1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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
20 // VISU VISUGUI : GUI of VISU component
21 // File : VisuGUI_FeatureEdgesPanel.cxx
22 // Author : Oleg Uvarov
25 #include "VisuGUI_FeatureEdgesPanel.h"
28 #include "VisuGUI_Tools.h"
29 #include "VisuGUI_ViewTools.h"
36 #include <QPushButton>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_ResourceMgr.h>
42 #include <SalomeApp_Application.h>
43 #include <SalomeApp_DoubleSpinBox.h>
45 #include <LightApp_SelectionMgr.h>
47 VisuGUI_FeatureEdgesPanel::VisuGUI_FeatureEdgesPanel( VisuGUI* theModule, QWidget* theParent ) :
48 VisuGUI_Panel( tr( "WINDOW_TITLE" ), theModule, theParent, ApplyBtn | CloseBtn | HelpBtn ),
51 setWindowTitle( tr( "WINDOW_TITLE" ) );
52 setObjectName( tr( "WINDOW_TITLE" ) );
54 QVBoxLayout* aTopLayout = new QVBoxLayout( mainFrame() );
55 myGrp = new QGroupBox( tr( "FEATURE_EDGES_PROPERTIES" ), mainFrame() );
57 QGridLayout* aLayout = new QGridLayout( myGrp );
58 aLayout->setAlignment( Qt::AlignTop );
60 QLabel* anAngleLbl = new QLabel( tr( "FEATURE_EDGES_ANGLE" ), myGrp );
61 myAngleSpinBox = new SalomeApp_DoubleSpinBox( myGrp );
62 VISU::initSpinBox( myAngleSpinBox, 0.0, 90.0, 10.0, "angle_precision" );
64 myFeatureEdgesCB = new QCheckBox( tr( "SHOW_FEATURE_EDGES" ), myGrp );
65 myBoundaryEdgesCB = new QCheckBox( tr( "SHOW_BOUNDARY_EDGES" ), myGrp );
66 myManifoldEdgesCB = new QCheckBox( tr( "SHOW_MANIFOLD_EDGES" ), myGrp );
67 myNonManifoldEdgesCB = new QCheckBox( tr( "SHOW_NON_MANIFOLD_EDGES" ), myGrp );
69 //myColoringCB = new QCheckBox( tr( "FEATURE_EDGES_COLORING" ), myGrp );
71 aLayout->addWidget( anAngleLbl, 0, 0 );
72 aLayout->addWidget( myAngleSpinBox, 0, 1 );
73 aLayout->addWidget( myFeatureEdgesCB, 1, 0, 1, 2 );
74 aLayout->addWidget( myBoundaryEdgesCB, 2, 0, 1, 2 );
75 aLayout->addWidget( myManifoldEdgesCB, 3, 0, 1, 2 );
76 aLayout->addWidget( myNonManifoldEdgesCB, 4, 0, 1, 2 );
77 //aLayout->addWidget( myColoringCB, 5, 0, 1, 2 );
79 aTopLayout->addWidget( myGrp );
81 connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
82 this, SLOT( onSelectionEvent() ) );
85 VisuGUI_FeatureEdgesPanel::~VisuGUI_FeatureEdgesPanel()
89 void VisuGUI_FeatureEdgesPanel::showEvent( QShowEvent* theEvent )
93 VisuGUI_Panel::showEvent(theEvent);
96 VISU_Actor* VisuGUI_FeatureEdgesPanel::getSelectedActor() const
98 SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule );
102 _PTR(SObject) aSObject;
103 VISU::Prs3d_i* aPrs3d = 0;
104 Handle(SALOME_InteractiveObject) anIO;
106 VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( myModule );
107 if( aSelectionInfo.size() != 1 )
110 VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
111 VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
112 aPrs3d = GetPrs3dFromBase( anObjectInfo.myBase );
116 anIO = aSelectionItem.myIO;
117 aSObject = anObjectInfo.mySObject;
119 VISU_Actor* anActor =
120 VISU::FindActor( VISU::GetAppStudy( myModule ), aViewWindow, aSObject->GetID().c_str() );
125 void VisuGUI_FeatureEdgesPanel::onSelectionEvent()
127 myActor = getSelectedActor();
128 bool anIsSelected = myActor && myActor->IsFeatureEdgesAllowed();
130 myGrp->setEnabled( anIsSelected );
131 myApply->setEnabled( anIsSelected );
136 if( !myActor->IsFeatureEdgesAllowed() )
139 float anAngle = myActor->GetFeatureEdgesAngle();
141 bool anIsFeatureEdges = false,
142 anIsBoundaryEdges = false,
143 anIsManifoldEdges = false,
144 anIsNonManifoldEdges = false;
145 myActor->GetFeatureEdgesFlags( anIsFeatureEdges,
148 anIsNonManifoldEdges );
150 //float aColoring = myActor->GetFeatureEdgesColoring();
152 myAngleSpinBox->setValue( anAngle );
153 myFeatureEdgesCB->setChecked( anIsFeatureEdges );
154 myBoundaryEdgesCB->setChecked( anIsBoundaryEdges );
155 myManifoldEdgesCB->setChecked( anIsManifoldEdges );
156 myNonManifoldEdgesCB->setChecked( anIsNonManifoldEdges );
157 //myColoringCB->setChecked( aColoring );
160 void VisuGUI_FeatureEdgesPanel::onApply()
164 myActor->SetFeatureEdgesAngle( myAngleSpinBox->value() );
165 myActor->SetFeatureEdgesFlags( myFeatureEdgesCB->isChecked(),
166 myBoundaryEdgesCB->isChecked(),
167 myManifoldEdgesCB->isChecked(),
168 myNonManifoldEdgesCB->isChecked() );
169 //myActor->SetFeatureEdgesColoring( myColoringCB->isChecked() );
173 VisuGUI_Panel::onApply();
176 void VisuGUI_FeatureEdgesPanel::onClose()
179 VisuGUI_Panel::onClose();
182 void VisuGUI_FeatureEdgesPanel::onHelp()
184 QString aHelpFileName = "feature_edges_page.html";
185 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
187 app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
191 platform = "winapplication";
193 platform = "application";
195 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
196 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
197 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
200 VisuGUI_Panel::onHelp();
203 void VisuGUI_FeatureEdgesPanel::keyPressEvent( QKeyEvent* e )
205 VisuGUI_Panel::keyPressEvent( e );
206 if ( e->isAccepted() )
209 if ( e->key() == Qt::Key_F1 )
216 void VisuGUI_FeatureEdgesPanel::onModuleActivated()
218 disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
219 this, SLOT( onSelectionEvent() ) );
220 connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
221 this, SLOT( onSelectionEvent() ) );
222 VisuGUI_Panel::onModuleActivated();
225 void VisuGUI_FeatureEdgesPanel::onModuleDeactivated()
227 disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
228 this, SLOT( onSelectionEvent() ) );
229 VisuGUI_Panel::onModuleDeactivated();