Salome HOME
Implementation of the "20830: EDF 1357 GUI : Hide/Show Icon"
[modules/geom.git] / src / MeasureGUI / MeasureGUI.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : MeasureGUI.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 //
27 #include "MeasureGUI.h"
28
29 #include <GeometryGUI.h>
30 #include "GeometryGUI_Operations.h"
31 #include <SUIT_Desktop.h>
32 #include <SalomeApp_Application.h>
33
34 #include "MeasureGUI_PropertiesDlg.h"    // Method PROPERTIES
35 #include "MeasureGUI_CenterMassDlg.h"    // Method CENTER MASS
36 #include "MeasureGUI_NormaleDlg.h"       // Method NORMALE
37 #include "MeasureGUI_InertiaDlg.h"       // Method INERTIA
38 #include "MeasureGUI_BndBoxDlg.h"        // Method BNDBOX
39 #include "MeasureGUI_DistanceDlg.h"      // Method DISTANCE
40 #include "MeasureGUI_AngleDlg.h"         // Method ANGLE
41 #include "MeasureGUI_MaxToleranceDlg.h"  // Method MAXTOLERANCE
42 #include "MeasureGUI_WhatisDlg.h"        // Method WHATIS
43 #include "MeasureGUI_CheckShapeDlg.h"    // Method CHECKSHAPE
44 #include "MeasureGUI_CheckCompoundOfBlocksDlg.h" // Method CHECKCOMPOUND
45 #include "MeasureGUI_PointDlg.h"         // Method POINTCOORDINATES
46
47 #include <QApplication>
48
49 //=======================================================================
50 // function : MeasureGUI()
51 // purpose  : Constructor
52 //=======================================================================
53 MeasureGUI::MeasureGUI( GeometryGUI* parent ) : GEOMGUI( parent )
54 {
55 }
56
57 //=======================================================================
58 // function : ~MeasureGUI()
59 // purpose  : Destructor
60 //=======================================================================
61 MeasureGUI::~MeasureGUI()
62 {
63 }
64
65
66 //=======================================================================
67 // function : OnGUIEvent()
68 // purpose  : 
69 //=======================================================================
70 bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
71 {
72   SalomeApp_Application* app = getGeometryGUI()->getApp();
73   if ( !app ) return false;
74
75   getGeometryGUI()->EmitSignalDeactivateDialog();
76
77   QDialog* dlg = 0;
78   switch ( theCommandID ) {
79   case GEOMOp::OpProperties:
80     dlg = new MeasureGUI_PropertiesDlg( getGeometryGUI(), parent );
81     break; // LENGTH, AREA AND VOLUME
82   case GEOMOp::OpCenterMass:
83     dlg = new MeasureGUI_CenterMassDlg( getGeometryGUI(), parent );
84     break; // CENTER MASS7
85   case GEOMOp::OpInertia:
86     dlg = new MeasureGUI_InertiaDlg( getGeometryGUI(), parent );
87     break; // INERTIA
88   case GEOMOp::OpNormale : 
89     dlg = new MeasureGUI_NormaleDlg( getGeometryGUI(), parent );
90     break; // NORMALE
91   case GEOMOp::OpBoundingBox:
92     dlg = new MeasureGUI_BndBoxDlg( getGeometryGUI(), parent );
93     break; // BOUNDING BOX
94   case GEOMOp::OpMinDistance:
95     dlg = new MeasureGUI_DistanceDlg( getGeometryGUI(), parent );
96     break; // MIN DISTANCE
97   case GEOMOp::OpAngle: 
98     dlg = new MeasureGUI_AngleDlg( getGeometryGUI(), parent );
99     break; // ANGLE
100   case GEOMOp::OpTolerance: 
101     dlg = new MeasureGUI_MaxToleranceDlg( getGeometryGUI(), parent );
102     break; // MAXTOLERANCE
103   case GEOMOp::OpWhatIs:
104     dlg = new MeasureGUI_WhatisDlg( getGeometryGUI(), parent );
105     break; // WHATIS
106   case GEOMOp::OpCheckShape:
107     dlg = new MeasureGUI_CheckShapeDlg( getGeometryGUI(), parent );
108     break; // CHECKSHAPE
109   case GEOMOp::OpCheckCompound:
110     dlg = new MeasureGUI_CheckCompoundOfBlocksDlg( getGeometryGUI(), parent );
111     break; // CHECKCOMPOUND
112   case GEOMOp::OpPointCoordinates:
113     dlg = new MeasureGUI_PointDlg( getGeometryGUI(), parent );
114     break; // POINT COORDINATES
115   default: 
116     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); 
117     break;
118   }
119   if ( dlg ) {
120     dlg->updateGeometry();
121     dlg->resize( dlg->minimumSizeHint() );
122     dlg->show();
123   }
124   return true;
125 }
126
127
128 //=====================================================================================
129 // EXPORTED METHODS
130 //=====================================================================================
131 extern "C"
132 {
133 #ifdef WIN32
134   __declspec( dllexport )
135 #endif
136   GEOMGUI* GetLibGUI( GeometryGUI* parent )
137   {
138     return new MeasureGUI( parent );
139   }
140 }