Salome HOME
DCQ : New Architecture
[modules/geom.git] / src / MeasureGUI / MeasureGUI.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   : MeasureGUI.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header: 
28
29 using namespace std;
30 #include "MeasureGUI.h"
31
32 #include "SALOMEGUI_QtCatchCorbaException.hxx"
33
34 #include "MeasureGUI_PropertiesDlg.h"    // Method PROPERTIES
35 #include "MeasureGUI_CenterMassDlg.h"    // Method CENTER MASS
36 #include "MeasureGUI_InertiaDlg.h"       // Method INERTIA
37 #include "MeasureGUI_BndBoxDlg.h"        // Method BNDBOX
38 #include "MeasureGUI_DistanceDlg.h"      // Method DISTANCE
39 #include "MeasureGUI_MaxToleranceDlg.h"  // Method MAXTOLERANCE
40 #include "MeasureGUI_WhatisDlg.h"        // Method WHATIS
41 #include "MeasureGUI_CheckShapeDlg.h"    // Method CHECKSHAPE
42
43 //=======================================================================
44 // function : MeasureGUI()
45 // purpose  : Constructor
46 //=======================================================================
47 MeasureGUI::MeasureGUI() :
48   QObject()
49 {
50   myGeomBase = new GEOMBase();
51   myGeomGUI = GEOMContext::GetGeomGUI();
52   myGeom = myGeomGUI->myComponentGeom;
53 }
54
55
56 //=======================================================================
57 // function : ~MeasureGUI()
58 // purpose  : Destructor
59 //=======================================================================
60 MeasureGUI::~MeasureGUI()
61 {
62 }
63
64
65 //=======================================================================
66 // function : OnGUIEvent()
67 // purpose  : 
68 //=======================================================================
69 bool MeasureGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
70 {
71   MeasureGUI* myMeasureGUI = new MeasureGUI();
72   myMeasureGUI->myGeomGUI->EmitSignalDeactivateDialog();
73   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
74
75   switch (theCommandID)
76     {
77     case 701: // PROPERTIES (Length, surface, volume)
78       {
79         MeasureGUI_PropertiesDlg *aDlg = new MeasureGUI_PropertiesDlg(parent, "", Sel);
80         break;
81       }
82     case 702: // CDG : Center of mass
83       {
84         MeasureGUI_CenterMassDlg *aDlg = new MeasureGUI_CenterMassDlg(parent, "", myMeasureGUI, Sel);
85         break;
86       }
87     case 703: // INERTIA
88       {
89         MeasureGUI_InertiaDlg *aDlg = new MeasureGUI_InertiaDlg(parent, "", Sel);
90         break;
91       }
92     case 7041: // BOUNDING BOX
93       {
94         MeasureGUI_BndBoxDlg *aDlg = new MeasureGUI_BndBoxDlg(parent, "", Sel);
95         break;
96       }
97     case 7042: // MIN DISTANCE
98       {
99         MeasureGUI_DistanceDlg *aDlg = new MeasureGUI_DistanceDlg(parent, "", Sel);
100         break;
101       }
102     case 705: // MAXTOLERANCE
103       {
104         MeasureGUI_MaxToleranceDlg *aDlg = new MeasureGUI_MaxToleranceDlg(parent, "", Sel);
105         break;
106       }
107     case 706: // WHATIS
108       {
109         MeasureGUI_WhatisDlg *aDlg = new MeasureGUI_WhatisDlg(parent, "", Sel);
110         break;
111       }
112     case 707: // CHECKSHAPE
113      {
114        MeasureGUI_CheckShapeDlg *aDlg = new MeasureGUI_CheckShapeDlg(parent, "", Sel);
115        break;
116      }
117     default:
118       {
119         parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
120         break;
121       }
122     }
123   return true;
124 }
125
126
127 //=====================================================================================
128 // function : MakeCDGAndDisplay()
129 // purpose  :
130 //=====================================================================================
131 void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape)
132 {
133   try {
134     GEOM::GEOM_Shape_var result = myGeom->MakeCDG(Shape);
135     if(result->_is_nil()) {
136       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
137       return;
138     }
139     result->NameType(tr("GEOM_POINT"));
140     if(myGeomBase->Display(result))
141       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
142   }  
143   catch(const SALOME::SALOME_Exception& S_ex) {
144     QtCatchCorbaException(S_ex);
145   }
146   return;
147 }
148
149
150 //=====================================================================================
151 // EXPORTED METHODS
152 //=====================================================================================
153 extern "C"
154 {
155   bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
156   {return MeasureGUI::OnGUIEvent(theCommandID, parent);}
157 }