X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMBase%2FGEOMBase_Skeleton.cxx;h=1a93f19711831d3957100b57184c546c539dc8af;hb=496cc5f9ba9ea7ae0e2adc8960a697839c145c20;hp=7ab20a236dc08b526e1f33dd368dcaf96edbe4f5;hpb=b0937de45df90a04388a2e101c956c0a4ea750c3;p=modules%2Fgeom.git diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx index 7ab20a236..1a93f1971 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.cxx +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -1,59 +1,89 @@ -// GEOM GEOMGUI : GUI for Geometry component +// GEOM GEOMGUI : GUI for Geometry component // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : GEOMBase_Skeleton.cxx +// Author : Damien COQUERET, Open CASCADE S.A.S. // -// -// File : GEOMBase_Skeleton.cxx -// Author : Damien COQUERET -// Module : GEOM -// $Header$ -using namespace std; #include "GEOMBase_Skeleton.h" -#include "GeometryGUI.h" -#include "SALOME_Selection.h" +#include "GEOMBase.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include -#include +#include +#include + +using namespace std; //================================================================================= // class : GEOMBase_Skeleton() // purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. +// true to construct a modal dialog. //================================================================================= -GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) -:DlgRef_Skeleton_QTD(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), GEOMBase_Helper() +GEOMBase_Skeleton::GEOMBase_Skeleton( GeometryGUI* theGeometryGUI, QWidget* parent, + const char* name, bool modal, Qt::WindowFlags fl ) + : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + GEOMBase_Helper( dynamic_cast( parent ) ), + myGeomGUI( theGeometryGUI ), + myRBGroup( 0 ) { - if (!name) - setName("GEOMBase_Skeleton"); + if ( !name ) + setObjectName( "GEOMBase_Skeleton" ); + else + setObjectName( name ); + + setAttribute( Qt::WA_DeleteOnClose ); - buttonCancel->setText(tr("GEOM_BUT_CLOSE")); - buttonOk->setText(tr("GEOM_BUT_OK")); - buttonApply->setText(tr("GEOM_BUT_APPLY")); + setModal( modal ); - GroupMedium->close(TRUE); - resize(0, 0); + myMainFrame = new DlgRef_Skeleton( this ); + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( 0 ); topLayout->setSpacing( 0 ); + topLayout->addWidget( myMainFrame ); - Init(Sel); + buttonCancel()->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonOk()->setText( tr( "GEOM_BUT_OK" )) ; + buttonApply()->setText( tr( "GEOM_BUT_APPLY" ) ); + buttonHelp()->setText( tr( "GEOM_BUT_HELP" ) ); + + myRBGroup = new QButtonGroup( this ); + myRBGroup->addButton( myMainFrame->RadioButton1, 0 ); + myRBGroup->addButton( myMainFrame->RadioButton2, 1 ); + myRBGroup->addButton( myMainFrame->RadioButton3, 2 ); + myRBGroup->addButton( myMainFrame->RadioButton4, 4 ); + + connect( myRBGroup, SIGNAL( buttonClicked( int ) ), this, SIGNAL( constructorsClicked( int ) ) ); + + Init(); } @@ -63,7 +93,8 @@ GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_S //================================================================================= GEOMBase_Skeleton::~GEOMBase_Skeleton() { - myGeomGUI->SetActiveDialogBox( 0 ); + if ( myGeomGUI ) + myGeomGUI->SetActiveDialogBox( 0 ); } @@ -71,32 +102,38 @@ GEOMBase_Skeleton::~GEOMBase_Skeleton() // function : Init() // purpose : //================================================================================= -void GEOMBase_Skeleton::Init(SALOME_Selection* Sel) +void GEOMBase_Skeleton::Init() { - myGeomGUI = GeometryGUI::GetGeomGUI(); + SalomeApp_Application* app = (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ); + if ( !myGeomGUI && app ) + myGeomGUI = dynamic_cast( app->module( "Geometry" ) ); /* init variables */ - mySelection = Sel; - - myGeomBase = new GEOMBase(); // SAN -- TO BE REMOVED !!! - myGeomGUI->SetActiveDialogBox(this); + myGeomGUI->SetActiveDialogBox( this ); /* signals and slots connections */ - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + connect( buttonCancel(), SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + if ( myGeomGUI ) { + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + } - /* Move widget on the botton right corner of main widget */ -// int x, y; -// myGeomBase->DefineDlgPosition( this, x, y ); + // connect help button on a private slot that displays help information + connect( buttonHelp(), SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) ); /* displays Dialog */ - RadioButton1->setChecked(TRUE); - RadioButton4->hide(); - - return; + myMainFrame->RadioButton1->setChecked( true ); + myMainFrame->RadioButton4->hide(); } +void GEOMBase_Skeleton::initSpinBox( QDoubleSpinBox* spinBox, + double min, double max, + double step, int decimals ) +{ + spinBox->setRange( min, max ); + spinBox->setSingleStep( step ); + spinBox->setDecimals( decimals ); +} //================================================================================= // function : ClickOnCancel() @@ -122,10 +159,9 @@ void GEOMBase_Skeleton::LineEditReturnPressed() /* so SelectionIntoArgument() is automatically called. */ const QString objectUserName = myEditCurrentArgument->text(); QWidget* thisWidget = (QWidget*)this; - if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) - myEditCurrentArgument->setText(objectUserName); - - return; + + if ( GEOMBase::SelectionByNameInDialogs( thisWidget, objectUserName, selectedIO() ) ) + myEditCurrentArgument->setText( objectUserName ); } @@ -135,12 +171,10 @@ void GEOMBase_Skeleton::LineEditReturnPressed() //================================================================================= void GEOMBase_Skeleton::DeactivateActiveDialog() { - this->setEnabled(false); + this->setEnabled( false ); globalSelection(); - //myGeomGUI->ResetState(); - disconnect(mySelection, 0, this, 0); - GeometryGUI::GetGeomGUI()->SetActiveDialogBox(0); - return; + disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 ); + if ( myGeomGUI ) myGeomGUI->SetActiveDialogBox( 0 ); } @@ -151,9 +185,9 @@ void GEOMBase_Skeleton::DeactivateActiveDialog() void GEOMBase_Skeleton::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); - this->setEnabled(true); - GeometryGUI::GetGeomGUI()->SetActiveDialogBox((QDialog*)this); + if ( myGeomGUI ) myGeomGUI->EmitSignalDeactivateDialog(); + this->setEnabled( true ); + if ( myGeomGUI ) myGeomGUI->SetActiveDialogBox( (QDialog*)this ); return; } @@ -162,9 +196,13 @@ void GEOMBase_Skeleton::ActivateThisDialog() // function : closeEvent() // purpose : same than click on cancel button //================================================================================= -void GEOMBase_Skeleton::closeEvent(QCloseEvent* e) +void GEOMBase_Skeleton::closeEvent( QCloseEvent* e ) { - disconnect(mySelection, 0, this, 0); + SalomeApp_Application* app = (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ); + if( app ) { + disconnect( app->selectionMgr(), 0, this, 0 ); + app->updateActions(); + } QDialog::closeEvent( e ); } @@ -172,11 +210,11 @@ void GEOMBase_Skeleton::closeEvent(QCloseEvent* e) // function : initName() // purpose : initialize the Name field with a string "thePrefix_X" (Vertex_3) //================================================================================= -void GEOMBase_Skeleton::initName( const char* thePrefix ) +void GEOMBase_Skeleton::initName( const QString& thePrefix ) { - if ( thePrefix ) + if ( !thePrefix.isNull() ) setPrefix( thePrefix ); - ResultName->setText( GEOMBase::GetDefaultName( getPrefix() ) ); + myMainFrame->ResultName->setText( GEOMBase::GetDefaultName( getPrefix() ) ); } //================================================================================= @@ -185,7 +223,7 @@ void GEOMBase_Skeleton::initName( const char* thePrefix ) //================================================================================= const char* GEOMBase_Skeleton::getNewObjectName() const { - return ResultName->text(); + return myMainFrame->ResultName->text().toLatin1().constData(); } //================================================================================= @@ -194,7 +232,89 @@ const char* GEOMBase_Skeleton::getNewObjectName() const //================================================================================= int GEOMBase_Skeleton::getConstructorId() const { - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + /*if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) return GroupConstructors->id( GroupConstructors->selected() ); + return -1;*/ + + if ( myRBGroup != NULL ) + return myRBGroup->checkedId(); return -1; } + +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::ClickOnHelp() +{ + LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() ); + if ( app ) + app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName ); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ), + QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). + arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ), + QObject::tr( "BUT_OK" ) ); + } +} +//================================================================================= +// function : setHelpFileName() +// purpose : set name for help file html +//================================================================================= + +void GEOMBase_Skeleton::setHelpFileName( const QString& theName ) +{ + myHelpFileName = theName; +} + +DlgRef_Skeleton* GEOMBase_Skeleton::mainFrame() +{ + return myMainFrame; +} + +QWidget* GEOMBase_Skeleton::centralWidget() +{ + return myMainFrame->GroupMedium; +} + +QPushButton* GEOMBase_Skeleton::buttonCancel() const +{ + return myMainFrame->buttonCancel; +} + +QPushButton* GEOMBase_Skeleton::buttonOk() const +{ + return myMainFrame->buttonOk; +} + +QPushButton* GEOMBase_Skeleton::buttonApply() const +{ + return myMainFrame->buttonApply; +} + +QPushButton* GEOMBase_Skeleton::buttonHelp() const +{ + return myMainFrame->buttonHelp; +} + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); + } +}