1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_FeatureEdgesPanel.cxx
24 // Author : Oleg Uvarov
27 #include "VisuGUI_FeatureEdgesPanel.h"
30 #include "VisuGUI_Tools.h"
31 #include "VisuGUI_ViewTools.h"
38 #include <QPushButton>
40 #include <QtxDoubleSpinBox.h>
42 #include <SUIT_MessageBox.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_ResourceMgr.h>
46 #include <SalomeApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
50 VisuGUI_FeatureEdgesPanel::VisuGUI_FeatureEdgesPanel( VisuGUI* theModule, QWidget* theParent ) :
51 VisuGUI_Panel( tr( "WINDOW_TITLE" ), theModule, theParent, ApplyBtn | CloseBtn | HelpBtn ),
54 setWindowTitle( tr( "WINDOW_TITLE" ) );
55 setObjectName( tr( "WINDOW_TITLE" ) );
57 QVBoxLayout* aTopLayout = new QVBoxLayout( mainFrame() );
58 myGrp = new QGroupBox( tr( "FEATURE_EDGES_PROPERTIES" ), mainFrame() );
60 QGridLayout* aLayout = new QGridLayout( myGrp );
61 aLayout->setAlignment( Qt::AlignTop );
63 QLabel* anAngleLbl = new QLabel( tr( "FEATURE_EDGES_ANGLE" ), myGrp );
64 myAngleSpinBox = new QtxDoubleSpinBox( 0.0, 90.0, 10.0, myGrp );
66 myFeatureEdgesCB = new QCheckBox( tr( "SHOW_FEATURE_EDGES" ), myGrp );
67 myBoundaryEdgesCB = new QCheckBox( tr( "SHOW_BOUNDARY_EDGES" ), myGrp );
68 myManifoldEdgesCB = new QCheckBox( tr( "SHOW_MANIFOLD_EDGES" ), myGrp );
69 myNonManifoldEdgesCB = new QCheckBox( tr( "SHOW_NON_MANIFOLD_EDGES" ), myGrp );
71 //myColoringCB = new QCheckBox( tr( "FEATURE_EDGES_COLORING" ), myGrp );
73 aLayout->addWidget( anAngleLbl, 0, 0 );
74 aLayout->addWidget( myAngleSpinBox, 0, 1 );
75 aLayout->addWidget( myFeatureEdgesCB, 1, 0, 1, 2 );
76 aLayout->addWidget( myBoundaryEdgesCB, 2, 0, 1, 2 );
77 aLayout->addWidget( myManifoldEdgesCB, 3, 0, 1, 2 );
78 aLayout->addWidget( myNonManifoldEdgesCB, 4, 0, 1, 2 );
79 //aLayout->addWidget( myColoringCB, 5, 0, 1, 2 );
81 aTopLayout->addWidget( myGrp );
83 connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
84 this, SLOT( onSelectionEvent() ) );
87 VisuGUI_FeatureEdgesPanel::~VisuGUI_FeatureEdgesPanel()
91 void VisuGUI_FeatureEdgesPanel::showEvent( QShowEvent* theEvent )
95 VisuGUI_Panel::showEvent(theEvent);
98 VISU_Actor* VisuGUI_FeatureEdgesPanel::getSelectedActor() const
100 SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule );
104 _PTR(SObject) aSObject;
105 VISU::Prs3d_i* aPrs3d = 0;
106 Handle(SALOME_InteractiveObject) anIO;
108 VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( myModule );
109 if( aSelectionInfo.size() != 1 )
112 VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
113 VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
114 aPrs3d = GetPrs3dFromBase( anObjectInfo.myBase );
118 anIO = aSelectionItem.myIO;
119 aSObject = anObjectInfo.mySObject;
121 VISU_Actor* anActor =
122 VISU::FindActor( VISU::GetAppStudy( myModule ), aViewWindow, aSObject->GetID().c_str() );
127 void VisuGUI_FeatureEdgesPanel::onSelectionEvent()
129 myActor = getSelectedActor();
130 bool anIsSelected = myActor && myActor->IsFeatureEdgesAllowed();
132 myGrp->setEnabled( anIsSelected );
133 myApply->setEnabled( anIsSelected );
138 if( !myActor->IsFeatureEdgesAllowed() )
141 float anAngle = myActor->GetFeatureEdgesAngle();
143 bool anIsFeatureEdges = false,
144 anIsBoundaryEdges = false,
145 anIsManifoldEdges = false,
146 anIsNonManifoldEdges = false;
147 myActor->GetFeatureEdgesFlags( anIsFeatureEdges,
150 anIsNonManifoldEdges );
152 //float aColoring = myActor->GetFeatureEdgesColoring();
154 myAngleSpinBox->setValue( anAngle );
155 myFeatureEdgesCB->setChecked( anIsFeatureEdges );
156 myBoundaryEdgesCB->setChecked( anIsBoundaryEdges );
157 myManifoldEdgesCB->setChecked( anIsManifoldEdges );
158 myNonManifoldEdgesCB->setChecked( anIsNonManifoldEdges );
159 //myColoringCB->setChecked( aColoring );
162 void VisuGUI_FeatureEdgesPanel::onApply()
166 myActor->SetFeatureEdgesAngle( myAngleSpinBox->value() );
167 myActor->SetFeatureEdgesFlags( myFeatureEdgesCB->isChecked(),
168 myBoundaryEdgesCB->isChecked(),
169 myManifoldEdgesCB->isChecked(),
170 myNonManifoldEdgesCB->isChecked() );
171 //myActor->SetFeatureEdgesColoring( myColoringCB->isChecked() );
175 VisuGUI_Panel::onApply();
178 void VisuGUI_FeatureEdgesPanel::onClose()
181 VisuGUI_Panel::onClose();
184 void VisuGUI_FeatureEdgesPanel::onHelp()
186 QString aHelpFileName = "feature_edges_page.html";
187 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
189 app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
193 platform = "winapplication";
195 platform = "application";
197 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
198 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
199 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
202 VisuGUI_Panel::onHelp();
205 void VisuGUI_FeatureEdgesPanel::keyPressEvent( QKeyEvent* e )
207 VisuGUI_Panel::keyPressEvent( e );
208 if ( e->isAccepted() )
211 if ( e->key() == Qt::Key_F1 )
218 void VisuGUI_FeatureEdgesPanel::onModuleActivated()
220 disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
221 this, SLOT( onSelectionEvent() ) );
222 connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
223 this, SLOT( onSelectionEvent() ) );
224 VisuGUI_Panel::onModuleActivated();
227 void VisuGUI_FeatureEdgesPanel::onModuleDeactivated()
229 disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
230 this, SLOT( onSelectionEvent() ) );
231 VisuGUI_Panel::onModuleDeactivated();