Commit a9ec5325 authored by claes's avatar claes

Ge journal file and undo/redo added

parent 16947259
/*
* Proview $Id: rt_xtt_gtk.cpp,v 1.12 2008-02-27 06:59:27 claes Exp $
* Proview $Id: rt_xtt_gtk.cpp,v 1.13 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -236,6 +236,8 @@ void XttGtk::activate_command( GtkWidget *w, gpointer data)
return;
}
gtk_editable_delete_text( GTK_EDITABLE(((XttGtk *)xtt)->cmd_input), 0, -1);
if ( xtt->input_open)
xtt->input_open = 0;
else
......@@ -243,7 +245,6 @@ void XttGtk::activate_command( GtkWidget *w, gpointer data)
xtt->message( ' ', "");
gtk_widget_grab_focus( ((XttGtk *)xtt)->cmd_input);
gtk_editable_delete_text( GTK_EDITABLE(((XttGtk *)xtt)->cmd_input), 0, -1);
xtt->set_prompt( "xtt >");
xtt->command_open = 1;
}
......
/*
* Proview $Id: ge_gtk.cpp,v 1.15 2008-04-08 11:21:16 claes Exp $
* Proview $Id: ge_gtk.cpp,v 1.16 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -97,6 +97,12 @@ static GtkWidget *image_widget( char *filename)
}
int GeGtk::create_modal_dialog( char *title, char *text, char *button1, char *button2, char *button3,
char *image)
{
return wow->CreateModalDialog( title, text, button1, button2, button3, image);
}
void GeGtk::create_list( char *title, char *texts,
void (action_cb)( void *, char *), void *ctx)
{
......@@ -401,6 +407,11 @@ void GeGtk::activate_cut(GtkWidget *w, gpointer gectx)
((Ge *)gectx)->activate_cut();
}
void GeGtk::activate_delete(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_delete();
}
void GeGtk::activate_copy(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_copy();
......@@ -594,6 +605,18 @@ void GeGtk::activate_paste(GtkWidget *w, gpointer gectx)
((Ge *)gectx)->activate_paste();
}
void GeGtk::activate_undo(GtkWidget *w, gpointer gectx)
{
if ( ((Ge *)gectx)->graph->journal)
((Ge *)gectx)->graph->journal->undo();
}
void GeGtk::activate_redo(GtkWidget *w, gpointer gectx)
{
if ( ((Ge *)gectx)->graph->journal)
((Ge *)gectx)->graph->journal->redo();
}
void GeGtk::activate_command(GtkWidget *w, gpointer data)
{
GeGtk *gectx = (GeGtk *)data;
......@@ -1543,6 +1566,21 @@ GeGtk::GeGtk( void *x_parent_ctx,
GtkWidget *edit_paste = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
g_signal_connect(edit_paste, "activate", G_CALLBACK(activate_paste), this);
GtkWidget *edit_delete = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, accel_g);
g_signal_connect(edit_delete, "activate", G_CALLBACK(activate_delete), this);
gtk_widget_add_accelerator( edit_delete, "activate", accel_g,
'd', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *edit_undo = gtk_image_menu_item_new_from_stock(GTK_STOCK_UNDO, accel_g);
g_signal_connect(edit_undo, "activate", G_CALLBACK(activate_undo), this);
gtk_widget_add_accelerator( edit_undo, "activate", accel_g,
'z', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *edit_redo = gtk_image_menu_item_new_from_stock(GTK_STOCK_REDO, accel_g);
g_signal_connect(edit_redo, "activate", G_CALLBACK(activate_redo), this);
gtk_widget_add_accelerator( edit_redo, "activate", accel_g,
'z', GdkModifierType(GDK_CONTROL_MASK | GDK_MOD1_MASK), GTK_ACCEL_VISIBLE);
GtkWidget *edit_rotate = gtk_menu_item_new_with_mnemonic( "_Rotate...");
g_signal_connect( edit_rotate, "activate",
G_CALLBACK(activate_rotate), this);
......@@ -1573,6 +1611,9 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_cut);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_copy);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_paste);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_delete);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_undo);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_redo);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_rotate);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_polyline);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_change_text);
......@@ -1808,8 +1849,6 @@ GeGtk::GeGtk( void *x_parent_ctx,
GtkWidget *functions_show_grid = gtk_menu_item_new_with_mnemonic( "S_how Grid");
g_signal_connect( functions_show_grid, "activate",
G_CALLBACK(activate_show_grid), this);
gtk_widget_add_accelerator( functions_show_grid, "activate", accel_g,
'd', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_background_color);
......@@ -2215,6 +2254,13 @@ GeGtk::GeGtk( void *x_parent_ctx,
g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoom_reset), this);
gtk_toolbar_append_widget( tools2, tools_zoom_reset, "Zoom reset", "");
GtkWidget *tools_undo = image_button( "$pwr_exe/ge_undo.png");
gtk_toolbar_append_widget( tools2, tools_undo, "Undo", "");
g_signal_connect(tools_undo, "clicked", G_CALLBACK(activate_undo), this);
GtkWidget *tools_redo = image_button( "$pwr_exe/ge_redo.png");
gtk_toolbar_append_widget( tools2, tools_redo, "Redo", "");
g_signal_connect(tools_redo, "clicked", G_CALLBACK(activate_redo), this);
// Line width option menu
GtkWidget *tools_linewidth_1 = gtk_image_menu_item_new_with_label( "Linewidth 1");
......@@ -2491,7 +2537,6 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_toolbar_append_widget( tools2, tools_incr_shift, "Shift color", "");
g_signal_connect(tools_incr_shift, "clicked", G_CALLBACK(activate_incr_shift), this);
// Statusbar and cmd input
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
msg_label = gtk_label_new( "");
......@@ -2539,6 +2584,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
graph->set_focus_cb = &Ge::set_focus_cb;
graph->traverse_focus_cb = &Ge::traverse_focus;
graph->get_ldhses_cb = &Ge::get_ldhses_cb;
graph->create_modal_dialog_cb = &Ge::create_modal_dialog_cb;
// Vertical palette pane
GtkWidget *vpaned1 = gtk_vpaned_new();
......
/*
* Proview $Id: ge_gtk.h,v 1.8 2008-01-24 09:28:01 claes Exp $
* Proview $Id: ge_gtk.h,v 1.9 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -89,6 +89,8 @@ class GeGtk : public Ge {
virtual int get_plant_select( char *name);
virtual void create_list( char *title, char *texts,
void (action_cb)( void *, char *), void *ctx);
virtual int create_modal_dialog( char *title, char *text, char *button1, char *button2, char *button3,
char *image);
static void valchanged_cmd_input( GtkWidget *w, gpointer data);
static void change_text_cb( void *ge_ctx, void *text_object, char *text);
......@@ -111,6 +113,7 @@ class GeGtk : public Ge {
static void activate_change_name( GtkWidget *w, gpointer gectx);
static void activate_preview_start( GtkWidget *w, gpointer gectx);
static void activate_preview_stop( GtkWidget *w, gpointer gectx);
static void activate_delete( GtkWidget *w, gpointer gectx);
static void activate_cut( GtkWidget *w, gpointer gectx);
static void activate_copy( GtkWidget *w, gpointer gectx);
static void activate_rotate( GtkWidget *w, gpointer gectx);
......@@ -149,6 +152,8 @@ class GeGtk : public Ge {
static void activate_objectattributes( GtkWidget *w, gpointer gectx);
static void activate_show_grid( GtkWidget *w, gpointer gectx);
static void activate_paste( GtkWidget *w, gpointer gectx);
static void activate_undo( GtkWidget *w, gpointer gectx);
static void activate_redo( GtkWidget *w, gpointer gectx);
static void activate_command( GtkWidget *w, gpointer gectx);
static void activate_exit( GtkWidget *w, gpointer gectx);
static void activate_print( GtkWidget *w, gpointer gectx);
......
/*
* Proview $Id: ge.cpp,v 1.30 2008-04-07 14:57:13 claes Exp $
* Proview $Id: ge.cpp,v 1.31 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -549,6 +549,9 @@ void Ge::open_graph( char *name)
update();
set_title();
if ( graph->journal)
graph->journal->open( graphname);
}
void Ge::open( char *name)
......@@ -677,6 +680,12 @@ int Ge::command_cb( void *ge_ctx, char *command)
return 0;
}
int Ge::create_modal_dialog_cb( void *ge_ctx, char *title, char *text, char *button1, char *button2,
char *button3, char *image)
{
return ((Ge *)ge_ctx)->create_modal_dialog( title, text, button1, button2, button3, image);
}
//
// Callbackfunctions from menu entries
//
......@@ -702,6 +711,11 @@ void Ge::activate_preview_stop()
set_title();
}
void Ge::activate_delete()
{
graph->delete_select();
}
void Ge::activate_cut()
{
graph->cut();
......
/*
* Proview $Id: ge.h,v 1.11 2008-01-24 09:28:01 claes Exp $
* Proview $Id: ge.h,v 1.12 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -117,6 +117,8 @@ class Ge {
virtual int get_plant_select( char *name) { return 0;}
virtual void create_list( char *title, char *texts,
void (action_cb)( void *, char *), void *ctx) {}
virtual int create_modal_dialog( char *title, char *text, char *button1, char *button2, char *button3,
char *image) { return 0;}
virtual void plant_del( void *plantctx) {}
virtual int plant_get_select( void *plantctx, pwr_sAttrRef *attrref, int *is_attr) {return 0;}
......@@ -135,6 +137,7 @@ class Ge {
void activate_change_name();
void activate_preview_start();
void activate_preview_stop();
void activate_delete();
void activate_cut();
void activate_copy();
void activate_rotate();
......@@ -286,6 +289,8 @@ class Ge {
static int set_focus_cb( void *ctx, void *component);
static void message_cb( void *ctx, char severity, char *message);
static void help_cb( void *ctx, char *topic, char *helpfile);
static int create_modal_dialog_cb( void *ge_ctx, char *title, char *text, char *button1, char *button2,
char *button3, char *image);
};
#endif
/*
* Proview $Id: ge_curve.cpp,v 1.17 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge_curve.cpp,v 1.18 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -145,7 +145,6 @@ int GeCurve::growcurve_cb( GlowCtx *ctx, glow_tEvent event)
case glow_eEvent_MB1Click:
break;
case glow_eEvent_SliderMoveStart: {
printf( "Slider start\n");
if ( event->object.object_type == glow_eObjectType_NoObject)
grow_SetMoveRestrictions( (GrowCtx *)ctx, glow_eMoveRestriction_Disable, 0, 0, NULL);
else
......@@ -406,7 +405,6 @@ int GeCurve::growaxis_cb( GlowCtx *ctx, glow_tEvent event)
{
case glow_eEvent_MB1Click:
{
printf( "GrowAxis callback MB1\n");
if ( event->object.object_type != glow_eObjectType_NoObject) {
for ( int i = 0; i < curve->cd->cols; i++) {
......@@ -464,7 +462,6 @@ int GeCurve::grownames_cb( GlowCtx *ctx, glow_tEvent event)
{
glow_eDrawType color;
printf( "GrowNames callback MB1\n");
if ( event->object.object_type != glow_eObjectType_NoObject) {
for ( int i = 0; i < curve->cd->cols; i++) {
......@@ -508,7 +505,6 @@ int GeCurve::grownames_cb( GlowCtx *ctx, glow_tEvent event)
return 0;
case glow_eEvent_Resized:
{
printf( "GrowNames callback Resized\n");
#if 0
Arg args[2];
short width;
......@@ -972,16 +968,16 @@ int GeCurve::read_file( char *filename)
return 0;
}
printf( "line: %s\n", line);
for ( i = 0; i < nr; i++)
printf( "item: %s\n", item_str[i]);
//printf( "line: %s\n", line);
//for ( i = 0; i < nr; i++)
// printf( "item: %s\n", item_str[i]);
while( dcli_read_line( line, sizeof(line), fp)) {
rows++;
}
fclose( fp);
printf( "Rows: %d\n", rows);
// printf( "Rows: %d\n", rows);
cd = new GeCurveData( curve_eDataType_LogFile);
......@@ -1132,7 +1128,7 @@ void GeCurveData::get_borders()
if ( value_type[i] == pwr_eType_Boolean &&
!( data[i][j] == 1 || data[i][j] == 0)) {
value_type[i] = pwr_eType_Float64;
printf( "Not Boolean %s: %f\n", name[i], data[i][j]);
// printf( "Not Boolean %s: %f\n", name[i], data[i][j]);
}
}
}
......@@ -1554,9 +1550,9 @@ void GeCurveData::scale( int axis_type, int value_type,
*axis_width = 0.65 * format_int + 0.4;
break;
}
printf( "%f %f %f %f %3d %5s %4.1f\n",
min_value, max_value,
*min_value_axis, *max_value_axis, *trend_lines, format, *axis_width);
//printf( "%f %f %f %f %3d %5s %4.1f\n",
// min_value, max_value,
// *min_value_axis, *max_value_axis, *trend_lines, format, *axis_width);
return;
}
This diff is collapsed.
/*
* Proview $Id: ge_graph.h,v 1.32 2008-01-24 09:28:01 claes Exp $
* Proview $Id: ge_graph.h,v 1.33 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -39,6 +39,10 @@
#include "ge_graph_ccm.h"
#endif
#ifndef ge_graph_journal_h
#include "ge_graph_journal.h"
#endif
#ifndef ge_attr_h
#include "ge_attr.h"
#endif
......@@ -420,6 +424,7 @@ class Graph {
GraphGrow *grow_stack[GRAPH_GROW_MAX]; //! Grow stack. Not used.
int grow_cnt; //! Number of grow in stack. Not used.
ldh_tSesContext ldhses; //! Ldh session.
GraphJournal *journal; //! Journal file.
void (*message_cb)( void *, char, char *);
int (*get_current_subgraph_cb)( void *, char *, char *);
......@@ -447,6 +452,8 @@ class Graph {
int (*call_method_cb)(void *, char *, char *, pwr_sAttrRef,
unsigned long, unsigned long, char *);
int (*sound_cb)(void *, pwr_tAttrRef *);
int (*create_modal_dialog_cb)( void *, char *, char *, char *, char *, char *,
char *);
int linewidth; //!< Selected linewidth.
glow_eLineType linetype; //!< Selected linetype.
int textsize; //!< Selected text size.
......@@ -797,6 +804,10 @@ class Graph {
/*! \param angel Rotation angel in degrees. */
void rotate( double angel);
//! Delete the selected object.
/*! The selected objects are deleted. */
void delete_select();
//! Cut the selected object.
/*! The selected objects are removed and put in the paste buffer. */
void cut();
......@@ -1261,6 +1272,12 @@ class Graph {
*/
int export_plcfo( char *filename);
//! Store in journal file.
int journal_store( journal_eAction a, grow_tObject o) {
if (journal) return journal->store( a, o);
else return 1;
}
//
// Command module
......
This diff is collapsed.
/*
* Proview $Id: ge_graph_journal.h,v 1.1 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef ge_journal_h
#define ge_journal_h
#include <fstream.h>
#include <vector.h>
using namespace std;
class Graph;
class JournalPos {
public:
JournalPos() {}
streampos undo_pos;
streampos redo_pos;
streampos end_pos;
};
/* ge_journal.h -- Journal function */
typedef enum {
journal_eAction_DeleteObject,
journal_eAction_DeleteSelect,
journal_eAction_MoveObject,
journal_eAction_MoveSelect,
journal_eAction_CreateObject,
journal_eAction_AntePropertiesSelect,
journal_eAction_PostPropertiesSelect,
journal_eAction_AntePropertiesObject,
journal_eAction_PostPropertiesObject,
journal_eAction_AnteGroupSelect,
journal_eAction_PostGroupSelect,
journal_eAction_UngroupSelect,
journal_eAction_PopSelect,
journal_eAction_PushSelect,
journal_eAction_AntePaste,
journal_eAction_PostPaste,
journal_eAction_AnteRename,
journal_eAction_PostRename
} journal_eAction;
typedef enum {
journal_eStatus_Empty,
journal_eStatus_Stored,
journal_eStatus_Undo,
journal_eStatus_Redo,
journal_eStatus_AnteProperties,
journal_eStatus_AntePaste,
journal_eStatus_AnteGroup
} journal_eStatus;
class GraphJournal {
public:
GraphJournal( Graph *g, int *sts);
~GraphJournal();
int store( journal_eAction action, grow_tObject o);
int undo();
int redo();
void check_object_number( grow_tObject o);
int open( char *name);
int clear( char *name = 0);
int restore( char *fname);
int store_undo_delete_select();
int store_redo_delete_select();
int undo_delete_select();
int redo_delete_select();
int store_undo_delete_object( grow_tObject o);
int store_redo_delete_object( grow_tObject o);
int undo_delete_object();
int redo_delete_object();
int store_undo_create_object( grow_tObject o);
int store_redo_create_object( grow_tObject o);
int undo_create_object();
int redo_create_object();
int store_properties_select();
int undo_properties_select();
int store_properties_object( grow_tObject o);
int undo_properties_object();
int store_undo_group_select( grow_tObject o);
int store_redo_group_select();
int undo_group_select();
int redo_group_select();
int store_undo_ungroup_select();
int store_redo_ungroup_select();
int undo_ungroup_select();
int redo_ungroup_select();
int store_undo_paste();
int store_redo_paste();
int undo_paste();
int redo_paste();
int store_undo_pop_select();
int store_redo_pop_select();
int undo_pop_select();
int redo_pop_select();
int store_undo_push_select();
int store_redo_push_select();
int undo_push_select();
int redo_push_select();
int store_undo_rename( grow_tObject o);
int store_redo_rename( grow_tObject o);
int undo_rename();
int redo_rename();
Graph *graph;
fstream fp;
int empty;
journal_eStatus status;
vector<JournalPos> poslist;
vector<grow_tObject> pastelist;
int current_idx;
char graphname[80];
pwr_tFileName filename;
char rename_name[80];
};
#endif
/*
* Proview $Id: glow.h,v 1.25 2007-09-19 15:07:11 claes Exp $
* Proview $Id: glow.h,v 1.26 2008-05-13 13:59:02 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -881,6 +881,7 @@ typedef enum {
glow_eEvent_CursorMotion, //!< Cursor motion event
glow_eEvent_Init, //!< Initialize event
glow_eEvent_PasteSequenceStart, //!< Start of paste sequence event
glow_eEvent_PasteSequenceEnd, //!< End of paste sequence event
glow_eEvent_VisibilityUnobscured, //!< Visibility unobscured event
glow_eEvent_VisibilityObscured, //!< Visibility obscured event
glow_eEvent_SelectClear, //!< Select list is cleared event
......@@ -929,6 +930,8 @@ typedef enum {
glow_eEvent_MenuDelete, //!< Delete pulldown menu.
glow_eEvent_ScrollUp, //!< Scroll up.
glow_eEvent_ScrollDown, //!< Scroll down.
glow_eEvent_AnteUndo, //!< Before undo.
glow_eEvent_PostUndo, //!< Store undo.
glow_eEvent__
} glow_eEvent;
......
/*
* Proview $Id: glow_array.cpp,v 1.12 2008-01-17 14:17:05 claes Exp $
* Proview $Id: glow_array.cpp,v 1.13 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -421,6 +421,14 @@ void GlowArray::copy_from( const GlowArray& array)
}
}
void GlowArray::delete_all()
{
for ( int i = 0; i < a_size; i++) {
delete a[i];
}
a_size = 0;
}
GlowArray::~GlowArray()
{
int i;
......@@ -560,6 +568,83 @@ int GlowArray::brow_insert( GlowArrayElem *element, GlowArrayElem *destination,
return 1;
}
int GlowArray::move( GlowArrayElem *element, GlowArrayElem *destination,
glow_eDest code)
{
int elem_idx, dest_idx, i, found;
found = 0;
for ( elem_idx = 0; elem_idx < a_size; elem_idx++) {
if ( a[elem_idx] == element) {
found = 1;
break;
}
}
if ( !found)
return 0;
if ( !destination ) {
// If no destinaion, move to first or last
switch( code) {
case glow_eDest_After:
dest_idx = a_size - 1;
if ( elem_idx == a_size - 1)
return 1;
break;
default:
dest_idx = 0;
if ( elem_idx == 0)
return 1;
}
}
else {
found = 0;
for ( dest_idx = 0; dest_idx < a_size; dest_idx++) {
if ( a[dest_idx] == destination) {
found = 1;
break;
}
}
if ( !found)
return 0;
}
switch( code) {
case glow_eDest_After:
if ( elem_idx == dest_idx + 1)
return 1;
if ( elem_idx < dest_idx + 1) {
for ( i = elem_idx + 1; i <= dest_idx; i++)
a[i-1] = a[i];
a[dest_idx] = element;
}
else {
for ( i = elem_idx; i > dest_idx; i--)
a[i] = a[i-1];
a[dest_idx+1] = element;
}
break;
case glow_eDest_Before:
if ( elem_idx == dest_idx - 1)
return 1;
if ( elem_idx < dest_idx - 1) {
for ( i = elem_idx + 1; i < dest_idx; i++)
a[i-1] = a[i];
a[dest_idx-1] = element;
}
else {
for ( i = elem_idx; i >= dest_idx; i--)
a[i] = a[i-1];
a[dest_idx] = element;
}
break;
default:
;
}
return 1;
}
void GlowArray::remove( GlowArrayElem *element)
{
int i;
......
/*
* Proview $Id: glow_array.h,v 1.5 2008-01-17 14:17:05 claes Exp $
* Proview $Id: glow_array.h,v 1.6 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -119,6 +119,7 @@ class GlowArray {
//! Clear the array.
void clear() { a_size = 0;}
void delete_all();
void zoom();
void nav_zoom();
......@@ -165,7 +166,9 @@ class GlowArray {
void set_inverse( int on);
void configure();
int brow_insert( GlowArrayElem *element, GlowArrayElem *destination,
glow_eDest code);
glow_eDest code);
int move( GlowArrayElem *element, GlowArrayElem *destination,
glow_eDest code);
void brow_remove( void *ctx, GlowArrayElem *element);
void brow_close( void *ctx, GlowArrayElem *element);
int brow_get_parent( GlowArrayElem *element, GlowArrayElem **parent);
......
/*
* Proview $Id: glow_ctx.cpp,v 1.19 2008-01-24 09:29:31 claes Exp $
* Proview $Id: glow_ctx.cpp,v 1.20 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1965,10 +1965,10 @@ void GlowCtx::change_scrollbar()
return;
data.scroll_data = scroll_data;
data.total_width = int( (x_right - x_left) / scroll_size);
data.total_height = int( (y_high - y_low) / scroll_size);
data.window_width = int( mw.window_width / scroll_size / mw.zoom_factor_x);
data.window_height = int( mw.window_height / scroll_size / mw.zoom_factor_y + 1);
data.total_width = int( (x_right - x_left) / scroll_size) + 1;
data.total_height = int( (y_high - y_low) / scroll_size) + 1;
data.window_width = int( mw.window_width / scroll_size / mw.zoom_factor_x) + 1;
data.window_height = int( mw.window_height / scroll_size / mw.zoom_factor_y) + 1;
data.offset_x = int( mw.offset_x / scroll_size / mw.zoom_factor_x - x_left /
scroll_size);
data.offset_y = int( mw.offset_y /scroll_size / mw.zoom_factor_y - y_low /
......
/*
* Proview $Id: glow_ctx.h,v 1.12 2007-06-29 09:29:19 claes Exp $
* Proview $Id: glow_ctx.h,v 1.13 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -348,6 +348,14 @@ class GlowCtx {
void get_selectlist( GlowArrayElem ***list, int *size)
{ *list = a_sel.a; *size = a_sel.size();};
//! Get the paste list.
/*!
\param list Returned pointer to the paste list.
\param size Number of objects in the paste list.
*/
void get_pastelist( GlowArrayElem ***list, int *size)
{ *list = a_paste.a; *size = a_paste.size();};
//! Get the object list.
/*!
\param list Returned pointer to the object list.
......
/*
* Proview $Id: glow_growapi.cpp,v 1.36 2008-01-17 14:17:05 claes Exp $
* Proview $Id: glow_growapi.cpp,v 1.37 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -498,6 +498,11 @@ void grow_GetSelectList( grow_tCtx ctx, grow_tObject **list, int *cnt)
ctx->get_selectlist( (GlowArrayElem ***)list, cnt);
}
void grow_GetPasteList( grow_tCtx ctx, grow_tObject **list, int *cnt)
{
ctx->get_pastelist( (GlowArrayElem ***)list, cnt);
}
void grow_GetObjectList( grow_tCtx ctx, grow_tObject **list, int *cnt)
{
ctx->get_objectlist( (GlowArrayElem ***)list, cnt);
......@@ -1144,6 +1149,16 @@ int grow_GetNextObjectNameNumber( grow_tCtx ctx)
return ctx->get_next_objectname_num();
}
int grow_IncrNextObjectNameNumber( grow_tCtx ctx)
{
return ctx->incr_next_objectname_num();
}
void grow_SetNextObjectNameNumber( grow_tCtx ctx, int num)
{
ctx->set_next_objectname_num( num);
}
int grow_GetObjectAttrInfo( grow_tObject object, char *transtab,
grow_sAttrInfo **info, int *attr_cnt)
{
......@@ -3577,6 +3592,11 @@ void grow_PopSelectedObjects( grow_tCtx ctx)
ctx->pop_select();
}
int grow_OrderObject( grow_tCtx ctx, grow_tObject object, grow_tObject destination, glow_eDest code)
{
return ctx->order_object( (GlowArrayElem *)object, (GlowArrayElem *)destination, code);
}
void grow_SetDefaultLayout( grow_tCtx ctx)
{
ctx->set_default_layout();
......@@ -4153,6 +4173,11 @@ int grow_UngroupSelect( grow_tCtx ctx)
return ctx->ungroup_select();
}
void grow_UngroupGroup( grow_tCtx ctx, grow_tObject group)
{
ctx->ungroup_group( (GrowGroup *)group);
}
void grow_CurveConfigure( grow_tObject object, glow_sCurveData *data)
{
((GrowCurve *)object)->configure_curves( data);
......@@ -4472,10 +4497,20 @@ void grow_SetSelectScale( grow_tCtx ctx, double scale_x, double scale_y,
ctx->set_select_scale( scale_x, scale_y, type);
}
int grow_GetNextObject( grow_tCtx ctx, grow_tObject object, glow_eDirection dir,
grow_tObject *next)
int grow_GetNextObjectPosition( grow_tCtx ctx, grow_tObject object, glow_eDirection dir,
grow_tObject *next)
{
return ctx->get_next_object( (GlowArrayElem *)object, dir, (GlowArrayElem **)next);
return ctx->get_next_object_position( (GlowArrayElem *)object, dir, (GlowArrayElem **)next);
}
int grow_GetPreviousObject( grow_tCtx ctx, grow_tObject object, grow_tObject *prev)
{
return ctx->get_next_object( (GlowArrayElem *)object, (GlowArrayElem **)prev);
}
int grow_GetNextObject( grow_tCtx ctx, grow_tObject object, grow_tObject *next)
{
return ctx->get_next_object( (GlowArrayElem *)object, (GlowArrayElem **)next);
}
int grow_IsVisible( grow_tCtx ctx, grow_tObject object, glow_eVisible type)
......@@ -4488,6 +4523,21 @@ int grow_ExportFlow( grow_tCtx ctx, char *filename)
return ctx->export_flow( filename);
}
void grow_ObjectSave( grow_tObject object, ofstream& fp, glow_eSaveMode mode)
{
((GlowArrayElem *)object)->save( fp, mode);
}
void grow_ObjectOpen( grow_tObject object, ifstream& fp)
{
((GlowArrayElem *)object)->open( fp);
}
void grow_ObjectRead( grow_tCtx ctx, ifstream& fp, grow_tObject *object)
{
ctx->read_object( fp, (GlowArrayElem **)object);
}
/*@}*/
......
/*
* Proview $Id: glow_growapi.h,v 1.30 2008-01-17 14:17:05 claes Exp $
* Proview $Id: glow_growapi.h,v 1.31 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -530,6 +530,14 @@ extern "C" {
*/
void grow_GetSelectList( grow_tCtx ctx, grow_tObject **list, int *cnt);
//! Get list of objects in paste buffer.
/*!
\param ctx Grow context.
\param list List of objects in paste buffer.
\param cnt Number of objects in paste buffer.
*/
void grow_GetPasteList( grow_tCtx ctx, grow_tObject **list, int *cnt);
//! Get list of all objects in the grow context.
/*!
\param ctx Grow context.
......@@ -1282,10 +1290,28 @@ extern "C" {
\param ctx Grow context.
\return Next objectname number.
Returns the number for next objectname and increments the counter.
Returns the number for next objectname.
*/
int grow_GetNextObjectNameNumber( grow_tCtx ctx);
//! Get and increment next objectname number.
/*!
\param ctx Grow context.
\return Next objectname number.
Returns the number for next objectname and increments the counter.
*/
int grow_IncrNextObjectNameNumber( grow_tCtx ctx);
//! Set next objectname number.
/*!
\param ctx Grow context.
\return Next objectname number.
Sets the number for next objectname.
*/
void grow_SetNextObjectNameNumber( grow_tCtx ctx, int num);
//! Get attributes for an object.
/*!
\param object Object to get attributes for.
......@@ -1756,6 +1782,15 @@ extern "C" {
/*! \param ctx Grow context. */
void grow_PopSelectedObjects( grow_tCtx ctx);
//! Pop the selected objects.
/*!
\param ctx Grow context.
\param object Object to order.
\param destination Destionation object.
\param code Destination code, glow_eDest_After or glow_eDest_Before.
*/
int grow_OrderObject( grow_tCtx ctx, grow_tObject object, grow_tObject destination, glow_eDest code);
//! Set default layout. Adjust zoom factor to the current size of the window.
/*! \param ctx Grow context. */
void grow_SetDefaultLayout( grow_tCtx ctx);
......@@ -2553,6 +2588,9 @@ extern "C" {
*/
int grow_UngroupSelect( grow_tCtx ctx);
//! Ungroup a group.
void grow_UngroupGroup( grow_tCtx ctx, grow_tObject group);
//! Configure the curves of a curve object.
/*!
\param object Curve object.
......@@ -2903,10 +2941,15 @@ extern "C" {
int grow_GetNodeClassAnnotBackground( grow_tNodeClass nodeclass, glow_eDrawType *background);
void grow_SetSelectScale( grow_tCtx ctx, double scale_x, double scale_y,
glow_eScaleType type);
int grow_GetNextObject( grow_tCtx ctx, grow_tObject object, glow_eDirection dir,
grow_tObject *next);
int grow_GetNextObjectPosition( grow_tCtx ctx, grow_tObject object, glow_eDirection dir,
grow_tObject *next);
int grow_GetPreviousObject( grow_tCtx ctx, grow_tObject object, grow_tObject *prev);
int grow_GetNextObject( grow_tCtx ctx, grow_tObject object, grow_tObject *next);
int grow_IsVisible( grow_tCtx ctx, grow_tObject object, glow_eVisible type);
int grow_ExportFlow( grow_tCtx ctx, char *filename);
void grow_ObjectSave( grow_tObject object, ofstream& fp, glow_eSaveMode mode);
void grow_ObjectOpen( grow_tObject object, ifstream& fp);
void grow_ObjectRead( grow_tCtx ctx, ifstream& fp, grow_tObject *object);
/*@}*/
#if defined __cplusplus
......
/*
* Proview $Id: glow_growctx.cpp,v 1.30 2008-01-17 14:17:05 claes Exp $
* Proview $Id: glow_growctx.cpp,v 1.31 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -52,6 +52,13 @@
#include "glow_growmenu.h"
#include "glow_growfolder.h"
#include "glow_growtable.h"
#include "glow_growconglue.h"
#include "glow_growline.h"
#include "glow_growarc.h"
#include "glow_growconpoint.h"
#include "glow_growbar.h"
#include "glow_growtrend.h"
#include "glow_growxycurve.h"
#include "glow_exportflow.h"
#include "glow_draw.h"
......@@ -326,6 +333,20 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
if ( event == event_region_select)
// Move and region select is defined as the same event
node_move_event = 1;
// Send undo callback
if ( event_callback[glow_eEvent_AnteUndo] ) {
static glow_sEvent e;
memset( &e, 0, sizeof(e));
e.event = glow_eEvent_AnteUndo;
e.any.type = glow_eEventType_Object;
if ( a_move.size() == 1) {
e.object.object = a_move[0];
e.object.object_type = a_move[0]->type();
}
event_callback[glow_eEvent_AnteUndo]( this, &e);
}
}
if ( event_callback[glow_eEvent_SliderMoveStart] &&
a_move.size() == 1 &&
......@@ -557,8 +578,14 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
gdraw->set_cursor( &mw, glow_eDrawCursor_Normal);
/* Send callback for all move objects */
if ( event_callback[glow_eEvent_ObjectMoved] )
{
if ( event_callback[glow_eEvent_PasteSequenceEnd]) {
static glow_sEvent e;
memset( &e, 0, sizeof(0));
e.event = glow_eEvent_PasteSequenceEnd;
event_callback[glow_eEvent_PasteSequenceEnd]( this, &e);
}
if ( event_callback[glow_eEvent_ObjectMoved]) {
static glow_sEvent e;
e.event = glow_eEvent_ObjectMoved;
......@@ -1276,9 +1303,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
nav_zoom();
gdraw->set_cursor( &mw, glow_eDrawCursor_CrossHair);
/* Send callback for all move objects */
if ( event_callback[glow_eEvent_ObjectMoved] )
{
// Send callback for all move objects
if ( event_callback[glow_eEvent_ObjectMoved] ) {
static glow_sEvent e;
e.event = glow_eEvent_ObjectMoved;
......@@ -1287,13 +1313,25 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
e.any.y_pixel = y;
e.any.x = 1.0 * (x + mw.offset_x) / mw.zoom_factor_x;
e.any.y = 1.0 * (y + mw.offset_y) / mw.zoom_factor_y;
for ( i = 0; i < a_move.size(); i++)
{
for ( i = 0; i < a_move.size(); i++) {
e.object.object = a_move[i];
e.object.object_type = a_move[i]->type();
event_callback[event_move_node]( this, &e);
}
}
// Send undo callback
if ( event_callback[glow_eEvent_PostUndo] ) {
static glow_sEvent e;
memset( &e, 0, sizeof(e));
e.event = glow_eEvent_PostUndo;
e.any.type = glow_eEventType_Object;
if ( a_move.size() == 1) {
e.object.object = a_move[0];
e.object.object_type = a_move[0]->type();
}
event_callback[glow_eEvent_PostUndo]( this, &e);
}
break;
case glow_eMoveRestriction_VerticalSlider:
cursor_y = double(y + mw.offset_y) / mw.zoom_factor_y;
......@@ -3776,6 +3814,16 @@ int GrowCtx::ungroup_select()
return 1;
}
void GrowCtx::ungroup_group( GrowGroup *group)
{
group->set_rootnode( 0);
group->ungroup();
a.remove( group);
a_sel.remove( group);
a_paste.remove( group);
delete group;
}
void GrowCtx::get_nodegrouplist( GlowArrayElem ***list, int *size)
{
GlowArray *a_ng = new GlowArray(20, 20);
......@@ -3905,8 +3953,8 @@ void GrowCtx::delete_menu_child( GlowArrayElem *parent)
}
}
int GrowCtx::get_next_object( GlowArrayElem *object, glow_eDirection dir,
GlowArrayElem **next)
int GrowCtx::get_next_object_position( GlowArrayElem *object, glow_eDirection dir,
GlowArrayElem **next)
{
if ( object &&
!(object->type() == glow_eObjectType_GrowNode ||
......@@ -4154,3 +4202,150 @@ int GrowCtx::is_visible( GlowArrayElem *element, glow_eVisible type)
}
return 0;
}
void GrowCtx::read_object( ifstream& fp, GlowArrayElem **o)
{
int type;
GlowArrayElem *n;
fp >> type;
switch( type) {
case glow_eSave_Array: break;
case glow_eSave_Rect: {
n = new GlowRect( this);
break;
}
case glow_eSave_Line: {
n = new GlowLine( this);
break;
}
case glow_eSave_PolyLine: {
n = new GlowPolyLine( this, (glow_sPoint *) NULL, 0);
break;
}
case glow_eSave_Arc: {
n = new GlowArc( this);
break;
}
case glow_eSave_Text: {
n = new GlowText( this, "");
break;
}
case glow_eSave_ConPoint: {
n = new GlowConPoint( this);
break;
}
case glow_eSave_Annot: {
n = new GlowAnnot( this);
break;
}
case glow_eSave_Arrow: {
n = new GlowArrow( this,0,0,0,0,0,0,glow_eDrawType_Line);
break;
}
case glow_eSave_Node: {
n = new GlowNode( this, "", 0, 0, 0);
break;
}
case glow_eSave_Con: {
n = new GlowCon( this, "", (GlowConClass *)0,
(GlowNode *)0, (GlowNode *)0, 0, 0);
break;
}
case glow_eSave_Point: {
n = new GlowPoint( this);
break;
}
case glow_eSave_GrowRect: {
n = new GrowRect( this, "");
break;
}
case glow_eSave_GrowRectRounded: {
n = new GrowRectRounded( this, "");
break;
}
case glow_eSave_GrowImage: {
n = new GrowImage( this, "");
break;
}
case glow_eSave_GrowAxis: {
n = new GrowAxis( this, "");
break;
}
case glow_eSave_GrowConGlue: {
n = new GrowConGlue( this, "");
break;
}
case glow_eSave_GrowLine: {
n = new GrowLine( this, "");
break;
}
case glow_eSave_GrowPolyLine: {
n = new GrowPolyLine( this, "", (glow_sPoint*) NULL, 0);
break;
}
case glow_eSave_GrowArc: {
n = new GrowArc( this, "");
break;
}
case glow_eSave_GrowConPoint: {
n = new GrowConPoint( this, "");
break;
}
case glow_eSave_GrowAnnot: {
n = new GrowAnnot( this);
break;
}
case glow_eSave_GrowSubAnnot: {
n = new GrowSubAnnot( this, "");
break;
}
case glow_eSave_GrowText: {
n = new GrowText( this, "", "");
break;
}
case glow_eSave_GrowBar: {
n = new GrowBar( this, "");
break;
}
case glow_eSave_GrowTrend: {
n = new GrowTrend( this, "");
break;
}
case glow_eSave_GrowWindow: {
n = new GrowWindow( this, "");
break;
}
case glow_eSave_GrowTable: {
n = new GrowTable( this, "");
break;
}
case glow_eSave_GrowFolder: {
n = new GrowFolder( this, "");
break;
}
case glow_eSave_GrowNode: {
n = new GrowNode( this, "", 0, 0, 0);
break;
}
case glow_eSave_GrowGroup: {
n = new GrowGroup( this, "");
break;
}
case glow_eSave_GrowSlider: {
n = new GrowSlider( this, "", 0, 0, 0);
break;
}
case glow_eSave_GrowXYCurve: {
n = new GrowXYCurve( this, "");
break;
}
case glow_eSave_End:
break;
default:
break;
}
n->open( fp);
a.insert( n);
*o = n;
}
/*
* Proview $Id: glow_growctx.h,v 1.15 2008-01-17 14:17:05 claes Exp $
* Proview $Id: glow_growctx.h,v 1.16 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -49,6 +49,8 @@ typedef enum {
grow_eMode_RectRounded //!< Create rounded rectangle mode
} grow_eMode;
class GrowGroup;
//! Extended class for the drawing window.
/*! GlowCtx adds functions to GlowCtx for creation of Grow objects, background color and images,
an extended event handling, and more advanced drawing routines.
......@@ -235,15 +237,31 @@ class GrowCtx : public GlowCtx {
Returns the number for next connectionpoint and increments the counter.
*/
int get_next_conpoint_num() { return conpoint_num_cnt++;};
int get_next_conpoint_num() { return conpoint_num_cnt++;}
//! Get next objectname number.
/*!
\return Next objectname number.
Returns the number for next objectname.
*/
int get_next_objectname_num() { return objectname_cnt;}
//! Get and increment next objectname number.
/*!
\return Next objectname number.
Returns the number for next objectname and increments the counter.
*/
int get_next_objectname_num() { return objectname_cnt++;};
int incr_next_objectname_num() { return objectname_cnt++;}
//! Set next objectname number.
/*!
\return Next objectname number.
Set the number for next objectname.
*/
void set_next_objectname_num( int num) { objectname_cnt = num;}
//! Clear the window.
/*!
......@@ -708,6 +726,9 @@ class GrowCtx : public GlowCtx {
/*! \return Always returns 1. */
int ungroup_select();
//! Ungroup a groups.
void ungroup_group( GrowGroup *group);
//! Get the group the specified object is a member of.
/*!
\param object Object to get group for.
......@@ -782,13 +803,25 @@ class GrowCtx : public GlowCtx {
/*! \param o Owner string. */
void set_owner( char *o) { strcpy( owner, o);}
//! Get next object regarding position. */
int get_next_object_position( GlowArrayElem *object, glow_eDirection dir,
GlowArrayElem **next);
//! Get previous object. */
int get_previous_object( GlowArrayElem *object, GlowArrayElem **prev) { return a.get_previous( object, prev);}
//! Get next object. */
int get_next_object( GlowArrayElem *object, glow_eDirection dir,
GlowArrayElem **next);
int get_next_object( GlowArrayElem *object, GlowArrayElem **next) { return a.get_next( object, next);}
//! Check if object is visible. */
int is_visible( GlowArrayElem *element, glow_eVisible type);
//! Read object from file. */
void read_object( ifstream& fp, GlowArrayElem **o);
//! Order object. */
int order_object( GlowArrayElem *o, GlowArrayElem *dest, glow_eDest code) { return a.move( o, dest, code);}
char name[40]; //!< Name of the context.
grow_eMode edit_mode; //!< Current edit mode.
int conpoint_num_cnt; //!< Counter to get next number for when creating conpoints in a subgraph.
......
/*
* Proview $Id: glow_polyline.cpp,v 1.3 2007-01-04 07:57:39 claes Exp $
* Proview $Id: glow_polyline.cpp,v 1.4 2008-05-13 13:59:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -97,6 +97,9 @@ void GlowPolyLine::open( ifstream& fp)
char dummy[40];
int tmp;
if ( a_points.size())
a_points.delete_all();
for (;;)
{
fp >> type;
......
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