]> SALOME platform Git repositories - modules/geom.git/blob - src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx
Salome HOME
5416076902f3cb65617570495f894725165f68bf
[modules/geom.git] / src / MeasureGUI / MeasureGUI_CheckShapeDlg.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_CheckShapeDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : GEOM
27 //  $Header$
28
29 #include "MeasureGUI_CheckShapeDlg.h"
30 #include "MeasureGUI_1Sel1TextView_QTD.h"
31
32 #include "utilities.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Tools.h"
35
36 #include <qtextedit.h>
37 #include <qlineedit.h>
38 #include <qlabel.h>
39 #include <qlayout.h>
40 #include <qpushbutton.h>
41 #include <qradiobutton.h>
42 #include <qbuttongroup.h>
43
44 #define TEXTEDIT_FONT_FAMILY "Courier"
45 #define TEXTEDIT_FONT_SIZE 11
46
47 //=================================================================================
48 // class    : MeasureGUI_CheckShapeDlg()
49 // purpose  : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
50 //            name 'name' and widget flags set to 'f'.
51 //            The dialog will by default be modeless, unless you set 'modal' to
52 //            TRUE to construct a modal dialog.
53 //=================================================================================
54 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
55 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_CheckShapeDlg" )
56 {
57   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
58     "GEOM",tr( "ICON_DLG_CHECKSHAPE" ) ) );
59   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
60     "GEOM",tr( "ICON_SELECT" ) ) );
61
62   setCaption( tr( "GEOM_CHECK_TITLE" ) );
63
64   /***************************************************************/
65
66   GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
67   RadioButton1->setPixmap( image0 );
68
69   myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" );
70   myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
71   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
72   myGrp->TextEdit1->setReadOnly( TRUE );
73   
74   QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
75   aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
76   myGrp->TextEdit1->setFont( aFont );
77   myGrp->PushButton1->setPixmap( image1 );
78   myGrp->LineEdit1->setReadOnly( true );
79
80   Layout1->addWidget( myGrp, 1, 0 );
81
82   /***************************************************************/
83
84   myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#check";
85
86   /* Initialisation */
87   Init();
88 }
89
90
91 //=================================================================================
92 // function : ~MeasureGUI_CheckShapeDlg()
93 // purpose  : Destroys the object and frees any allocated resources
94 //=================================================================================
95 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
96 {
97 }
98
99
100 //=================================================================================
101 // function : Init()
102 // purpose  :
103 //=================================================================================
104 void MeasureGUI_CheckShapeDlg::Init()
105 {
106   mySelBtn = myGrp->PushButton1;
107   mySelEdit = myGrp->LineEdit1;
108   MeasureGUI_Skeleton::Init();
109 }
110
111 //=================================================================================
112 // function : getParameters
113 // purpose  :
114 //=================================================================================
115 bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
116 {
117   if ( myObj->_is_nil() )
118     return false;
119   else
120   {
121     try
122     {
123       char* aMsg;
124       theIsValid = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->CheckShape( myObj, aMsg );
125       theMsg = aMsg;
126     }
127     catch( const SALOME::SALOME_Exception& e )
128     {
129       SalomeApp_Tools::QtCatchCorbaException( e );
130       return false;
131     }
132
133     return getOperation()->IsDone();
134   }
135 }
136
137
138 //=================================================================================
139 // function : processObject
140 // purpose  :
141 //=================================================================================
142 void MeasureGUI_CheckShapeDlg::processObject()
143 {
144   bool isShapeValid;
145   QString aMsg;
146   if ( !getParameters( isShapeValid, aMsg ) )
147   {
148     myGrp->TextEdit1->setText( "" );
149     return;
150   }
151
152   if (isShapeValid) {
153     myGrp->TextEdit1->setText("This Shape seems to be valid.");
154   } else {
155     QString aDescr ("This Shape is not valid.\n");
156     aDescr += aMsg;
157     myGrp->TextEdit1->setText(aDescr);
158 //    myGrp->TextEdit1->setText("This Shape is not valid.");
159   }
160 }