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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : GEOMBase_Skeleton.cxx
25 // Author : Damien COQUERET
29 #include "GEOMBase_Skeleton.h"
31 #include "GeometryGUI.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_Application.h"
35 #include "LightApp_SelectionMgr.h"
36 #include "SUIT_Session.h"
37 #include "SUIT_MessageBox.h"
40 #include <qpushbutton.h>
41 #include <qcheckbox.h>
45 //=================================================================================
46 // class : GEOMBase_Skeleton()
47 // purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the
48 // name 'name' and widget flags set to 'f'.
49 // The dialog will by default be modeless, unless you set 'modal' to
50 // TRUE to construct a modal dialog.
51 //=================================================================================
52 GEOMBase_Skeleton::GEOMBase_Skeleton (GeometryGUI* theGeometryGUI, QWidget* parent,
53 const char* name, bool modal, WFlags fl)
54 : DlgRef_Skeleton_QTD( parent, name, modal, WStyle_Customize | WStyle_NormalBorder
55 | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
56 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
57 myGeomGUI( theGeometryGUI )
60 setName("GEOMBase_Skeleton");
62 GroupBoxName->setTitle(tr("GEOM_RESULT_NAME_GRP"));
63 NameLabel->setText(tr("GEOM_RESULT_NAME_LBL"));
65 GroupBoxPublish->setTitle(tr("GEOM_PUBLISH_RESULT_GRP"));
66 CheckBoxRestoreSS->setText(tr("GEOM_RESTORE_SUB_SHAPES"));
68 buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
69 buttonOk->setText(tr("GEOM_BUT_APPLY_AND_CLOSE"));
70 buttonApply->setText(tr("GEOM_BUT_APPLY"));
71 buttonHelp->setText(tr("GEOM_BUT_HELP"));
78 //=================================================================================
79 // function : ~GEOMBase_Skeleton()
80 // purpose : Destroys the object and frees any allocated resources
81 //=================================================================================
82 GEOMBase_Skeleton::~GEOMBase_Skeleton()
85 myGeomGUI->SetActiveDialogBox( 0 );
88 //=================================================================================
91 //=================================================================================
92 void GEOMBase_Skeleton::Init()
94 SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
95 if (!myGeomGUI && app)
96 myGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
100 myGeomGUI->SetActiveDialogBox(this);
102 /* signals and slots connections */
103 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
106 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
107 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
110 // connect help button on a private slot that displays help information
111 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
113 /* displays Dialog */
114 RadioButton1->setChecked(TRUE);
115 RadioButton4->hide();
116 RadioButton5->hide();
118 CheckBoxRestoreSS->setChecked(FALSE);
119 GroupBoxPublish->hide();
122 //=================================================================================
123 // function : ClickOnCancel()
125 //=================================================================================
126 void GEOMBase_Skeleton::ClickOnCancel()
131 //=================================================================================
132 // function : LineEditReturnPressed()
134 //=================================================================================
135 void GEOMBase_Skeleton::LineEditReturnPressed()
137 if ( !myEditCurrentArgument )
140 /* User name of object input management */
141 /* If successfull the selection is changed and signal emitted... */
142 /* so SelectionIntoArgument() is automatically called. */
143 const QString objectUserName = myEditCurrentArgument->text();
144 QWidget* thisWidget = (QWidget*)this;
146 if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
147 myEditCurrentArgument->setText(objectUserName);
150 //=================================================================================
151 // function : DeactivateActiveDialog()
153 //=================================================================================
154 void GEOMBase_Skeleton::DeactivateActiveDialog()
156 this->setEnabled(false);
159 myGeomGUI->SetActiveDialogBox(0);
160 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
164 //=================================================================================
165 // function : ActivateThisDialog()
167 //=================================================================================
168 void GEOMBase_Skeleton::ActivateThisDialog()
170 /* Emit a signal to deactivate the active dialog */
171 if (myGeomGUI) myGeomGUI->EmitSignalDeactivateDialog();
172 this->setEnabled(true);
173 if (myGeomGUI) myGeomGUI->SetActiveDialogBox((QDialog*)this);
176 //=================================================================================
177 // function : closeEvent()
178 // purpose : same than click on cancel button
179 //=================================================================================
180 void GEOMBase_Skeleton::closeEvent(QCloseEvent* e)
183 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
184 myGeomGUI->getApp()->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() );
220 //=================================================================================
221 // function : ClickOnHelp()
223 //=================================================================================
224 void GEOMBase_Skeleton::ClickOnHelp()
226 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
228 app->onHelpContextModule(myGeomGUI ? app->moduleName(myGeomGUI->moduleName()) : QString(""), myHelpFileName);
232 platform = "winapplication";
234 platform = "application";
236 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
237 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
238 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
239 QObject::tr("BUT_OK"));
243 //=================================================================================
244 // function : setHelpFileName()
245 // purpose : set name for help file html
246 //=================================================================================
247 void GEOMBase_Skeleton::setHelpFileName(const QString& theName)
249 myHelpFileName = theName;
252 //=================================================================================
253 // function : keyPressEvent()
255 //=================================================================================
256 void GEOMBase_Skeleton::keyPressEvent( QKeyEvent* e )
258 QDialog::keyPressEvent( e );
259 if ( e->isAccepted() )
262 if ( e->key() == Key_F1 )