Commit 6830b7e4 authored by claes's avatar claes

Navigation and editing from keyboard improved

parent 1beba15d
This diff is collapsed.
/*
* Proview $Id: wb_foe_gtk.h,v 1.4 2007-09-25 13:36:32 claes Exp $
* Proview $Id: wb_foe_gtk.h,v 1.5 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -59,6 +59,8 @@ struct s_widgets {
GtkWidget *paste;
GtkWidget *undelete;
GtkWidget *unselect;
GtkWidget *createnode;
GtkWidget *createcon;
GtkWidget *connect;
GtkWidget *del;
GtkWidget *changetext;
......@@ -79,6 +81,19 @@ struct s_widgets {
GtkWidget *view_plantpal;
GtkWidget *tools_save;
GtkWidget *tools_build;
GtkWidget *lockconpoint;
GtkWidget *move_right;
GtkWidget *move_left;
GtkWidget *move_up;
GtkWidget *move_down;
GtkWidget *select_addnextright;
GtkWidget *select_addnextleft;
GtkWidget *select_addnextup;
GtkWidget *select_addnextdown;
GtkWidget *select_cp_nextright;
GtkWidget *select_cp_nextleft;
GtkWidget *select_cp_nextup;
GtkWidget *select_cp_nextdown;
};
class WFoeGtk : public WFoe {
......@@ -174,6 +189,7 @@ class WFoeGtk : public WFoe {
static void activate_compile( GtkWidget *w, gpointer data);
static void delete_subwindow_ok_cb( void *ctx, void *data);
static void activate_delete( GtkWidget *w, gpointer data);
static void activate_delete_confirm( GtkWidget *w, gpointer data);
static void activate_createobject( GtkWidget *w, gpointer data);
static void activate_changetext( GtkWidget *w, gpointer data);
static void activate_cut( GtkWidget *w, gpointer data);
......@@ -183,10 +199,29 @@ class WFoeGtk : public WFoe {
static void activate_select_nextleft(GtkWidget *w, gpointer foe);
static void activate_select_nextup(GtkWidget *w, gpointer foe);
static void activate_select_nextdown(GtkWidget *w, gpointer foe);
static void activate_select_addnextright(GtkWidget *w, gpointer foe);
static void activate_select_addnextleft(GtkWidget *w, gpointer foe);
static void activate_select_addnextup(GtkWidget *w, gpointer foe);
static void activate_select_addnextdown(GtkWidget *w, gpointer foe);
static void activate_select_cp_nextright(GtkWidget *w, gpointer foe);
static void activate_select_cp_nextleft(GtkWidget *w, gpointer foe);
static void activate_select_cp_nextup(GtkWidget *w, gpointer foe);
static void activate_select_cp_nextdown(GtkWidget *w, gpointer foe);
static void activate_scroll_right(GtkWidget *w, gpointer foe);
static void activate_scroll_left(GtkWidget *w, gpointer foe);
static void activate_scroll_up(GtkWidget *w, gpointer foe);
static void activate_scroll_down(GtkWidget *w, gpointer foe);
static void activate_move_right(GtkWidget *w, gpointer foe);
static void activate_move_left(GtkWidget *w, gpointer foe);
static void activate_move_up(GtkWidget *w, gpointer foe);
static void activate_move_down(GtkWidget *w, gpointer foe);
static void activate_attribute( GtkWidget *w, gpointer data);
static void activate_subwindow( GtkWidget *w, gpointer data);
static void activate_undelete( GtkWidget *w, gpointer data);
static void activate_unselect( GtkWidget *w, gpointer data);
static void activate_createnode( GtkWidget *w, gpointer data);
static void activate_createcon( GtkWidget *w, gpointer data);
static void activate_lockconpoint( GtkWidget *w, gpointer data);
static void activate_gridsize1( GtkWidget *w, gpointer data);
static void activate_gridsize2( GtkWidget *w, gpointer data);
static void activate_gridsize3( GtkWidget *w, gpointer data);
......
/*
* Proview $Id: wb_pal_gtk.cpp,v 1.3 2008-02-27 06:27:51 claes Exp $
* Proview $Id: wb_pal_gtk.cpp,v 1.4 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -146,6 +146,7 @@ void PalGtk::set_selection_owner()
return;
}
selection_owner = 1;
brow_SetInverseColor( brow_ctx, flow_eDrawType_Line);
}
static void pal_sel_convert_cb( GtkWidget *w, GtkSelectionData *selection_data,
......@@ -185,7 +186,8 @@ static void pal_sel_lose_cb( GtkWidget *w, GdkEventSelection *event,
{
PalGtk *pal = (PalGtk *)data;
brow_SelectClear( pal->brow_ctx);
// brow_SelectClear( pal->brow_ctx);
brow_SetInverseColor( pal->brow_ctx, flow_eDrawType_LineGray);
pal->selection_owner = 0;
}
......
/*
* Proview $Id: wb_wtt_gtk.cpp,v 1.24 2008-06-24 07:52:21 claes Exp $
* Proview $Id: wb_wtt_gtk.cpp,v 1.25 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "co_cdh.h"
#include "co_time.h"
......@@ -1002,6 +1003,48 @@ void WttGtk::activate_rename( GtkWidget *w, gpointer data)
wtt->open_change_name();
}
void WttGtk::activate_creaobjafter( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_creaobj( ldh_eDest_After);
}
void WttGtk::activate_creaobjfirst( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_creaobj( ldh_eDest_IntoFirst);
}
void WttGtk::activate_moveobjup( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_moveobj( wnav_eDestCode_Before);
}
void WttGtk::activate_moveobjdown( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_moveobj( wnav_eDestCode_After);
}
void WttGtk::activate_moveobjinto( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_moveobj( wnav_eDestCode_FirstChild);
}
void WttGtk::activate_moveobjontop( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_moveobj( wnav_eDestCode_LastChild);
}
void WttGtk::activate_deleteobj( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
wtt->activate_deleteobj();
}
void WttGtk::activate_configure( GtkWidget *w, gpointer data)
{
Wtt *wtt = (Wtt *)data;
......@@ -2065,6 +2108,7 @@ WttGtk::WttGtk(
cm_add_attribute = gtk_check_menu_item_new_with_mnemonic( "_Add Attribute");
g_signal_connect( cm_add_attribute, "activate",
G_CALLBACK(WttGtk::activate_selmode), this);
cm_add_type = gtk_check_menu_item_new_with_mnemonic( "Add _Type");
g_signal_connect( cm_add_type, "activate",
G_CALLBACK(WttGtk::activate_selmode), this);
......@@ -2082,6 +2126,74 @@ WttGtk::WttGtk(
gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit_cm),
GTK_WIDGET(edit_cm_menu));
// Submenu Create Object
menu_creaobjafter_w = gtk_menu_item_new_with_mnemonic( "_After");
g_signal_connect( menu_creaobjafter_w, "activate",
G_CALLBACK(WttGtk::activate_creaobjafter), this);
gtk_widget_add_accelerator( menu_creaobjafter_w, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
menu_creaobjfirst_w = gtk_menu_item_new_with_mnemonic( "_First Child");
g_signal_connect( menu_creaobjfirst_w, "activate",
G_CALLBACK(WttGtk::activate_creaobjfirst), this);
gtk_widget_add_accelerator( menu_creaobjfirst_w, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *edit_creaobj = gtk_menu_item_new_with_mnemonic( "C_reate Object");
GtkMenu *edit_creaobj_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_creaobj_menu), menu_creaobjafter_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_creaobj_menu), menu_creaobjfirst_w);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit_creaobj),
GTK_WIDGET(edit_creaobj_menu));
// Submenu Move Object
menu_moveobjup_w = gtk_menu_item_new_with_mnemonic( "_Up");
g_signal_connect( menu_moveobjup_w, "activate",
G_CALLBACK(WttGtk::activate_moveobjup), this);
gtk_widget_add_accelerator( menu_moveobjup_w, "activate", accel_g,
GDK_Up, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
GTK_ACCEL_VISIBLE);
menu_moveobjdown_w = gtk_menu_item_new_with_mnemonic( "_Down");
g_signal_connect( menu_moveobjdown_w, "activate",
G_CALLBACK(WttGtk::activate_moveobjdown), this);
gtk_widget_add_accelerator( menu_moveobjdown_w, "activate", accel_g,
GDK_Down, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
GTK_ACCEL_VISIBLE);
menu_moveobjinto_w = gtk_menu_item_new_with_mnemonic( "_Into");
g_signal_connect( menu_moveobjinto_w, "activate",
G_CALLBACK(WttGtk::activate_moveobjinto), this);
gtk_widget_add_accelerator( menu_moveobjinto_w, "activate", accel_g,
GDK_Right, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
GTK_ACCEL_VISIBLE);
menu_moveobjontop_w = gtk_menu_item_new_with_mnemonic( "_OnTop");
g_signal_connect( menu_moveobjontop_w, "activate",
G_CALLBACK(WttGtk::activate_moveobjontop), this);
gtk_widget_add_accelerator( menu_moveobjontop_w, "activate", accel_g,
GDK_Left, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *edit_moveobj = gtk_menu_item_new_with_mnemonic( "_Move Object");
GtkMenu *edit_moveobj_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_moveobj_menu), menu_moveobjup_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_moveobj_menu), menu_moveobjdown_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_moveobj_menu), menu_moveobjinto_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_moveobj_menu), menu_moveobjontop_w);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit_moveobj),
GTK_WIDGET(edit_moveobj_menu));
menu_deleteobj_w = gtk_menu_item_new_with_mnemonic( "_Delete Object");
g_signal_connect( menu_deleteobj_w, "activate",
G_CALLBACK(WttGtk::activate_deleteobj), this);
gtk_widget_add_accelerator( menu_deleteobj_w, "activate", accel_g,
GDK_Delete, GdkModifierType(0), GTK_ACCEL_VISIBLE);
GtkWidget *edit_collapse = gtk_menu_item_new_with_mnemonic( "Co_llapse");
g_signal_connect( edit_collapse, "activate",
G_CALLBACK(WttGtk::activate_collapse), this);
......@@ -2117,6 +2229,9 @@ WttGtk::WttGtk(
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menu_edit_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_search);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_cm);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_creaobj);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_moveobj);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menu_deleteobj_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_collapse);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menu_cut_w);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menu_copy_w);
......
/*
* Proview $Id: wb_wtt_gtk.h,v 1.7 2008-02-27 06:30:10 claes Exp $
* Proview $Id: wb_wtt_gtk.h,v 1.8 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -99,6 +99,13 @@ class WttGtk : public Wtt {
GtkWidget *menu_edit_w;
GtkWidget *menu_classeditor_w;
GtkWidget *menu_updateclasses_w;
GtkWidget *menu_creaobjafter_w;
GtkWidget *menu_creaobjfirst_w;
GtkWidget *menu_deleteobj_w;
GtkWidget *menu_moveobjup_w;
GtkWidget *menu_moveobjdown_w;
GtkWidget *menu_moveobjinto_w;
GtkWidget *menu_moveobjontop_w;
GtkWidget *tools_edit_w;
GtkWidget *tools_buildnode_w;
GtkWidget *tools_save_w;
......@@ -183,6 +190,13 @@ class WttGtk : public Wtt {
static void activate_pasteinto( GtkWidget *w, gpointer data);
static void activate_copykeep( GtkWidget *w, gpointer data);
static void activate_rename( GtkWidget *w, gpointer data);
static void activate_creaobjafter( GtkWidget *w, gpointer data);
static void activate_creaobjfirst( GtkWidget *w, gpointer data);
static void activate_moveobjup( GtkWidget *w, gpointer data);
static void activate_moveobjdown( GtkWidget *w, gpointer data);
static void activate_moveobjinto( GtkWidget *w, gpointer data);
static void activate_moveobjontop( GtkWidget *w, gpointer data);
static void activate_deleteobj( GtkWidget *w, gpointer data);
static void activate_configure( GtkWidget *w, gpointer data);
static void activate_utilities( GtkWidget *w, gpointer data);
static void activate_openobject( GtkWidget *w, gpointer data);
......
/*
* Proview $Id: wb_foe.cpp,v 1.10 2008-06-24 07:52:21 claes Exp $
* Proview $Id: wb_foe.cpp,v 1.11 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -533,8 +533,56 @@ void WFoe::activate_compile()
show_executeorder();
}
void WFoe::pal_select_cb( void *ctx, pwr_tCid cid)
{
WFoe *foe = (WFoe *) ctx;
vldh_t_node node;
pwr_tStatus sts;
if ( foe->function != EDIT)
return;
foe->gre->pending_paste_stop();
foe->disable_ldh_cb();
sts = foe->gre->create_node_floating( cid, 0, 0, &node);
foe->enable_ldh_cb();
foe->error_msg( sts);
}
//
// Delete from menu
//
// Callback from the menu.
void WFoe::delete_ok_cb( void *ctx, void *data)
{
WFoe *foe = (WFoe *) ctx;
foe->activate_delete();
}
void WFoe::activate_delete_confirm()
{
unsigned long node_count;
vldh_t_node *nodelist;
char msg[200];
gre->get_selnodes( &node_count, &nodelist);
if ( !node_count) {
message( "Nothing to delete");
return;
}
if ( node_count > 1)
strcpy( msg, "Do you want to delete the selected objects");
else
strcpy( msg, "Do you want to delete the selected object");
wow->DisplayQuestion( this, "Delete", msg, delete_ok_cb, 0, *nodelist);
}
//
// Callback from the popup menu.
// Deletes the selected nodes and connections.
// Checks first that a selected node does not contain a subwindow.
//
......@@ -600,7 +648,7 @@ void WFoe::activate_delete()
/* Single node that has subwindow */
char msg[200];
sprintf( msg,
"Object \"%s\" has subwindow\n Do you wan't to delete the subwindow?",
"Object \"%s\" has subwindow\n Do you want to delete the subwindow?",
(*nodelist)->hn.name);
wow->DisplayQuestion( this,
"Delete subwindow", msg,
......@@ -761,7 +809,32 @@ void WFoe::activate_paste()
void WFoe::activate_select_nextobject( flow_eDirection dir)
{
gre->select_nextobject( dir);
gre->select_nextobject( dir, 0);
}
void WFoe::activate_select_addnextobject( flow_eDirection dir)
{
gre->select_nextobject( dir, 1);
}
void WFoe::activate_scroll( flow_eDirection dir)
{
gre->scroll( dir);
}
void WFoe::activate_select_nextconpoint( flow_eDirection dir)
{
gre->select_next_conpoint( dir);
}
void WFoe::activate_conpoint_lock()
{
gre->conpoint_lock(1);
}
void WFoe::activate_move_object( flow_eDirection dir)
{
gre->move_object( dir);
}
//
......@@ -879,6 +952,94 @@ void WFoe::activate_unselect()
}
//
// Callback from the menu.
// Create a node.
//
void WFoe::activate_createnode()
{
pwr_tClassId cid;
int sts;
vldh_t_node node;
if ( msg_label_id != 0 ) message( "");
gre->unselect();
/* Get selected nodes from palette */
sts = node_palctx->get_select( &cid);
if ( EVEN(sts)) {
message( "Choose an object from the palette");
BEEP;
return;
}
gre->pending_paste_stop();
disable_ldh_cb();
sts = gre->create_node_floating( cid, 0, 0, &node);
enable_ldh_cb();
error_msg( sts);
if ( EVEN(sts)) return;
}
//
// Callback from the menu.
// Create a connection.
//
void WFoe::activate_createconnection()
{
unsigned long node_count;
vldh_t_node *nodelist;
int *numlist;
int sts;
if ( msg_label_id != 0 ) message( "");
gre->get_conpoint_select( &node_count, &nodelist, &numlist);
if ( !node_count) {
message( "No connectionpoint is selected");
return;
}
if ( node_count == 1) {
double x, y;
flow_eDirection dir;
gre->get_conpoint( nodelist[0], numlist[0], &x, &y, &dir);
switch ( dir) {
case flow_eDirection_Up:
y += 0.15;
break;
case flow_eDirection_Down:
y -= 0.15;
break;
case flow_eDirection_Right:
x += 0.1;
break;
case flow_eDirection_Left:
x -= 0.3;
break;
default:
x -= 0.3;
}
gre_con_created( gre, x, y, nodelist[0], numlist[0], 0, 0, 1, &sts);
}
else {
gre_con_created( gre, 0, 0, nodelist[0], numlist[0], nodelist[1], numlist[1], 0, &sts);
gre->unselect();
}
if ( ODD(sts)) {
gre->conpoint_unselect();
gre->conpoint_lock(0);
}
free( nodelist);
free( numlist);
}
//
// Callback from the menu.
//
......@@ -1024,7 +1185,7 @@ void WFoe::activate_getobj()
/* get the id of the desired object */
sts = gobj_get_object( this, *nodelist, 1) ;
error_msg( sts);
gre->unselect();
// gre->unselect();
}
if ( node_count > 0) free((char *) nodelist);
......@@ -1365,17 +1526,16 @@ void WFoe::gre_con_selected( WGre *gre)
//
// Description: Backcall from the controlled gre module when
// a connection should be created.
// Checks syntax and gets a suitible connectionclass by foe_gsx.
// Checks syntax and gets a suitable connectionclass by foe_gsx.
// If foe->con_palette_managed is set the class is fetched
// from the connection palette. Creates a connection.
//
void WFoe::gre_con_created( WGre *gre, double x, double y,
vldh_t_node source_obj, unsigned long source_point,
vldh_t_node destination_obj, unsigned long destination_point)
vldh_t_node destination_obj, unsigned long destination_point, int select, int *sts)
{
pwr_tClassId con_class;
pwr_tClassId user_class;
int sts;
WFoe *foe;
vldh_t_node dest;
unsigned long destpoint;
......@@ -1384,8 +1544,8 @@ void WFoe::gre_con_created( WGre *gre, double x, double y,
if ( gre->trace_started) {
if ( !destination_obj) {
sts = trace_create_analyse( gre, x, y, source_obj, source_point);
if ( EVEN(sts)) {
*sts = trace_create_analyse( gre, x, y, source_obj, source_point);
if ( EVEN(*sts)) {
foe->message( "Unable to find trace attribute");
BEEP;
return;
......@@ -1404,8 +1564,8 @@ void WFoe::gre_con_created( WGre *gre, double x, double y,
if ( foe->con_palette_managed == 0 )
user_class = 0;
else {
sts = foe->con_palctx->get_select( &user_class);
if ( EVEN(sts)) {
*sts = foe->con_palctx->get_select( &user_class);
if ( EVEN(*sts)) {
/* SG 20.03.91 Inform the user that he has to choose a conn */
foe->message( "Choose a connection from the palette");
BEEP;
......@@ -1415,33 +1575,39 @@ void WFoe::gre_con_created( WGre *gre, double x, double y,
if ( !destination_obj) {
foe->disable_ldh_cb();
sts = gsx_auto_create( foe, x, y, source_obj, source_point,
*sts = gsx_auto_create( foe, x, y, source_obj, source_point,
&dest, &destpoint);
foe->enable_ldh_cb();
if ( EVEN(sts)) return;
if ( EVEN(*sts)) return;
if ( select)
gre->select_node( dest);
foe->gre->set_node_visible( dest);
}
else {
dest = destination_obj;
destpoint = destination_point;
}
/* Check connection syntax */
sts = gsx_check_connection( foe, source_obj, source_point,
*sts = gsx_check_connection( foe, source_obj, source_point,
dest, destpoint, &con_class, user_class);
if ( sts == GSX__CONTYPE) {
if ( *sts == GSX__CONTYPE) {
foe->message( "Connected attributes are not of the same type");
BEEP;
return;
}
foe->error_msg( sts);
if ( EVEN(sts)) return;
foe->error_msg( *sts);
if ( EVEN(*sts)) return;
if ( user_class)
con_class = user_class;
sts = gre->create_con( con_class, source_obj, source_point,
*sts = gre->create_con( con_class, source_obj, source_point,
dest, destpoint, foe->con_drawtype);
foe->error_msg( sts);
if ( EVEN(sts)) return;
foe->error_msg( *sts);
if ( EVEN(*sts)) return;
*sts = FOE__SUCCESS;
}
//
......@@ -2129,6 +2295,8 @@ void WFoe::quit()
vldh_t_wind wind;
int sts;
gre->pending_paste_stop();
/* Tell my parent that his child is quitting, if parent is a node */
wind = gre->wind;
if ( wind->hw.parent_node_pointer != 0 )
......@@ -2162,6 +2330,8 @@ void WFoe::foe_exit()
vldh_t_node parent_node;
int sts;
gre->pending_paste_stop();
/* Tell my parent that his child is quitting, if parent is a node */
wind = gre->wind;
windowindex = wind->lw.subwindowindex;
......@@ -2197,6 +2367,8 @@ void WFoe::foe_delete()
/* Tell my parent that his child is deleted, if parent is a node */
wind = gre->wind;
gre->pending_paste_stop();
sts = ldh_SaveSession( wind->hw.ldhses);
if ( EVEN(sts)) return;
......@@ -3296,6 +3468,8 @@ int WFoe::change_mode( int new_mode)
/* Save changes... */
wind = gre->wind;
gre->pending_paste_stop();
/* Check if changes are made */
sts = ldh_GetSessionInfo( wind->hw.ldhses, &info);
if ( EVEN(sts)) return sts;
......@@ -3441,6 +3615,8 @@ int WFoe::change_mode( int new_mode)
/* Save changes... */
wind = gre->wind;
gre->pending_paste_stop();
/* Check if changes are made */
sts = ldh_GetSessionInfo( wind->hw.ldhses, &info);
if ( EVEN(sts)) return sts;
......@@ -3525,6 +3701,8 @@ int WFoe::change_mode( int new_mode)
/* Save changes... */
wind = gre->wind;
gre->pending_paste_stop();
/* Check if changes are made */
sts = ldh_GetSessionInfo( wind->hw.ldhses, &info);
if ( EVEN(sts)) return sts;
......
/*
* Proview $Id: wb_foe.h,v 1.16 2008-05-29 14:57:53 claes Exp $
* Proview $Id: wb_foe.h,v 1.17 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -199,16 +199,24 @@ class WFoe : public WUtility {
void activate_syntax();
void activate_compile();
void activate_delete();
void activate_delete_confirm();
void activate_createobject( float x, float y);
void activate_changetext();
void activate_cut();
void activate_copy();
void activate_paste();
void activate_select_nextobject( flow_eDirection dir);
void activate_select_addnextobject( flow_eDirection dir);
void activate_select_nextconpoint( flow_eDirection dir);
void activate_scroll( flow_eDirection dir);
void activate_move_object( flow_eDirection dir);
void activate_attribute();
void activate_subwindow();
void activate_undelete();
void activate_unselect();
void activate_createnode();
void activate_createconnection();
void activate_connect();
void activate_redraw();
void activate_zoomin();
void activate_zoomout();
......@@ -228,6 +236,7 @@ class WFoe : public WUtility {
void activate_simulate_togg( int set);
void activate_view_togg( int set);
void activate_edit_togg( int set);
void activate_conpoint_lock();
void function_setup();
int register_callbacks();
......@@ -281,6 +290,7 @@ class WFoe : public WUtility {
static void edit_exit_save( WFoe *foe);
static void edit_exit_nosave( WFoe *foe);
static void delete_subwindow_ok_cb( void *ctx, void *data);
static void delete_ok_cb( void *ctx, void *data);
static void exit_save( WFoe *foe);
static void exit_nosave( WFoe *foe);
......@@ -294,7 +304,7 @@ class WFoe : public WUtility {
static void gre_con_selected( WGre *gre);
static void gre_con_created( WGre *gre, double x, double y,
vldh_t_node source_obj, unsigned long source_point,
vldh_t_node destination_obj, unsigned long destination_point);
vldh_t_node destination_obj, unsigned long destination_point, int select, int *sts);
static void gre_region_selected( WGre *gre);
static void gre_enter_leave( WGre *gre);
static void gre_delete( WGre *gre, void *object, unsigned long object_type);
......@@ -312,6 +322,8 @@ class WFoe : public WUtility {
static void gre_regionmoved( WGre *gre);
static void gre_message( WGre *gre, char *message);
static void pal_select_cb( void *ctx, pwr_tCid cid);
};
......
/*
* Proview $Id: wb_gobj.cpp,v 1.3 2007-12-06 10:55:04 claes Exp $
* Proview $Id: wb_gobj.cpp,v 1.4 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1188,6 +1188,7 @@ int gobj_get_object_m14( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
return FOE__SUCCESS;
......@@ -1303,6 +1304,7 @@ int gobj_get_object_m15( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
return FOE__SUCCESS;
......@@ -1429,6 +1431,7 @@ int gobj_get_object_m16( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
return FOE__SUCCESS;
......@@ -1545,6 +1548,7 @@ int gobj_get_object_m17( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......@@ -1706,6 +1710,7 @@ int gobj_get_object_m19( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......@@ -1815,6 +1820,7 @@ int gobj_get_object_m20( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......@@ -2093,6 +2099,7 @@ int gobj_get_object_m24( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......@@ -2215,6 +2222,7 @@ int gobj_get_object_m25( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......@@ -2466,6 +2474,7 @@ int gobj_get_object_m28( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......@@ -2597,6 +2606,7 @@ int gobj_get_object_m29( WFoe *foe, vldh_t_node node, unsigned long index)
if ( EVEN(sts)) return sts;
foe->gre->node_update( new_node);
foe->gre->select_node( new_node);
if ( con_count > 0) free((char *) con_list);
......
This diff is collapsed.
/*
* Proview $Id: wb_gre.h,v 1.9 2007-09-25 13:36:32 claes Exp $
* Proview $Id: wb_gre.h,v 1.10 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -112,11 +112,15 @@ class WGre {
flow_tNode trace_changenode;
int popup_menu_x;
int popup_menu_y;
int conpoint_locked;
vldh_t_node last_selected;
vldh_t_node last_cp_selected;
int last_cp_selected_num;
/* Callbacks */
void (*gre_setup_window)(WGre *);
void (*gre_node_created)(WGre *, unsigned long, float, float);
void (*gre_con_created)(WGre *, double, double, vldh_t_node, unsigned long, vldh_t_node, unsigned long);
void (*gre_con_created)(WGre *, double, double, vldh_t_node, unsigned long, vldh_t_node, unsigned long, int, int *);
void (*gre_node_moved)(WGre *);
void (*gre_delete)(WGre *, void *, unsigned long);
void (*gre_cut)(WGre *, void *, unsigned long);
......@@ -146,6 +150,7 @@ class WGre {
void message( char *message);
void ctx_init();
void unselect();
void conpoint_unselect();
void search_rectangle_delete();
void search_rectangle_create( vldh_t_node node);
void create_cursors();
......@@ -173,7 +178,7 @@ class WGre {
int setup_backcalls (
void (*setup_window_bc)(WGre *),
void (*node_created_bc)(WGre *, unsigned long, float, float),
void (*con_created_bc)(WGre *, double, double, vldh_t_node, unsigned long, vldh_t_node, unsigned long),
void (*con_created_bc)(WGre *, double, double, vldh_t_node, unsigned long, vldh_t_node, unsigned long, int, int *),
void (*node_moved_bc)(WGre *),
void (*delete_bc)(WGre *, void *, unsigned long),
void (*cut_bc)(WGre *, void *, unsigned long),
......@@ -190,6 +195,7 @@ class WGre {
void (*regionmoved_bc)(WGre *),
void (*message_bc)(WGre *, char *));
int create_node( pwr_tClassId cid, float x, float y, vldh_t_node *node);
int create_node_floating( pwr_tClassId cid, float x, float y, vldh_t_node *node);
int create_con( pwr_tClassId cid,
vldh_t_node source_obj, unsigned long source_point,
vldh_t_node destination_obj, unsigned long destination_point,
......@@ -229,8 +235,17 @@ class WGre {
flow_tConClass *con_class);
void pixel_to_position( int pix_x, int pix_y, double *x, double *y);
void select_nextobject( flow_eDirection dir);
void select_node( vldh_t_node node);
void select_nextobject( flow_eDirection dir, int add);
void select_next_conpoint( flow_eDirection dir);
void move_object( flow_eDirection dir);
void pending_paste_stop();
int get_conpoint_select( unsigned long *node_count, vldh_t_node **nodelist, int **numlist);
int get_conpoint( vldh_t_node node, int num, double *x, double *y, flow_eDirection *dir);
void conpoint_lock( int lock) { conpoint_locked = lock;}
void scroll( flow_eDirection dir);
void set_node_visible( vldh_t_node node);
static int get_annot_width( flow_tNodeClass nodeclass,
float *annot_width, char *annot_str, int annot_count,
int annot_size);
......
/*
* Proview $Id: wb_pal.cpp,v 1.11 2007-01-11 11:40:30 claes Exp $
* Proview $Id: wb_pal.cpp,v 1.12 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1254,10 +1254,11 @@ int Pal::brow_cb( FlowCtx *ctx, flow_tEvent event)
;
}
break;
case flow_eEvent_MB1Click:
case flow_eEvent_MB1Click: {
// Select
double ll_x, ll_y, ur_x, ur_y;
int sts;
pwr_tCid cid = pwr_cNCid;
if ( pal->set_focus_cb)
(pal->set_focus_cb)( pal->parent_ctx, pal);
......@@ -1280,22 +1281,56 @@ int Pal::brow_cb( FlowCtx *ctx, flow_tEvent event)
return sts;
}
if ( brow_FindSelectedObject( pal->brow_ctx, event->object.object))
{
brow_SelectClear( pal->brow_ctx);
}
else
{
if ( !brow_FindSelectedObject( pal->brow_ctx, event->object.object)) {
brow_SelectClear( pal->brow_ctx);
brow_SetInverse( event->object.object, 1);
brow_SelectInsert( pal->brow_ctx, event->object.object);
}
if ( !pal->select_cb)
break;
switch ( event->object.object_type) {
case flow_eObjectType_Node:
brow_GetUserData( event->object.object, (void **)&item);
switch ( item->type) {
case pal_ePalItemType_Object:
char name[32];
int size;
sts = ldh_ObjidToName( pal->ldhses, item->objid, ldh_eName_Object,
name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
sts = ldh_ClassNameToId( pal->ldhses, &cid, name);
if ( EVEN(sts)) return sts;
break;
case pal_ePalItemType_Class:
sts = ldh_ClassNameToId( pal->ldhses, &cid, ((PalItemClass *)item)->name);
if ( EVEN(sts)) return sts;
break;
default:
;
}
default:
;
}
if ( cid == pwr_cNCid)
break;
pal->select_cb( pal->parent_ctx, cid);
break;
default:
brow_SelectClear( pal->brow_ctx);
}
pal->last_selected = event->object.object;
break;
}
case flow_eEvent_Map:
{
pal->displayed = 1;
......@@ -1305,6 +1340,7 @@ int Pal::brow_cb( FlowCtx *ctx, flow_tEvent event)
{
// Popup menu
pwr_tCid cid = pwr_cNCid;
pwr_tStatus sts;
if ( !pal->create_popup_menu_cb)
break;
......@@ -1503,7 +1539,7 @@ Pal::Pal(
parent_ctx(pal_parent_ctx),
wbctx(0), ldhses(pal_ldhses), root_objid(pwr_cNObjid), root_item(0),
last_selected(0), selection_owner(0), set_focus_cb(0),
traverse_focus_cb(0), create_popup_menu_cb(0), displayed(0), menu(0)
traverse_focus_cb(0), create_popup_menu_cb(0), select_cb(0), displayed(0), menu(0)
{
strcpy( name, pal_name);
strcpy( root_name, pal_root_name);
......
/*
* Proview $Id: wb_pal.h,v 1.6 2007-01-04 07:29:04 claes Exp $
* Proview $Id: wb_pal.h,v 1.7 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -60,6 +60,7 @@ class Pal {
int (*set_focus_cb)( void *, void *);
int (*traverse_focus_cb)( void *, void *);
void (*create_popup_menu_cb)( void *, pwr_tCid, int, int);
void (*select_cb)( void *, pwr_tCid);
int displayed;
PalFileMenu *menu;
......
/*
* Proview $Id: wb_tra.cpp,v 1.2 2007-11-22 08:50:55 claes Exp $
* Proview $Id: wb_tra.cpp,v 1.3 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1064,6 +1064,7 @@ static int trace_flow_cb( FlowCtx *ctx, flow_tEvent event)
void *vobject;
double ll_x, ll_y, ur_x, ur_y, width;
int subwindow_nr;
int sts;
flow_GetCtxUserData( ctx, (void **)&gre);
......@@ -1087,7 +1088,7 @@ static int trace_flow_cb( FlowCtx *ctx, flow_tEvent event)
(gre->gre_con_created) (gre,
event->con_create.x, event->con_create.y,
source, event->con_create.source_conpoint,
dest, event->con_create.dest_conpoint);
dest, event->con_create.dest_conpoint, 0, &sts);
}
switch ( event->event)
{
......
/*
* Proview $Id: wb_vldh.cpp,v 1.2 2008-01-24 09:49:05 claes Exp $
* Proview $Id: wb_vldh.cpp,v 1.3 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -4727,6 +4727,33 @@ char *vldh_VolumeIdToStr( pwr_tVolumeId volumeid)
return str;
}
//
// Check if node exist in this window
//
int vldh_check_node(
vldh_t_wind wind,
vldh_t_node node
)
{
vldh_t_node *nodelist;
unsigned long node_count;
int sts, node_found;
sts = vldh_get_nodes( wind, &node_count, &nodelist);
if ( EVEN(sts)) return 0;
node_found = 0;
for ( unsigned int i = 0; i < node_count; i++) {
if ( node == nodelist[i]) {
node_found = 1;
break;
}
}
if ( node_count > 0) free((char *) nodelist);
return node_found;
}
static void cnv_from_neted( vldh_t_node n)
{
const float pin = 0.05;
......
/*
* Proview $Id: wb_vldh.h,v 1.8 2007-01-04 07:29:04 claes Exp $
* Proview $Id: wb_vldh.h,v 1.9 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -544,6 +544,11 @@ pwr_tStatus vldh_StrToId(
pwr_tObjid *objid
);
int vldh_check_node(
vldh_t_wind wind,
vldh_t_node node
);
#ifdef __cplusplus
}
#endif
......
/*
* Proview $Id: wb_wnav.cpp,v 1.41 2008-06-24 07:52:21 claes Exp $
* Proview $Id: wb_wnav.cpp,v 1.42 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -3051,6 +3051,117 @@ void WNav::select_object( brow_tObject object)
brow_SelectInsert( brow->ctx, object);
}
int WNav::select_object( pwr_tOid oid)
{
int sts;
WItem *item;
if ( !selection_owner)
return 0;
sts = find( oid, (void **)&item);
if ( EVEN(sts)) return sts;
brow_SelectClear( brow->ctx);
brow_SetInverse( item->node, 1);
brow_SelectInsert( brow->ctx, item->node);
return 1;
}
int WNav::get_next( pwr_tOid oid, wnav_eDestCode dest, pwr_tOid *next_oid, wnav_eDestCode *d)
{
int sts;
WItem *item, *next_item, *next_next_item;
brow_tObject next_node, next_next_node;
int level, next_level, next_next_level;
sts = find( oid, (void **)&item);
if ( EVEN(sts)) return sts;
if ( dest == wnav_eDestCode_After) {
sts = brow_GetNext( brow->ctx, item->node, &next_node);
if ( EVEN(sts)) {
// No next, return parent as next
sts = brow_GetParent( brow->ctx, item->node, &next_node);
*d = wnav_eDestCode_After;
return sts;
}
else {
level = brow_GetObjectLevel( item->node);
next_level = brow_GetObjectLevel( next_node);
if ( level > next_level) {
// Next has higher level, return parent as next
sts = brow_GetParent( brow->ctx, item->node, &next_node);
*d = wnav_eDestCode_After;
}
else {
// If next has open children, move to first child
sts = brow_GetNext( brow->ctx, next_node, &next_next_node);
if ( ODD(sts)) {
next_next_level = brow_GetObjectLevel( next_next_node);
if ( next_level < next_next_level) {
brow_GetUserData( next_next_node, (void **)&next_next_item);
if ( next_next_item->type == wnav_eItemType_Object)
*d = wnav_eDestCode_FirstChild;
else
*d = wnav_eDestCode_After;
}
else
*d = wnav_eDestCode_After;
}
else
*d = wnav_eDestCode_After;
}
}
}
else if ( dest == wnav_eDestCode_Before) {
sts = brow_GetPrevious( brow->ctx, item->node, &next_node);
if ( EVEN(sts)) return sts;
level = brow_GetObjectLevel( item->node);
next_level = brow_GetObjectLevel( next_node);
if ( level < next_level)
*d = wnav_eDestCode_After;
else
*d = wnav_eDestCode_Before;
}
else if ( dest == wnav_eDestCode_FirstChild) {
// First Child
sts = brow_GetPrevious( brow->ctx, item->node, &next_node);
if ( EVEN(sts)) return sts;
*d = wnav_eDestCode_FirstChild;
}
else {
// Parent
sts = brow_GetParent( brow->ctx, item->node, &next_node);
if ( EVEN(sts)) return sts;
*d = wnav_eDestCode_After;
}
brow_GetUserData( next_node, (void **)&next_item);
*next_oid = next_item->objid;
return 1;
}
void WNav::set_select_visible()
{
brow_tNode *node_list;
int node_count;
brow_GetSelectedNodes( brow->ctx, &node_list, &node_count);
if ( !node_list)
return;
if ( !brow_IsVisible( brow->ctx, node_list[0], flow_eVisible_Full))
brow_CenterObject( brow->ctx, node_list[0], 0.50);
free( node_list);
}
void WNav::collapse()
{
brow_SelectClear( brow->ctx);
......
/*
* Proview $Id: wb_wnav.h,v 1.16 2008-06-24 07:52:21 claes Exp $
* Proview $Id: wb_wnav.h,v 1.17 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -402,6 +402,9 @@ class WNav : public WUtility{
int search_next();
int show_file( char *filename, char *intitle, int hide_dir);
void select_object( brow_tObject object);
int select_object( pwr_tOid oid);
int get_next( pwr_tOid oid, wnav_eDestCode dest, pwr_tOid *next_oid, wnav_eDestCode *d);
void set_select_visible();
// Crr module member functions
int crr_signal( char *filename, char *signalname, brow_tNode parent_node);
......
/*
* Proview $Id: wb_wtt.cpp,v 1.39 2008-06-24 07:52:22 claes Exp $
* Proview $Id: wb_wtt.cpp,v 1.40 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1231,7 +1231,7 @@ void Wtt::activate_openobject()
// Get selections in w1
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt1);
set_clock_cursor();
if ODD(sts) {
if (ODD(sts)) {
for ( i = 0; i < sel_cnt1; i++)
watt_new( sel_list[i]);
free( (char *)sel_list);
......@@ -1239,7 +1239,7 @@ void Wtt::activate_openobject()
}
sts = wnavnode->get_select( &sel_list, &sel_is_attr, &sel_cnt2);
if ODD(sts) {
if (ODD(sts)) {
for ( i = 0; i < sel_cnt2; i++)
watt_new( sel_list[i]);
free( (char *)sel_list);
......@@ -1254,6 +1254,272 @@ void Wtt::activate_openobject()
}
}
void Wtt::activate_creaobj( ldh_eDest dest)
{
int sts;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
pwr_tOid oid;
pwr_tCid cid;
int navnode = 0;
message( ' ', "");
sts = palette->get_select( &cid);
if ( EVEN(sts)) {
message( 'E', "Select a class in the palette");
return;
}
// Get selections in w1
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts)) {
sts = wnavnode->get_select( &sel_list, &sel_is_attr, &sel_cnt);
navnode = 1;
}
if ( EVEN(sts)) {
message( 'E', "No object is selected");
return;
}
if ( sel_cnt > 1) {
message( 'E', "Select one object");
return;
}
sts = ldh_CreateObject( ldhses, &oid, 0, cid, sel_list[0].Objid, dest);
if ( EVEN(sts)) {
message( 'E', wnav_get_message( sts));
return;
}
if ( navnode)
wnavnode->select_object( oid);
else
wnav->select_object( oid);
free( (char *)sel_list);
free( (char *)sel_is_attr);
}
void Wtt::activate_moveobj( wnav_eDestCode dest)
{
int sts;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
pwr_tOid next_oid;
int navnode = 0;
wnav_eDestCode d;
pwr_tOid parent;
pwr_tCid cid;
message( ' ', "");
// Get selections in w1
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts)) {
sts = wnavnode->get_select( &sel_list, &sel_is_attr, &sel_cnt);
navnode = 1;
}
if ( EVEN(sts)) {
message( 'E', "No object is selected");
return;
}
if ( sel_cnt > 1) {
message( 'E', "Select one object");
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
if ( sel_is_attr[0]) {
message( 'E', "Unable to move attributes");
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
if ( navnode)
sts = wnavnode->get_next( sel_list[0].Objid, dest, &next_oid, &d);
else
sts = wnav->get_next( sel_list[0].Objid, dest, &next_oid, &d);
if ( EVEN(sts)) {
message( 'E', wnav_get_message( sts));
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
// No plc objects can be moved
sts = ldh_GetParent( ldhses, sel_list[0].Objid, &parent);
while (ODD(sts)) {
sts = ldh_GetObjectClass( ldhses, parent, &cid);
if ( cid == pwr_cClass_plc || cid == pwr_cClass_PlcTemplate) {
message( 'E', "Unable to move plc objects");
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
sts = ldh_GetParent( ldhses, parent, &parent);
}
sts = ldh_GetParent( ldhses, next_oid, &parent);
while (ODD(sts)) {
sts = ldh_GetObjectClass( ldhses, parent, &cid);
if ( cid == pwr_cClass_plc || cid == pwr_cClass_PlcTemplate) {
message( 'E', "Unable to move plc objects");
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
sts = ldh_GetParent( ldhses, parent, &parent);
}
if ( d == wnav_eDestCode_FirstChild) {
sts = ldh_GetObjectClass( ldhses, next_oid, &cid);
if ( EVEN(sts)) return;
if ( cid == pwr_cClass_plc || cid == pwr_cClass_PlcTemplate) {
message( 'E', "Unable to move into plcpgm");
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
}
switch ( d) {
case wnav_eDestCode_Before:
sts = ldh_MoveObject( ldhses, sel_list[0].Objid, next_oid, ldh_eDest_Before);
break;
case wnav_eDestCode_After:
sts = ldh_MoveObject( ldhses, sel_list[0].Objid, next_oid, ldh_eDest_After);
break;
case wnav_eDestCode_FirstChild:
sts = ldh_MoveObject( ldhses, sel_list[0].Objid, next_oid, ldh_eDest_IntoFirst);
break;
case wnav_eDestCode_LastChild:
sts = ldh_MoveObject( ldhses, sel_list[0].Objid, next_oid, ldh_eDest_IntoLast);
break;
}
if ( EVEN(sts)) {
message( 'E', wnav_get_message( sts));
free( (char *)sel_list);
free( (char *)sel_is_attr);
return;
}
if ( navnode)
wnavnode->set_select_visible();
else
wnav->set_select_visible();
free( (char *)sel_list);
free( (char *)sel_is_attr);
}
void Wtt::activate_deleteobj()
{
int sts;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
int has_child = 0;
char msg[200];
pwr_tOid child;
message( ' ', "");
// Get selections in w1
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts))
sts = wnavnode->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts)) {
message( 'E', "No object is selected");
return;
}
for ( int i = 0; i < sel_cnt; i++) {
if ( sel_is_attr[i]) {
message( 'E', "Selected item is not an object");
return;
}
}
for ( int i = 0; i < sel_cnt; i++) {
sts = ldh_GetChild( ldhses, sel_list[i].Objid, &child);
if ( ODD(sts)) {
has_child = 1;
break;
}
}
if ( sel_cnt == 1) {
if ( has_child)
strcpy( msg, "Selected object has children !\nDo you want to delete the object tree");
else
strcpy( msg, "Do you want to delete the selected object");
}
else {
if ( has_child)
strcpy( msg, "Selected objects have children !\nDo you want to delete the object trees");
else
strcpy( msg, "Do you want to delete the selected objects");
}
open_confirm( msg, "Delete Object", delete_ok, 0);
free( (char *)sel_list);
free( (char *)sel_is_attr);
}
void Wtt::delete_ok( Wtt *wtt)
{
int sts;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
pwr_tOid child;
// Get selections in w1
sts = wtt->wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts))
sts = wtt->wnavnode->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts))
return;
if ( EVEN(sts)) {
wtt->message( 'E', "No object is selected");
return;
}
for ( int i = 0; i < sel_cnt; i++) {
if ( sel_is_attr[i]) {
wtt->message( 'E', "Selected item is not an object");
return;
}
}
for ( int i = 0; i < sel_cnt; i++) {
sts = ldh_GetChild( wtt->ldhses, sel_list[i].Objid, &child);
if ( ODD(sts)) {
sts = ldh_DeleteObjectTree( wtt->ldhses, sel_list[i].Objid, 0);
}
else {
sts = ldh_DeleteObject( wtt->ldhses, sel_list[i].Objid);
}
}
free( (char *)sel_list);
free( (char *)sel_is_attr);
}
void Wtt::activate_openvolobject()
{
pwr_tObjid objid;
......
/*
* Proview $Id: wb_wtt.h,v 1.18 2007-09-21 10:49:39 claes Exp $
* Proview $Id: wb_wtt.h,v 1.19 2008-10-03 14:18:37 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -214,6 +214,9 @@ class Wtt : public WUtility {
void activate_configure();
void activate_utilities();
void activate_openobject();
void activate_creaobj( ldh_eDest dest);
void activate_moveobj( wnav_eDestCode dest);
void activate_deleteobj();
void activate_openvolobject();
void activate_openplc();
void activate_buildobject();
......@@ -324,6 +327,7 @@ class Wtt : public WUtility {
static int get_wbctx( void *ctx, ldh_tWBContext *wbctx);
static void wpkg_quit_cb( void *ctx);
static void uted_quit_cb( void *ctx);
static void delete_ok( Wtt *wtt);
virtual ~Wtt();
......
/*
* Proview $Id: flow.h,v 1.14 2008-01-18 13:55:06 claes Exp $
* Proview $Id: flow.h,v 1.15 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -186,7 +186,8 @@ typedef enum {
flow_eEventType_MoveNode,
flow_eEventType_Object,
flow_eEventType_AnnotationInput,
flow_eEventType_Radiobutton
flow_eEventType_Radiobutton,
flow_eEventType_SelectConPoint
} flow_eEventType;
typedef enum {
......
/*
* Proview $Id: flow_annotpixmap.cpp,v 1.6 2007-09-25 13:11:00 claes Exp $
* Proview $Id: flow_annotpixmap.cpp,v 1.7 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -179,7 +179,7 @@ void FlowAnnotPixmap::draw_inverse( void *pos, int hot, void *node)
p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y,
&((FlowNode *) node)->annotpixmapv[number]->pixmap_data,
((FlowNode *) node)->annotpixmapv[number]->pixmaps,
draw_type, idx, 0);
ctx->inverse_color, idx, 0);
}
void FlowAnnotPixmap::erase( void *pos, int hot, void *node)
......
/*
* Proview $Id: flow_api.cpp,v 1.15 2008-05-28 12:03:52 claes Exp $
* Proview $Id: flow_api.cpp,v 1.16 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -128,6 +128,16 @@ void flow_SelectClear( flow_tCtx ctx)
ctx->select_clear();
}
void flow_ConPointSelectInsert( flow_tCtx ctx, flow_tObject object, int num)
{
ctx->conpoint_select( (FlowArrayElem *)object, num);
}
void flow_ConPointSelectClear( flow_tCtx ctx)
{
ctx->conpoint_select_clear();
}
void flow_GetSelectedNodes( flow_tCtx ctx, flow_tNode **nodes, int *num)
{
ctx->get_selected_nodes( (FlowArrayElem ***) nodes, num);
......@@ -415,11 +425,21 @@ void flow_GetSelectList( flow_tCtx ctx, flow_tObject **list, int *cnt)
ctx->get_selectlist( (FlowArrayElem ***)list, cnt);
}
void flow_GetPasteList( flow_tCtx ctx, flow_tObject **list, int *cnt)
{
ctx->get_pastelist( (FlowArrayElem ***)list, cnt);
}
void flow_GetObjectList( flow_tCtx ctx, flow_tObject **list, int *cnt)
{
ctx->get_objectlist( (FlowArrayElem ***)list, cnt);
}
void flow_GetConPointSelectList( flow_tCtx ctx, flow_tObject **list, int **num_list, int *cnt)
{
ctx->get_conpoint_selectlist( (FlowArrayElem ***)list, num_list, cnt);
}
flow_eObjectType flow_GetObjectType( flow_tObject object)
{
return ((FlowArrayElem *)object)->type();
......@@ -606,6 +626,11 @@ void flow_CenterObject( flow_tCtx ctx, flow_tObject object)
ctx->center_object( (FlowArrayElem *)object);
}
void flow_MoveSelectedNodes( flow_tCtx ctx, double delta_x, double delta_y, int grid)
{
ctx->move_selected_nodes( delta_x, delta_y, grid);
}
void flow_GetNodePosition( flow_tNode node, double *x, double *y)
{
((FlowNode *)node)->get_node_position( x, y);
......@@ -710,6 +735,13 @@ int flow_GetNextObject( flow_tCtx ctx, flow_tNode object, flow_eDirection dir,
(FlowArrayElem **)next);
}
int flow_GetNextConPoint( flow_tCtx ctx, flow_tNode object, int cp_num, flow_eDirection dir,
flow_tNode *next, int *next_cp_num)
{
return ctx->get_next_conpoint( (FlowArrayElem *)object, cp_num, dir,
(FlowArrayElem **)next, next_cp_num);
}
int flow_IsVisible( flow_tCtx ctx, flow_tObject object, flow_eVisible type)
{
return ctx->is_visible( (FlowArrayElem *)object, type);
......@@ -734,4 +766,19 @@ void flow_RemoveTipText( flow_tCtx ctx)
ctx->tiptext->remove();
}
int flow_PasteStop( flow_tCtx ctx)
{
return ctx->paste_stop();
}
int flow_PendingPaste( flow_tCtx ctx)
{
return ctx->pending_paste();
}
int flow_PendingPasteStop( flow_tCtx ctx)
{
return ctx->pending_paste_stop();
}
/*
* Proview $Id: flow_api.h,v 1.15 2008-05-28 12:03:52 claes Exp $
* Proview $Id: flow_api.h,v 1.16 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -98,6 +98,8 @@ void flow_ResetSelectInverse( flow_tCtx ctx);
void flow_SelectInsert( flow_tCtx ctx, flow_tObject object);
void flow_SelectRemove( flow_tCtx ctx, flow_tObject object);
void flow_SelectClear( flow_tCtx ctx);
void flow_ConPointSelectInsert( flow_tCtx ctx, flow_tObject object, int num);
void flow_ConPointSelectClear( flow_tCtx ctx);
void flow_GetSelectedNodes( flow_tCtx ctx, flow_tNode **nodes, int *num);
void flow_GetSelectedCons( flow_tCtx ctx, flow_tCon **cons, int *num);
void flow_SetHighlight( flow_tObject object, int value);
......@@ -177,7 +179,9 @@ void flow_CreateConClass( flow_tCtx ctx, char *name,
void flow_SetDefaultConClass( flow_tCtx ctx, flow_tConClass conclass);
flow_tConClass flow_GetDefaultConClass( flow_tCtx ctx);
void flow_GetSelectList( flow_tCtx ctx, flow_tObject **list, int *cnt);
void flow_GetPasteList( flow_tCtx ctx, flow_tObject **list, int *cnt);
void flow_GetObjectList( flow_tCtx ctx, flow_tObject **list, int *cnt);
void flow_GetConPointSelectList( flow_tCtx ctx, flow_tObject **list, int **num_list, int *cnt);
flow_eObjectType flow_GetObjectType( flow_tObject object);
void flow_MeasureNode( flow_tNode node, double *ll_x, double *ll_y,
double *ur_x, double *ur_y);
......@@ -213,6 +217,7 @@ void flow_PixelToPosition( flow_tCtx ctx, int pix_x, int pix_y,
double *x, double *y);
void flow_UnZoom( flow_tCtx ctx);
void flow_CenterObject( flow_tCtx ctx, flow_tObject object);
void flow_MoveSelectedNodes( flow_tCtx ctx, double delta_x, double delta_y, int grid);
void flow_GetNodePosition( flow_tNode node, double *x, double *y);
void flow_GetConPosition( flow_tCon con, double *x_arr[], double *y_arr[],
int *num);
......@@ -239,10 +244,16 @@ void flow_SetClickSensitivity( flow_tCtx ctx, int value);
void flow_SetNoConObstacle( flow_tNodeClass nc, int no_obstacle);
int flow_GetNextObject( flow_tCtx ctx, flow_tNode object, flow_eDirection dir,
flow_tNode *next);
int flow_GetNextConPoint( flow_tCtx ctx, flow_tNode object, int cp_num, flow_eDirection dir,
flow_tNode *next, int *next_cp_num);
int flow_IsVisible( flow_tCtx ctx, flow_tObject object, flow_eVisible type);
int flow_LoadNodeClass( flow_tCtx ctx, char *fname, flow_tNodeClass *nodeclass);
void flow_SetTipText( flow_tCtx ctx, flow_tObject object, char *text, int x, int y);
void flow_RemoveTipText( flow_tCtx ctx);
int flow_PasteStop( flow_tCtx ctx);
int flow_PendingPaste( flow_tCtx ctx);
int flow_PendingPasteStop( flow_tCtx ctx);
#if defined __cplusplus
}
......
/*
* Proview $Id: flow_browapi.cpp,v 1.11 2008-01-24 09:33:47 claes Exp $
* Proview $Id: flow_browapi.cpp,v 1.12 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -761,3 +761,13 @@ void brow_SetTipText( brow_tCtx ctx, brow_tObject object, char *text, int x, int
{
ctx->tiptext->draw_text( (FlowArrayElem *)object, text, x, y);
}
void brow_SetInverseColor( brow_tCtx ctx, flow_eDrawType color)
{
ctx->set_inverse_color( color);
}
int brow_GetObjectLevel( brow_tObject object)
{
return ((FlowNode *)object)->get_level();
}
/*
* Proview $Id: flow_browapi.h,v 1.11 2008-01-24 09:33:47 claes Exp $
* Proview $Id: flow_browapi.h,v 1.12 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -237,6 +237,8 @@ void brow_SetClickSensitivity( brow_tCtx ctx, int value);
void brow_SetWhiteBackground( brow_tCtx ctx);
void brow_SetFillColor( brow_tNode node, flow_eDrawType color);
void brow_SetTipText( brow_tCtx ctx, brow_tObject object, char *text, int x, int y);
void brow_SetInverseColor( brow_tCtx ctx, flow_eDrawType color);
int brow_GetObjectLevel( brow_tObject object);
#if defined __cplusplus
}
......
/*
* Proview $Id: flow_conpoint.cpp,v 1.3 2005-10-21 16:11:22 claes Exp $
* Proview $Id: flow_conpoint.cpp,v 1.4 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -25,6 +25,7 @@
#include "flow_conpoint.h"
#include "flow_draw.h"
#include "flow_node.h"
void FlowConPoint::zoom()
{
......@@ -140,6 +141,79 @@ void FlowConPoint::get_trace_attr( char *object, char *attribute,
*inverted = 0;
}
void FlowConPoint::draw( void *pos, int highlight, int hot, void *node)
{
int line_width = 1;
int idx = int( ctx->zoom_factor / ctx->base_zoom_factor * line_width - 1) + 2;
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
int size = (int)(0.025 * ctx->zoom_factor);
int x, y;
if ( ((FlowNode *)node)->sel_conpoint1 == number ||
((FlowNode *)node)->sel_conpoint2 == number) {
switch ( direction) {
case flow_eDirection_Up:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size/2;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size;;
break;
case flow_eDirection_Down:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size/2;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y;
break;
case flow_eDirection_Right:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size/2;
break;
case flow_eDirection_Left:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size/2;
break;
default:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size/2;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size/2;
}
ctx->fdraw->arc( ctx, x, y, size, size, 0, 360,
flow_eDrawType_LineRed, idx, 0);
}
}
void FlowConPoint::erase( void *pos, int hot, void *node)
{
int line_width = 1;
int idx = int( ctx->zoom_factor / ctx->base_zoom_factor * line_width - 1) + 2;
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
int size = (int)(0.025 * ctx->zoom_factor);
int x, y;
if ( ((FlowNode *)node)->sel_conpoint1 == number ||
((FlowNode *)node)->sel_conpoint2 == number) {
switch ( direction) {
case flow_eDirection_Up:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size/2;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size;;
break;
case flow_eDirection_Down:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size/2;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y;
break;
case flow_eDirection_Right:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size/2;
break;
case flow_eDirection_Left:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size/2;
break;
default:
x = p.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x - size/2;
y = p.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y - size/2;
}
ctx->fdraw->arc_erase( ctx, x, y, size, size, 0, 360, idx);
}
}
ostream& operator<< ( ostream& o, const FlowConPoint cp)
{
o << '(' << cp.p.x << ',' << cp.p.y << ')';
......
/*
* Proview $Id: flow_conpoint.h,v 1.4 2005-10-21 16:11:22 claes Exp $
* Proview $Id: flow_conpoint.h,v 1.5 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -46,9 +46,9 @@ class FlowConPoint : public FlowArrayElem {
void print( void *pos, void *node) {};
void save( ofstream& fp, flow_eSaveMode mode);
void open( ifstream& fp);
void draw( void *pos, int highlight, int hot, void *node) {};
void draw( void *pos, int highlight, int hot, void *node);
void nav_draw( void *pos, int highlight, void *node) {};
void erase( void *pos, int hot, void *node) {};
void erase( void *pos, int hot, void *node);
void nav_erase( void *pos, void *node) {};
void get_borders( double pos_x, double pos_y, double *x_right,
double *x_left, double *y_high, double *y_low, void *node) {};
......
This diff is collapsed.
/*
* Proview $Id: flow_ctx.h,v 1.9 2008-01-18 13:55:06 claes Exp $
* Proview $Id: flow_ctx.h,v 1.10 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -27,6 +27,8 @@
#include "flow_pdf.h"
#include "flow_array.h"
#define CONPOINT_SELECTLIST_SIZE 2
class FlowDraw;
class FlowTipText;
......@@ -117,10 +119,16 @@ class FlowCtx {
void node_movement( FlowArrayElem *node, int x, int y);
void con_create_source( FlowArrayElem *node, int cp_num, int cp_x, int cp_y);
void con_create_dest( FlowArrayElem *node, int cp_num, flow_eEvent event, int x, int y);
void conpoint_select( FlowArrayElem *node, int cp_num);
void conpoint_select_clear();
void get_selectlist( FlowArrayElem ***list, int *size)
{ *list = a_sel.a; *size = a_sel.size();};
void get_pastelist( FlowArrayElem ***list, int *size)
{ *list = a_paste.a; *size = a_paste.size();};
void get_objectlist( FlowArrayElem ***list, int *size)
{ *list = a.a; *size = a.size();};
void get_conpoint_selectlist( FlowArrayElem ***list, int **num_list, int *size)
{ *list = conpoint_select_node; *num_list = conpoint_select_num; *size = conpoint_select_idx;};
void set_gridsize( double size_x, double size_y)
{ grid_size_x = size_x; grid_size_y = size_y;};
void set_grid( int on) { grid_on = on;};
......@@ -156,6 +164,9 @@ class FlowCtx {
int con_create_conpoint_x;
int con_create_conpoint_y;
int con_create_active;
FlowArrayElem *conpoint_select_node[CONPOINT_SELECTLIST_SIZE];
int conpoint_select_num[CONPOINT_SELECTLIST_SIZE];
int conpoint_select_idx;
int auto_scrolling_active;
void *auto_scrolling_id;
void auto_scrolling_stop();
......@@ -207,6 +218,7 @@ class FlowCtx {
flow_eEvent event_create_con;
flow_eEvent event_create_node;
flow_eEvent event_move_node;
flow_eEvent event_select_conpoint;
FlowArrayElem *callback_object;
flow_eObjectType callback_object_type;
void register_callback_object( flow_eObjectType type, FlowArrayElem *object)
......@@ -272,6 +284,7 @@ class FlowCtx {
int widget_cnt;
flow_eSelectPolicy select_policy;
FlowTipText *tiptext;
flow_eDrawType inverse_color;
void set_nodraw() { nodraw++; };
void reset_nodraw() { if ( nodraw) nodraw--; };
......@@ -301,7 +314,14 @@ class FlowCtx {
void get_zoom( double *zoom) { *zoom = zoom_factor;};
int get_next_object( FlowArrayElem *object, flow_eDirection dir,
FlowArrayElem **next);
int get_next_conpoint( FlowArrayElem *object, int cp_num, flow_eDirection dir,
FlowArrayElem **next, int *next_cp_num);
int is_visible( FlowArrayElem *element, flow_eVisible type);
void move_selected_nodes( double delta_x, double delta_y, int grid);
int paste_stop();
int pending_paste() { return node_movement_paste_pending;}
int pending_paste_stop();
void set_inverse_color( flow_eDrawType color) { inverse_color = color; redraw();}
~FlowCtx();
};
......
/*
* Proview $Id: flow_node.cpp,v 1.10 2008-01-18 13:55:06 claes Exp $
* Proview $Id: flow_node.cpp,v 1.11 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -41,7 +41,7 @@ FlowNode::FlowNode( FlowCtx *flow_ctx, char *name, FlowNodeClass *node_class,
trace_inverted(0), trace_p(NULL), user_data(0),
level(0), node_open(0),
relative_annot_pos(rel_annot_pos), relative_annot_x(0),
fill_color(flow_eDrawType_Inherit)
fill_color(flow_eDrawType_Inherit), sel_conpoint1(-1), sel_conpoint2(-1)
{
double x_grid, y_grid;
strncpy( n_name, name, sizeof(n_name));
......@@ -434,7 +434,7 @@ void FlowNode::draw_inverse()
int( y_low * ctx->zoom_factor - ctx->offset_y),
int( x_r * ctx->zoom_factor - x_left * ctx->zoom_factor),
int( y_high * ctx->zoom_factor - y_low * ctx->zoom_factor),
flow_eDrawType_Line);
ctx->inverse_color);
nc->draw_inverse( &pos, 0, (void *)this);
}
}
......@@ -770,12 +770,27 @@ int FlowNode::event_handler( flow_eEvent event, int x, int y)
distance = 1e10;
conpoint = 0;
nc->a.conpoint_select( &pos, x, y, &distance,
(void **) &conpoint);
if ( conpoint)
{
(void **) &conpoint);
if ( conpoint) {
ctx->con_create_source( this, conpoint->number,
pos.z_x - ctx->offset_x + conpoint->p.z_x,
pos.z_y - ctx->offset_y + conpoint->p.z_y);
pos.z_x - ctx->offset_x + conpoint->p.z_x,
pos.z_y - ctx->offset_y + conpoint->p.z_y);
}
}
return sts;
}
else if ( event == ctx->event_select_conpoint)
{
sts = nc->event_handler( &pos, event, x, y, (void *)this);
if ( sts)
{
/* Find closest conpoint */
distance = 1e10;
conpoint = 0;
nc->a.conpoint_select( &pos, x, y, &distance,
(void **) &conpoint);
if ( conpoint) {
ctx->conpoint_select( this, conpoint->number);
}
}
return sts;
......@@ -1003,3 +1018,43 @@ void FlowNode::set_fillcolor( flow_eDrawType color)
int(x_right * ctx->nav_zoom_factor - ctx->nav_offset_x + 1),
int(y_high * ctx->nav_zoom_factor - ctx->nav_offset_y + 1));
}
void FlowNode::conpoint_select( int num)
{
if ( sel_conpoint1 == num || sel_conpoint2 == num)
return;
if ( sel_conpoint1 == -1)
sel_conpoint1 = num;
else if ( sel_conpoint2 == -1)
sel_conpoint2 = num;
nc->draw( &pos, highlight, hot, (void *)this);
}
void FlowNode::conpoint_select_clear( int num)
{
if ( sel_conpoint1 == num) {
erase();
sel_conpoint1 = -1;
nc->draw( &pos, highlight, hot, (void *)this);
}
else if ( sel_conpoint2 == num) {
erase();
sel_conpoint2 = -1;
nc->draw( &pos, highlight, hot, (void *)this);
}
}
void FlowNode::conpoint_select_clear()
{
if ( sel_conpoint1 != -1 || sel_conpoint2 != -1) {
erase();
sel_conpoint1 = -1;
sel_conpoint2 = -1;
nc->draw( &pos, highlight, hot, (void *)this);
}
}
int FlowNode::get_next_conpoint( int cp_num, flow_eDirection dir, double x0, double y0, int *next_cp_num)
{
return nc->get_next_conpoint( cp_num, dir, x0 - pos.x, y0 - pos.y, next_cp_num);
}
/*
* Proview $Id: flow_node.h,v 1.5 2007-05-11 15:07:21 claes Exp $
* Proview $Id: flow_node.h,v 1.6 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -167,6 +167,10 @@ class FlowNode : public FlowArrayElem {
int get_conpoint_trace_attr( int num, char *trace_attr, flow_eTraceType *type)
{ return nc->get_conpoint_trace_attr( num, trace_attr, type);};
void set_fillcolor( flow_eDrawType color);
void conpoint_select( int num);
void conpoint_select_clear( int num);
void conpoint_select_clear();
int get_next_conpoint( int cp_num, flow_eDirection dir, double x0, double y0, int *next_cp_num);
int level;
int node_open;
......@@ -178,6 +182,8 @@ class FlowNode : public FlowArrayElem {
void *annotv_input[10];
int rbuttonv[10];
flow_eDrawType fill_color;
int sel_conpoint1;
int sel_conpoint2;
};
#endif
/*
* Proview $Id: flow_nodeclass.cpp,v 1.7 2008-01-17 14:18:55 claes Exp $
* Proview $Id: flow_nodeclass.cpp,v 1.8 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -19,6 +19,8 @@
#include "flow_std.h"
#include <vector.h>
#include <float.h>
#include <iostream.h>
#include <fstream.h>
#include "flow_nodeclass.h"
......@@ -27,6 +29,14 @@
#include "flow_conpoint.h"
#include "flow_msg.h"
class NextConPoint {
public:
FlowConPoint *cp;
double distance;
double angle;
double rank;
};
FlowNodeClass::FlowNodeClass( FlowCtx *flow_ctx, char *name,
flow_eNodeGroup grp)
: ctx(flow_ctx), a(10,10), group(grp), no_con_obstacle(0)
......@@ -338,3 +348,99 @@ int FlowNodeClass::load( char *filename)
fp.close();
return FLOW__SUCCESS;
}
int FlowNodeClass::get_next_conpoint( int cp_num, flow_eDirection dir, double x0, double y0, int *next_cp_num)
{
double x, y, a_x, a_y;
double dir_angle;
vector<NextConPoint> a0;
switch ( dir) {
case flow_eDirection_Left:
dir_angle = M_PI;
break;
case flow_eDirection_Right:
dir_angle = 0;
break;
case flow_eDirection_Up:
dir_angle = -M_PI/2;
break;
case flow_eDirection_Down:
dir_angle = M_PI/2;
break;
default: ;
}
if ( cp_num == -1) {
x = x0;
y = y0;
}
else {
int found = 0;
for ( int i = 0; i < a.a_size; i++) {
if ( a.a[i]->type() == flow_eObjectType_ConPoint &&
((FlowConPoint *)a.a[i])->number == cp_num) {
x = ((FlowConPoint *)a.a[i])->p.x;
y = ((FlowConPoint *)a.a[i])->p.y;
found = 1;
break;
}
}
if ( !found)
return 0;
}
for ( int i = 0; i < a.a_size; i++) {
if ( a.a[i]->type() == flow_eObjectType_ConPoint &&
((FlowConPoint *)a.a[i])->number != cp_num) {
a_x = ((FlowConPoint *)a.a[i])->p.x;
a_y = ((FlowConPoint *)a.a[i])->p.y;
NextConPoint n;
n.cp = (FlowConPoint *)a[i];
n.distance = sqrt((a_x - x)*(a_x - x) + (a_y - y)*(a_y - y));
if ( fabs( a_y - y) < DBL_EPSILON) {
if ( a_x > x)
n.angle = 0;
else
n.angle = M_PI;
}
else {
n.angle = atan((a_x - x)/(a_y - y)) + M_PI / 2;
if ( (a_y - y) > 0)
n.angle -= M_PI;
}
double rank_angel = n.angle + dir_angle;
double rank_distance = n.distance;
if ( rank_angel > M_PI)
rank_angel -= 2 * M_PI;
if ( rank_angel < -M_PI)
rank_angel += 2 * M_PI;
rank_angel = fabs( rank_angel) / M_PI;
if ( rank_angel >= 0.5 - DBL_EPSILON)
continue;
n.rank = rank_angel + ( 0.3 + rank_distance);
a0.push_back( n);
}
}
if ( a0.size() == 0)
return 0;
// Find best object
double rank_min = 1E37;
FlowConPoint *rank_elem = 0;
for ( int i = 0; i < (int)a0.size(); i++) {
if ( a0[i].rank < rank_min) {
rank_min = a0[i].rank;
rank_elem = a0[i].cp;
}
}
if ( !rank_elem)
return 0;
*next_cp_num = rank_elem->number;
return 1;
}
/*
* Proview $Id: flow_nodeclass.h,v 1.6 2008-01-17 14:18:55 claes Exp $
* Proview $Id: flow_nodeclass.h,v 1.7 2008-10-03 14:19:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -69,6 +69,8 @@ class FlowNodeClass : public FlowArrayElem {
int get_conpoint_trace_attr( int num, char *trace_attr,
flow_eTraceType *type);
void set_no_con_obstacle( int no_obstacle) { no_con_obstacle = no_obstacle;}
int get_next_conpoint( int cp_num, flow_eDirection dir, double x0, double y0, int *next_cp_num);
FlowCtx *ctx;
FlowArray a;
flow_tName nc_name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment