1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GEOMBase_Skeleton.cxx
25 // Author : Damien COQUERET
30 #include "GEOMBase_Skeleton.h"
31 #include "GeometryGUI.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Application.h"
35 #include "SalomeApp_SelectionMgr.h"
37 #include <qpushbutton.h>
39 //=================================================================================
40 // class : GEOMBase_Skeleton()
41 // purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the
42 // name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // TRUE to construct a modal dialog.
45 //=================================================================================
46 GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, bool modal, WFlags fl)
47 :DlgRef_Skeleton_QTD( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
48 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) )
51 setName("GEOMBase_Skeleton");
53 buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
54 buttonOk->setText(tr("GEOM_BUT_OK"));
55 buttonApply->setText(tr("GEOM_BUT_APPLY"));
57 GroupMedium->close(TRUE);
64 //=================================================================================
65 // function : ~GEOMBase_Skeleton()
66 // purpose : Destroys the object and frees any allocated resources
67 //=================================================================================
68 GEOMBase_Skeleton::~GEOMBase_Skeleton()
71 myGeomGUI->SetActiveDialogBox( 0 );
75 //=================================================================================
78 //=================================================================================
79 void GEOMBase_Skeleton::Init()
82 SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
85 SalomeApp_Module* module = dynamic_cast<SalomeApp_Module*>(app->loadModule("Geometry"));
87 myGeomGUI = dynamic_cast<GeometryGUI*>(module);
91 myGeomBase = new GEOMBase(); // SAN -- TO BE REMOVED !!!
92 myGeomGUI->SetActiveDialogBox(this);
94 /* signals and slots connections */
95 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
98 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
99 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
102 /* Move widget on the botton right corner of main widget */
104 // myGeomBase->DefineDlgPosition( this, x, y );
106 /* displays Dialog */
107 RadioButton1->setChecked(TRUE);
108 RadioButton4->hide();
114 //=================================================================================
115 // function : ClickOnCancel()
117 //=================================================================================
118 void GEOMBase_Skeleton::ClickOnCancel()
124 //=================================================================================
125 // function : LineEditReturnPressed()
127 //=================================================================================
128 void GEOMBase_Skeleton::LineEditReturnPressed()
130 if ( !myEditCurrentArgument )
133 /* User name of object input management */
134 /* If successfull the selection is changed and signal emitted... */
135 /* so SelectionIntoArgument() is automatically called. */
136 const QString objectUserName = myEditCurrentArgument->text();
137 QWidget* thisWidget = (QWidget*)this;
139 if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
140 myEditCurrentArgument->setText(objectUserName);
146 //=================================================================================
147 // function : DeactivateActiveDialog()
149 //=================================================================================
150 void GEOMBase_Skeleton::DeactivateActiveDialog()
152 this->setEnabled(false);
154 disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
155 if (myGeomGUI) myGeomGUI->SetActiveDialogBox(0);
161 //=================================================================================
162 // function : ActivateThisDialog()
164 //=================================================================================
165 void GEOMBase_Skeleton::ActivateThisDialog()
167 /* Emit a signal to deactivate the active dialog */
168 if (myGeomGUI) myGeomGUI->EmitSignalDeactivateDialog();
169 this->setEnabled(true);
170 if (myGeomGUI) myGeomGUI->SetActiveDialogBox((QDialog*)this);
175 //=================================================================================
176 // function : closeEvent()
177 // purpose : same than click on cancel button
178 //=================================================================================
179 void GEOMBase_Skeleton::closeEvent(QCloseEvent* e)
181 SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
183 disconnect( app->selectionMgr(), 0, this, 0);
184 app->updateActions();
186 QDialog::closeEvent( e );
189 //=================================================================================
190 // function : initName()
191 // purpose : initialize the Name field with a string "thePrefix_X" (Vertex_3)
192 //=================================================================================
193 void GEOMBase_Skeleton::initName( const char* thePrefix )
196 setPrefix( thePrefix );
197 ResultName->setText( GEOMBase::GetDefaultName( getPrefix() ) );
200 //=================================================================================
201 // function : getNewObjectName()
202 // purpose : returns contents of Name field
203 //=================================================================================
204 const char* GEOMBase_Skeleton::getNewObjectName() const
206 return ResultName->text();
209 //=================================================================================
210 // function : getConstructorId()
212 //=================================================================================
213 int GEOMBase_Skeleton::getConstructorId() const
215 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
216 return GroupConstructors->id( GroupConstructors->selected() );