]> SALOME platform Git repositories - modules/geom.git/blob - src/PrimitiveGUI/PrimitiveGUI.cxx
Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI.cxx
1 //  GEOM GEOMGUI : GUI for Geometry 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   : PrimitiveGUI.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "PrimitiveGUI.h"
31 #include "GeometryGUI.h"
32
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35
36 #include "SALOMEGUI_QtCatchCorbaException.hxx"
37
38 #include "PrimitiveGUI_BoxDlg.h"      // Method BOX
39 #include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER
40 #include "PrimitiveGUI_SphereDlg.h"   // Method SPHERE
41 #include "PrimitiveGUI_TorusDlg.h"    // Method TORUS
42 #include "PrimitiveGUI_ConeDlg.h"     // Method CONE
43
44 PrimitiveGUI* PrimitiveGUI::myGUIObject = 0;
45
46 //=======================================================================
47 // function : GetPrimitiveGUI()
48 // purpose  : Get the only PrimitiveGUI object [ static ]
49 //=======================================================================
50 PrimitiveGUI* PrimitiveGUI::GetPrimitiveGUI()
51 {
52   if ( myGUIObject == 0 ) {
53     // init PrimitiveGUI only once
54     myGUIObject = new PrimitiveGUI();
55   }
56   return myGUIObject;
57 }
58
59 //=======================================================================
60 // function : PrimitiveGUI()
61 // purpose  : Constructor
62 //=======================================================================
63 PrimitiveGUI::PrimitiveGUI() : GEOMGUI()
64 {
65 }
66
67
68 //=======================================================================
69 // function : ~PrimitiveGUI
70 // purpose  : Destructor
71 //=======================================================================
72 PrimitiveGUI::~PrimitiveGUI()
73 {
74 }
75
76
77 //=======================================================================
78 // function : OnGUIEvent()
79 // purpose  : 
80 //=======================================================================
81 bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
82 {
83   PrimitiveGUI* aPrimitiveGUI = GetPrimitiveGUI();
84   GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog();
85   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
86   
87   QDialog* aDlg = NULL;
88
89   switch (theCommandID)
90     {
91     case 4021: // BOX
92       {
93         aDlg = new PrimitiveGUI_BoxDlg(parent, "", Sel);
94         break;
95       }
96     case 4022: // CYLINDER
97       {
98         aDlg = new PrimitiveGUI_CylinderDlg(parent, "", Sel);
99         break;
100       }
101     case 4023: // SPHERE
102       {
103         aDlg = new PrimitiveGUI_SphereDlg(parent, "", Sel);
104         break;
105       }
106     case 4024: // TORUS
107       {
108         aDlg = new PrimitiveGUI_TorusDlg(parent, "", Sel);
109         break;
110       }
111     case 4025: // CONE
112       {
113         aDlg = new PrimitiveGUI_ConeDlg(parent, "", Sel);
114         break;
115       }
116     default:
117       {
118         parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
119         break;
120       }
121     }
122
123   if ( aDlg != NULL )
124     aDlg->show();
125   
126   return true;
127 }
128
129
130 //=====================================================================================
131 // EXPORTED METHODS
132 //=====================================================================================
133 extern "C"
134 {
135   GEOMGUI* GetLibGUI()
136   {
137     return PrimitiveGUI::GetPrimitiveGUI();
138   }
139 }