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 albaOpImporterFile;
46class vtkMatrix4x4;
48class albaGUISettings;
50class albaUser;
51
52#ifdef ALBA_EXPORTS
53#include "albaDllMacros.h"
54EXPORT_STL_VECTOR(ALBA_EXPORT,albaOp*);
55#endif
57
58//----------------------------------------------------------------------------
59// albaOpManager :
60//----------------------------------------------------------------------------
62class ALBA_EXPORT albaOpManager: public albaObserver, public albaServiceClient
63{
64public:
66 virtual ~albaOpManager();
67 virtual void SetListener(albaObserver *Listener) {m_Listener = Listener;};
68 virtual void OnEvent(albaEventBase *alba_event);
69
71 ALBA_ID_DEC(OPERATION_INTERFACE_EVENT)
72 ALBA_ID_DEC(RUN_OPERATION_EVENT)
73
74
75 virtual void OpAdd(albaOp *op, wxString menuPath = "", bool can_undo = true, albaGUISettings *setting = NULL);
76
78 virtual void FillMenu(wxMenu* import, wxMenu* mexport, wxMenu* operations);
79
81 void FillSettingDialog(albaGUISettingsDialog *settingDialog);
82
84 virtual void VmeSelected(albaVME* v);
85
87 virtual void VmeModified(albaVME* v);
88
90 virtual void VmeRemove(albaVME* v);
91
93 virtual albaVME* GetSelectedVme();
94
96 virtual void OpRun(int op_id);
97
99 virtual void OpRun(albaOp *op, void *op_param = NULL);
100
102 virtual void OpRun(albaString &op_type, void *op_param = NULL);
103
104 void RunOpAddGroup();
105
106 void RunOpCut();
107 void RunOpCopy();
108 void RunOpPaste();
109 void RunOpDelete();
110 void RunOpRename();
111 void RunOpReparentTo();
112 void RunOpShowHistory();
113
115 virtual void OpExec (albaOp *op);
116
118 virtual void OpSelect(albaVME* v);
119
121 virtual void WarningIfCantUndo (bool warn) {m_Warn = warn;};
122
124 virtual void SetToolbar(wxToolBar *tb) {m_ToolBar = tb;};
125
127 virtual void SetMenubar(wxMenuBar *mb) {m_MenuBar = mb;};
128
130 virtual bool Running() {return m_Context.Caller() != NULL;};
131
133 virtual void ClearUndoStack();
134
136 virtual bool ForceStopWithOk();
137
139 virtual bool ForceStopWithCancel();
140
142 virtual bool StopCurrentOperation();
143
144 void EnableContextualMenu(albaGUITreeContextualMenu *contextualMenu, albaVME *node, bool CanEnable = true);
145
148
151
155
158
160 void SetMafUser(albaUser *user);
161
163 albaUser* GetMafUser(){return m_User;};
164
166 virtual void EnableOp(bool CanEnable = true);
167
168
170 albaString GetBuildNum() const { return m_BuildNum; }
171
173 void SetBuildNum(albaString val) { m_BuildNum = val; }
174
175 int ImportFile(albaString filename);
176
177protected:
179 virtual void OpDo(albaOp *op);
180
182 virtual void OpRunOk(albaOp *op);
183
185 virtual void OpRunCancel(albaOp *op);
186
188 virtual void OpUndo();
189
191 virtual void OpRedo();
192
194 virtual bool WarnUser(albaOp *op);
195
197 virtual void Notify(int msg, long arg=0L);
198
200 virtual void EnableToolbar(bool CanEnable = true);
201
203 void FillTraceabilityAttribute(albaOp *op, albaVME *in_node, albaVME *out_node);
204
206
208 bool m_Warn;
211 wxMenu *m_Menu[3];
214
216
217 std::vector<albaOp *> m_OpList;
218 std::vector<albaOpImporterFile *> m_OpImporterFileList;
220 wxAcceleratorEntry m_OpAccelEntries[MAXOP];
222
224
230 albaOpReparentTo *m_OpReparent;
231 albaOpCreateGroup *m_OpAddGroup;
232 albaOpShowHistory *m_OpShowHistory;
233 wxMenuBar *m_MenuBar;
234 wxToolBar *m_ToolBar;
236
238
240 friend class albaOpManagerTest;
241private:
242 albaOpImporterFile *SelectOpFromList(std::vector<albaOpImporterFile *> opList);
243};
244#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:67
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 ImportFile(albaString filename)
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.
std::vector< albaOpImporterFile * > m_OpImporterFileList
List of pointer of plugged importer file operations.
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:50
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