1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Francis KLOSS
31 // Acces a l`ihm de SALOME
32 // -----------------------
34 #include "SUPERVGUI_Def.h"
35 #include "SUPERVGUI_Service.h"
36 #include "SUPERVGUI_Main.h"
38 #include "SalomeApp_Module.h"
39 #include "SALOMEDSClient.hxx"
43 // Definition de la classe principale du module de supervision
44 // -----------------------------------------------------------
46 class SUPERVGUI: public SalomeApp_Module {
53 static SUPERVGUI* Supervision();
55 virtual void initialize( CAM_Application* );
56 virtual QString engineIOR() const;
57 SUPERV_Engine getEngine();
58 SUIT_Study* getActiveStudy() { return study; }
60 SUPERVGUI_Service* getBrowser();
62 //bool information(SUPERV_CNode node, bool isReadOnly);
63 void putInfo(const char* mess);
65 void importDataflow();
66 void exportDataflow();
68 void modifyDataflow();
69 void reloadDataflow();
73 void suspendResumeDataflow();
74 void showComponents();
76 SUPERVGUI_Main* getMain();
78 bool OnGUIEvent(int theCommandID);
80 //void DefinePopup(QString & theContext,
81 // QString & theParent,
82 // QString & theObject ) ;
83 //bool CustomPopup(QPopupMenu* popup,
84 // const QString & theContext,
85 // const QString & theParent,
86 // const QString & theObject);
87 bool ActiveStudyChanged();
88 //void SupportedViewType (int* buffer, int bufferSize);
90 bool isContains(SUIT_Study* theStudy, const QString theKey);
92 void registerGraph(QString theName, SUPERVGUI_Main* theGraph);
93 void unregisterGraph(SUPERVGUI_Main* theGraph);
94 SUIT_ViewWindow* createGraph();
97 theIsOwner = true if Selected object belongs to Suipervision.
98 theIsDataflow = true if Selected object is Dataflow
100 void whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bool& theIsDataflow);
102 /* asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file,
103 a backup copy of an existing file must be created (in case Export fails..)
104 This method creates a backup file and returns its name or QString::null if it fails
105 Function is static because it is called from
106 SUPERVGUI::exportDataflow() and SUPERVGUI_CanvasMacroNode::exportDataflow()
108 static QString createBackupFile( const QString& theOriginalFileName );
110 virtual void windows( QMap<int, int>& ) const;
112 QMap<QString, QString> getInterfaceNameMap() const;
115 * \brief The method nullify myInitalViewFrame variable
116 * to avoid using this view frame once more, it is using
117 * after add any node into first new dataflow in study.
119 void nullifyInitialVF() { if ( myInitialViewFrame ) myInitialViewFrame = 0; }
122 QColor getIVFBackgroundColor() { return myIVFBackgroundColor; }
123 void setIVFBackgroundColor( QColor theColor ) { if ( myInitialViewFrame ) myIVFBackgroundColor = theColor; }
127 * \brief The method update name of the given dataflow, if this dataflow is in study.
128 * Returns true if update was done.
130 bool updateDataFlowSOName( SUPERV::Graph_ptr theDataflow );
133 void KillMainThread(bool theValue);
136 void setMain(SUIT_ViewWindow* w);
137 void displayDataflow();
138 void renameDataflow();
140 void onGraphClosed( SUIT_ViewWindow* );
144 virtual bool activateModule( SUIT_Study* );
145 virtual bool deactivateModule( SUIT_Study* );
148 virtual CAM_DataModel* createDataModel();
149 virtual LightApp_Selection* createSelection() const;
152 void loadEngine(SALOME_NamingService* namingService);
154 // enumeration used in newDataflow() method
155 enum NEW_DF_MODE { Import, Modify, New };
156 // method called from importDataflow(), modifyDataflow(), newDataflow() with
157 // different modes. The behavior of the function is very similar in all 3 cases,
158 // but some differences still exist. These differences are implemented using NEW_DF_MODE param.
159 bool createDataflow( const NEW_DF_MODE f, bool theInitialDF = false );
161 void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""),
162 const int key = 0, const bool toggle = false );
164 void fillInterfaceNameMap();
168 SUPERV_Engine engine;
169 SUPERVGUI_Service* browser;
170 //SUPERVGUI_Information* info;
173 SUPERVGUI_Main* main; // active main
174 QPtrList<SUPERVGUI_Main> myGraphList;
175 QMap<QString, QString> myInterfaceNameMap;
177 bool myFirstActivation;
178 bool myAllGraphsClosed;
179 SUPERVGraph_ViewFrame* myInitialViewFrame;
180 QColor myIVFBackgroundColor; // mkr : IPAL10825