1 // Copyright (C) 2009-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "MyGEOMBase_Skeleton.hxx"
22 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
24 #include "MyDlgRef.hxx"
26 #include <SalomeApp_Application.h>
27 #include <SalomeApp_DoubleSpinBox.h>
28 #include <SalomeApp_Study.h>
29 #include <LightApp_Application.h>
30 #include <LightApp_SelectionMgr.h>
31 #include <SUIT_Desktop.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_MessageBox.h>
38 #include <QDoubleSpinBox>
40 using namespace HEXABLOCK::GUI;
42 //=================================================================================
43 // class : MyGEOMBase_Skeleton()
44 // purpose : Constructs a MyGEOMBase_Skeleton which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // true to construct a modal dialog.
48 //=================================================================================
49 MyGEOMBase_Skeleton::MyGEOMBase_Skeleton( QWidget* parent, Qt::WindowFlags fl )
50 : HexaBaseDialog(parent, NEW_MODE, fl),
54 myMainFrame = new MyDlgRef_Skeleton( this );
55 QVBoxLayout* topLayout = new QVBoxLayout( this );
56 topLayout->setMargin( 0 ); topLayout->setSpacing( 0 );
57 topLayout->addWidget( myMainFrame );
59 myMainFrame->GroupBoxPublish->setTitle( tr( "GEOM_PUBLISH_RESULT_GRP" ) );
60 myMainFrame->CheckBoxRestoreSS->setText( tr( "GEOM_RESTORE_SUB_SHAPES" ) );
61 myMainFrame->CheckBoxAddPrefix->setText( tr( "GEOM_RSS_ADD_FREFIX" ) );
62 myMainFrame->CheckBoxPreview->setText( tr("GEOM_PREVIEW") );
64 myRBGroup = new QButtonGroup( this );
65 myRBGroup->addButton( myMainFrame->RadioButton1, 0 );
66 myRBGroup->addButton( myMainFrame->RadioButton2, 1 );
67 myRBGroup->addButton( myMainFrame->RadioButton3, 2 );
68 myRBGroup->addButton( myMainFrame->RadioButton4, 3 );
69 myRBGroup->addButton( myMainFrame->RadioButton5, 4 );
71 connect( myRBGroup, SIGNAL( buttonClicked( int ) ), this, SIGNAL( constructorsClicked( int ) ) );
75 //=================================================================================
76 // function : ~MyGEOMBase_Skeleton()
77 // purpose : Destroys the object and frees any allocated resources
78 //=================================================================================
79 MyGEOMBase_Skeleton::~MyGEOMBase_Skeleton()
83 //=================================================================================
86 //=================================================================================
87 void MyGEOMBase_Skeleton::Init()
90 myMainFrame->RadioButton1->setChecked( true );
91 myMainFrame->RadioButton4->hide();
92 myMainFrame->RadioButton5->hide();
93 myMainFrame->GroupBoxPublish->hide();
96 //=================================================================================
97 // function : initSpinBox()
99 //=================================================================================
100 void MyGEOMBase_Skeleton::initSpinBox( QSpinBox* spinBox,
101 int min, int max, int step )
103 spinBox->setRange( min, max );
104 spinBox->setSingleStep( step );
107 //=================================================================================
108 // function : initSpinBox()
110 //=================================================================================
111 void MyGEOMBase_Skeleton::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
112 double min, double max,
113 double step, const char* quantity, unsigned int decimals)
115 spinBox->setPrecision( decimals );
116 spinBox->setDecimals( decimals );
117 spinBox->setRange( min, max );
118 spinBox->setSingleStep( step );
121 //=================================================================================
122 // function : closeEvent()
123 // purpose : same than click on cancel button
124 //=================================================================================
125 void MyGEOMBase_Skeleton::closeEvent( QCloseEvent* e )
128 HEXABLOCKGUI::currentOccGView->displayPreview(shape);
130 QDialog::closeEvent( e );
133 //=================================================================================
134 // function : getConstructorId()
136 //=================================================================================
137 int MyGEOMBase_Skeleton::getConstructorId() const
140 return myRBGroup->checkedId();
144 //=================================================================================
145 // function : setConstructorId( id )
147 //=================================================================================
148 void MyGEOMBase_Skeleton::setConstructorId( const int id )
150 if ( myRBGroup && myRBGroup->button( id ) )
151 myRBGroup->button( id )->setChecked( true );
154 //=================================================================================
155 // function : unsetConstructorId
157 //=================================================================================
158 void MyGEOMBase_Skeleton::unsetConstructorId()
160 // 0020428: EDF 906 GEOM : Performance for Group creation in GEOM
161 // uncheck all buttons
162 // workaround, because setChecked( false ) does not result in Qt4
163 bool isExclusive = myRBGroup->exclusive();
164 myRBGroup->setExclusive( false );
165 QList<QAbstractButton*> btnList = myRBGroup->buttons();
166 for ( int j = 0; j < 2; j++ )
168 QList<QAbstractButton*>::const_iterator it = btnList.constBegin(), itEnd = btnList.constEnd();
169 for ( ; it != itEnd; ++it )
170 (*it)->setCheckable( j == 1 );
172 myRBGroup->setExclusive( isExclusive );
175 MyDlgRef_Skeleton* MyGEOMBase_Skeleton::mainFrame()
180 QWidget* MyGEOMBase_Skeleton::centralWidget()
182 return myMainFrame->GroupMedium;
185 //=================================================================================
186 // function : showOnlyPreviewControl()
187 // purpose : display only CheckBoxPreview check box,
188 // hide CheckBoxRestoreSS and CheckBoxAddPrefix
189 //=================================================================================
190 void MyGEOMBase_Skeleton::showOnlyPreviewControl(){
191 mainFrame()->GroupBoxPublish->show();
192 mainFrame()->CheckBoxRestoreSS->hide();
193 mainFrame()->CheckBoxAddPrefix->hide();