ALBA
albaOpManager.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaOpManager
5 Authors: Silvano Imboden
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaOpManager_H__
18#define __albaOpManager_H__
19
20//----------------------------------------------------------------------------
21// includes :
22//----------------------------------------------------------------------------
23#include <wx/accel.h>
24#include <wx/menu.h>
25#include "albaEvent.h"
26#include "albaObserver.h"
27#include "albaOpContextStack.h"
28#include "albaServiceClient.h"
29#include "albaAbsLogicManager.h"
30
31//----------------------------------------------------------------------------
32// forward references :
33//----------------------------------------------------------------------------
34class albaVME;
35class albaVME;
36class albaOp;
37class albaOpSelect;
38class albaOpCut;
39class albaOpCopy;
40class albaOpPaste;
41class albaOpRename;
42class albaOpReparentTo;
43class albaOpCreateGroup;
44class albaOpShowHistory;
45class vtkMatrix4x4;
47class albaGUISettings;
49class albaUser;
50
51#ifdef ALBA_EXPORTS
52#include "albaDllMacros.h"
53EXPORT_STL_VECTOR(ALBA_EXPORT,albaOp*);
54#endif
56
57//----------------------------------------------------------------------------
58// albaOpManager :
59//----------------------------------------------------------------------------
61class ALBA_EXPORT albaOpManager: public albaObserver, public albaServiceClient
62{
63public:
65 virtual ~albaOpManager();
66 virtual void SetListener(albaObserver *Listener) {m_Listener = Listener;};
67 virtual void OnEvent(albaEventBase *alba_event);
68
70 ALBA_ID_DEC(OPERATION_INTERFACE_EVENT)
71 ALBA_ID_DEC(RUN_OPERATION_EVENT)
72
73
74 virtual void OpAdd(albaOp *op, wxString menuPath = "", bool can_undo = true, albaGUISettings *setting = NULL);
75
77 virtual void FillMenu(wxMenu* import, wxMenu* mexport, wxMenu* operations);
78
80 void FillSettingDialog(albaGUISettingsDialog *settingDialog);
81
83 virtual void VmeSelected(albaVME* v);
84
86 virtual void VmeModified(albaVME* v);
87
89 virtual void VmeRemove(albaVME* v);
90
92 virtual albaVME* GetSelectedVme();
93
95 virtual void OpRun(int op_id);
96
98 virtual void OpRun(albaOp *op, void *op_param = NULL);
99
101 virtual void OpRun(albaString &op_type, void *op_param = NULL);
102
103 void RunOpAddGroup();
104
105 void RunOpCut();
106 void RunOpCopy();
107 void RunOpPaste();
108 void RunOpDelete();
109 void RunOpRename();
110 void RunOpReparentTo();
111 void RunOpShowHistory();
112
114 virtual void OpExec (albaOp *op);
115
117 virtual void OpSelect(albaVME* v);
118
120 virtual void WarningIfCantUndo (bool warn) {m_Warn = warn;};
121
123 virtual void SetToolbar(wxToolBar *tb) {m_ToolBar = tb;};
124
126 virtual void SetMenubar(wxMenuBar *mb) {m_MenuBar = mb;};
127
129 virtual bool Running() {return m_Context.Caller() != NULL;};
130
132 virtual void ClearUndoStack();
133
135 virtual bool ForceStopWithOk();
136
138 virtual bool ForceStopWithCancel();
139
141 virtual bool StopCurrentOperation();
142
143 void EnableContextualMenu(albaGUITreeContextualMenu *contextualMenu, albaVME *node, bool CanEnable = true);
144
147
150
154
157
159 void SetMafUser(albaUser *user);
160
162 albaUser* GetMafUser(){return m_User;};
163
165 virtual void EnableOp(bool CanEnable = true);
166
167
169 albaString GetBuildNum() const { return m_BuildNum; }
170
172 void SetBuildNum(albaString val) { m_BuildNum = val; }
173
174protected:
176 virtual void OpDo(albaOp *op);
177
179 virtual void OpRunOk(albaOp *op);
180
182 virtual void OpRunCancel(albaOp *op);
183
185 virtual void OpUndo();
186
188 virtual void OpRedo();
189
191 virtual bool WarnUser(albaOp *op);
192
194 virtual void Notify(int msg, long arg=0L);
195
197 virtual void EnableToolbar(bool CanEnable = true);
198
200 void FillTraceabilityAttribute(albaOp *op, albaVME *in_node, albaVME *out_node);
201
203
205 bool m_Warn;
208 wxMenu *m_Menu[3];
211
213
214 std::vector<albaOp *> m_OpList;
216 wxAcceleratorEntry m_OpAccelEntries[MAXOP];
218
220
226 albaOpReparentTo *m_OpReparent;
227 albaOpCreateGroup *m_OpAddGroup;
228 albaOpShowHistory *m_OpShowHistory;
229 wxMenuBar *m_MenuBar;
230 wxToolBar *m_ToolBar;
232
234
236 friend class albaOpManagerTest;
237};
238#endif
const int MAXOP
Definition: albaDecl.h:71
#define ALBA_ID_DEC(idname)
This macros is used to define a new Id and should be placed in a .cpp file.
Definition: albaDefines.h:214
#define EXPORT_STL_VECTOR(declspec_, T_)
Definition: albaDllMacros.h:84
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
class name: albaGUISettingsDialog.
class name: albaGUISettings base class for more complex specified classes regarding the setting of ap...
Used to create and manage contextual menu' for tree widget used in side bar.
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaOpContextStack represents the stack used for implementing Undo and Redo mechanism
class name: albaOpCopy Operation which perform copy of a node.
Definition: albaOpSelect.h:140
class name: albaOpCut Operation which perform cut on a node input.
Definition: albaOpSelect.h:111
albaOpShowHistory * m_OpShowHistory
virtual void SetToolbar(wxToolBar *tb)
Set a reference to the main toolbar.
albaOpCreateGroup * m_OpAddGroup
Pointer to the (always available) operation for Adding Group VMEs.
wxToolBar * m_ToolBar
Pointer to the application's Toolbal.
std::vector< albaOp * > m_OpList
List of pointer of plugged operations.
virtual void EnableOp(bool CanEnable=true)
Enable/Disable the men items operation.
virtual void Notify(int msg, long arg=0L)
Sent a string message to the listener.
albaOp * GetRunningOperation()
Return the current running operation.
virtual bool Running()
return true if there is a running operation.
albaDeviceButtonsPadMouse * m_Mouse
Pointer to the mouse devices.
virtual void OpDo(albaOp *op)
Execute the current operation.
void SetBuildNum(albaString val)
Get Build Num.
virtual bool ForceStopWithOk()
Try to Stop the Current operation with OK condition.
void SetMouse(albaDeviceButtonsPadMouse *mouse)
Initialize the action for the mouse device.
albaUser * m_User
User credentials.
virtual bool StopCurrentOperation()
Stop the current operation in any case - to be used as last resort.
virtual void OpRedo()
Execute the 'Do' method of the operation.
albaOpReparentTo * m_OpReparent
Pointer to the (always available) operation for reparenting VMEs.
albaOpPaste * m_OpPaste
Pointer to the (always available) operation for pasting VMEs.
albaOp * GetOperationById(int id)
Return an instance of operation from id.
virtual void OnEvent(albaEventBase *alba_event)
process the events sent by subjects
albaOpSelect * m_OpSelect
Pointer to the (always available) operation for selecting VMEs.
albaOp * m_RunningOp
Pointer to the current running operation.
bool m_Warn
Flag to warn the user when an operation that can not undo is starting.
albaObserver * m_Listener
virtual bool WarnUser(albaOp *op)
Warn the user if the operation is undoable.
virtual void SetListener(albaObserver *Listener)
Definition: albaOpManager.h:66
virtual void OpRunOk(albaOp *op)
This method is called if the operation must be executed.
virtual void OpRunCancel(albaOp *op)
The operation is not executed and is deleted.
albaVME * m_NaturalNode
Pointer to the NATURAL node on which is running a non-input preserving operation.
albaOpCut * m_OpCut
Pointer to the (always available) operation for cutting VMEs.
albaOpContextStack m_Context
void * m_OpParameters
Pointer to the operation's parameter list.
virtual void OpUndo()
Execute the 'UnDo' method of the operation.
albaVME * m_Selected
Pointer to the current selected node.
wxMenuBar * m_MenuBar
Pointer to the Application's main menù.
albaUser * GetMafUser()
Return the current alba user.
virtual void SetMenubar(wxMenuBar *mb)
Set a reference to the main men.
void FillTraceabilityAttribute(albaOp *op, albaVME *in_node, albaVME *out_node)
Fill the attribute for traceability events.
virtual ~albaOpManager()
albaOpCopy * m_OpCopy
Pointer to the (always available) operation for copying VMEs.
albaString GetBuildNum() const
Set Build Num.
albaOpRename * m_OpRename
Pointer to the (always available) operation for reparenting VMEs.
void SetAccelerator(albaOp *op)
virtual void EnableToolbar(bool CanEnable=true)
Enable/Disable the toolbar's buttons.
albaString m_BuildNum
virtual void ClearUndoStack()
Clear the stack of executed operation.
virtual bool ForceStopWithCancel()
Try to Stop the Current Stop operation with CANCEL condition.
int m_NumOp
Number of plugged operations.
void EnableContextualMenu(albaGUITreeContextualMenu *contextualMenu, albaVME *node, bool CanEnable=true)
void RefreshMenu()
Called by logic to refresh the operation's menù items.
void SetMafUser(albaUser *user)
Set MafUser.
class name: albaOpPaste Operation which perform paste of a node previously copied or cut.
Definition: albaOpSelect.h:160
class name: albaOpPaste Operation which perform paste of a node previously copied or cut.
Definition: albaOpSelect.h:182
class name: albaOpSelect Operation for the selection of a vme.
Definition: albaOpSelect.h:38
Definition: albaOp.h:51
albaString - performs common string operations on c-strings.
Definition: albaString.h:43
albaUser - Used to manage username and password; store them and give basic function to check user's c...
Definition: albaUser.h:33
albaVME -
Definition: albaVME.h:150