Salome HOME
Copyright update 2021
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_ViscousLayersWidget.cxx
1 // Copyright (C) 2015-2021  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File    : HexoticPluginGUI_ViscousLayersWidget.cxx
22 //
23
24 #include "HexoticPluginGUI_Dlg.h"
25
26 #include <SUIT_Session.h>
27 #include <SUIT_ResourceMgr.h>
28
29 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
30
31 //////////////////////////////////////////
32 // HexoticPluginGUI_ViscousLayersWidget
33 //////////////////////////////////////////
34
35 HexoticPluginGUI_ViscousLayersWidget::HexoticPluginGUI_ViscousLayersWidget( QWidget* parent, Qt::WindowFlags f )
36 : QWidget( parent, f )
37 {
38   setupUi( this );
39
40   // Obtain precision from preferences
41   int precision = SUIT_Session::session()->resourceMgr()->integerValue( "SMESH", "length_precision", -3 );
42
43   myNbLayers->setMinimum(0);
44   myNbLayers->setSingleStep( 1 );
45
46   myFirstLayerSize->setMinimum(0);
47   myFirstLayerSize->setPrecision(precision);
48   myFirstLayerSize->setSingleStep(0.1);
49
50   myGrowth->setMinimum(0);
51   myFirstLayerSize->setPrecision(precision);
52   myGrowth->setSingleStep( 0.1 );
53
54   myFacesWithLayers = new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
55   QHBoxLayout* layoutFacesWithLayers = new QHBoxLayout(myContainerFacesWithLayers);
56   layoutFacesWithLayers->setMargin(0);
57   layoutFacesWithLayers->addWidget(myFacesWithLayers);
58
59   myImprintedFaces = new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
60   QHBoxLayout* layoutImprintedFaces = new QHBoxLayout(myContainerImprintedFaces);
61   layoutImprintedFaces->setMargin(0);
62   layoutImprintedFaces->addWidget(myImprintedFaces);
63
64   connect( myFacesWithLayers, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
65   connect( myImprintedFaces, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
66 }
67
68 HexoticPluginGUI_ViscousLayersWidget::~HexoticPluginGUI_ViscousLayersWidget()
69 {
70 }
71
72 void HexoticPluginGUI_ViscousLayersWidget::onSelectionChanged()
73 {
74   StdMeshersGUI_SubShapeSelectorWdg* send = (StdMeshersGUI_SubShapeSelectorWdg*)sender();
75
76   bool isDefault = (send == myFacesWithLayers);
77   myFacesWithLayers->ShowPreview(isDefault);
78   myImprintedFaces->ShowPreview(!isDefault);
79   if (isDefault)
80     myImprintedFaces->ClearSelected();
81   else
82         myFacesWithLayers->ClearSelected();
83
84 }