]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_Library.h
Salome HOME
840e0be6c425d625d4ad50f9e676532e3626eb1f
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Library.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SUPERVGUI_Library.h
25 //  Author : Alexander SLADKOV
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_Library_H
29 #define SUPERVGUI_Library_H
30
31 #include <qdialog.h>
32
33 #include "utilities.h"
34 #include "SALOME_LifeCycleCORBA.hxx"
35 #include CORBA_CLIENT_HEADER(SUPERV)
36
37 class QListBox;
38
39 /**
40  * SUPERVGUI_Library class is intended for management of InLine nodes library.
41  * InLine nodes library is an XML repository (currently it is a predefined user-dependant XML file)
42  * with InLine nodes stored in it.  InLine node in a library contains its Python code and lists of 
43  * input and output ports.
44  */
45 class SUPERVGUI_Library : QObject { // extending QObject to enable slot/signals
46
47   Q_OBJECT
48
49 protected:
50   SUPERVGUI_Library(); // constructor is protected, use static function getLibrary()
51  
52 public:
53   static SUPERVGUI_Library* getLibrary() { 
54     if ( !myLibrary )
55       myLibrary = new SUPERVGUI_Library();
56     return myLibrary; 
57   }
58
59   // Returns the XML file name used as InLine nodes repository
60   const char* GetLibraryFileName() const;
61
62   // Export an InLine node to Library 
63   bool Export( SUPERV::INode_var theNode ) const;
64
65   // Import an InLine node from Library into the dataflow  
66   SUPERV::CNode_var Import( SUPERV::Graph_var theDataflow, const int theLibIndex ) const; 
67
68 private:
69   static SUPERVGUI_Library* myLibrary;
70
71   bool createLibFile() const; // returns false on file creation error (also displays MB)
72
73 };
74
75 /**
76  * Dialog box for Add/Remove InLine nodes to Library, Add node to Graph from Library
77  */
78 class SUPERVGUI_LibDlg: public QDialog {
79
80   Q_OBJECT
81
82 public:
83   SUPERVGUI_LibDlg( QWidget* parent, int& theX, int& theY );
84   ~SUPERVGUI_LibDlg();
85
86 private slots:
87   void add(); // add selected node from library to graph
88   void remove(); // remove selected node from library
89
90 private:
91   QListBox* myLB;
92   int& myX; // comes from caller - SUPERVGUI_Service, used for calculating next node's position
93   int& myY; // comes from caller - SUPERVGUI_Service
94 };
95
96 #endif