1 // Copyright (C) 2009-2023 CEA, EDF
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>
39 #include <QButtonGroup>
41 using namespace HEXABLOCK::GUI;
43 //=================================================================================
44 // class : MyGEOMBase_Skeleton()
45 // purpose : Constructs a MyGEOMBase_Skeleton which is a child of 'parent', with the
46 // name 'name' and widget flags set to 'f'.
47 // The dialog will by default be modeless, unless you set 'modal' to
48 // true to construct a modal dialog.
49 //=================================================================================
50 MyGEOMBase_Skeleton::MyGEOMBase_Skeleton( QWidget* parent, Qt::WindowFlags fl )
51 : HexaBaseDialog(parent, NEW_MODE, fl),
55 myMainFrame = new MyDlgRef_Skeleton( this );
56 QVBoxLayout* topLayout = new QVBoxLayout( this );
57 topLayout->setMargin( 0 ); topLayout->setSpacing( 0 );
58 topLayout->addWidget( myMainFrame );
60 myMainFrame->GroupBoxPublish->setTitle( tr( "GEOM_PUBLISH_RESULT_GRP" ) );
61 myMainFrame->CheckBoxRestoreSS->setText( tr( "GEOM_RESTORE_SUB_SHAPES" ) );
62 myMainFrame->CheckBoxAddPrefix->setText( tr( "GEOM_RSS_ADD_FREFIX" ) );
63 myMainFrame->CheckBoxPreview->setText( tr("GEOM_PREVIEW") );
65 myRBGroup = new QButtonGroup( this );
66 myRBGroup->addButton( myMainFrame->RadioButton1, 0 );
67 myRBGroup->addButton( myMainFrame->RadioButton2, 1 );
68 myRBGroup->addButton( myMainFrame->RadioButton3, 2 );
69 myRBGroup->addButton( myMainFrame->RadioButton4, 3 );
70 myRBGroup->addButton( myMainFrame->RadioButton5, 4 );
72 connect( myRBGroup, SIGNAL( buttonClicked( int ) ), this, SIGNAL( constructorsClicked( int ) ) );
76 //=================================================================================
77 // function : ~MyGEOMBase_Skeleton()
78 // purpose : Destroys the object and frees any allocated resources
79 //=================================================================================
80 MyGEOMBase_Skeleton::~MyGEOMBase_Skeleton()
84 //=================================================================================
87 //=================================================================================
88 void MyGEOMBase_Skeleton::Init()
91 myMainFrame->RadioButton1->setChecked( true );
92 myMainFrame->RadioButton4->hide();
93 myMainFrame->RadioButton5->hide();
94 myMainFrame->GroupBoxPublish->hide();
97 //=================================================================================
98 // function : initSpinBox()
100 //=================================================================================
101 void MyGEOMBase_Skeleton::initSpinBox( QSpinBox* spinBox,
102 int min, int max, int step )
104 spinBox->setRange( min, max );
105 spinBox->setSingleStep( step );
108 //=================================================================================
109 // function : initSpinBox()
111 //=================================================================================
112 void MyGEOMBase_Skeleton::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
113 double min, double max,
114 double step, const char* quantity, unsigned int decimals)
116 spinBox->setPrecision( decimals );
117 spinBox->setDecimals( decimals );
118 spinBox->setRange( min, max );
119 spinBox->setSingleStep( step );
122 //=================================================================================
123 // function : closeEvent()
124 // purpose : same than click on cancel button
125 //=================================================================================
126 void MyGEOMBase_Skeleton::closeEvent( QCloseEvent* e )
129 HEXABLOCKGUI::currentOccGView->displayPreview(shape);
131 QDialog::closeEvent( e );
134 //=================================================================================
135 // function : getConstructorId()
137 //=================================================================================
138 int MyGEOMBase_Skeleton::getConstructorId() const
141 return myRBGroup->checkedId();
145 //=================================================================================
146 // function : setConstructorId( id )
148 //=================================================================================
149 void MyGEOMBase_Skeleton::setConstructorId( const int id )
151 if ( myRBGroup && myRBGroup->button( id ) )
152 myRBGroup->button( id )->setChecked( true );
155 //=================================================================================
156 // function : unsetConstructorId
158 //=================================================================================
159 void MyGEOMBase_Skeleton::unsetConstructorId()
161 // 0020428: EDF 906 GEOM : Performance for Group creation in GEOM
162 // uncheck all buttons
163 // workaround, because setChecked( false ) does not result in Qt4
164 bool isExclusive = myRBGroup->exclusive();
165 myRBGroup->setExclusive( false );
166 QList<QAbstractButton*> btnList = myRBGroup->buttons();
167 for ( int j = 0; j < 2; j++ )
169 QList<QAbstractButton*>::const_iterator it = btnList.constBegin(), itEnd = btnList.constEnd();
170 for ( ; it != itEnd; ++it )
171 (*it)->setCheckable( j == 1 );
173 myRBGroup->setExclusive( isExclusive );
176 MyDlgRef_Skeleton* MyGEOMBase_Skeleton::mainFrame()
181 QWidget* MyGEOMBase_Skeleton::centralWidget()
183 return myMainFrame->GroupMedium;
186 //=================================================================================
187 // function : showOnlyPreviewControl()
188 // purpose : display only CheckBoxPreview check box,
189 // hide CheckBoxRestoreSS and CheckBoxAddPrefix
190 //=================================================================================
191 void MyGEOMBase_Skeleton::showOnlyPreviewControl(){
192 mainFrame()->GroupBoxPublish->show();
193 mainFrame()->CheckBoxRestoreSS->hide();
194 mainFrame()->CheckBoxAddPrefix->hide();