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( const VisuGUI* theModule, QWidget* theParent ) :
51 VisuGUI_Panel( tr( "WINDOW_TITLE" ), theModule, theParent, ApplyBtn | CloseBtn | HelpBtn ),
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 QtxDoubleSpinBox( 0.0, 90.0, 10.0, myGrp );
63 myFeatureEdgesCB = new QCheckBox( tr( "SHOW_FEATURE_EDGES" ), myGrp );
64 myBoundaryEdgesCB = new QCheckBox( tr( "SHOW_BOUNDARY_EDGES" ), myGrp );
65 myManifoldEdgesCB = new QCheckBox( tr( "SHOW_MANIFOLD_EDGES" ), myGrp );
66 myNonManifoldEdgesCB = new QCheckBox( tr( "SHOW_NON_MANIFOLD_EDGES" ), myGrp );
68 //myColoringCB = new QCheckBox( tr( "FEATURE_EDGES_COLORING" ), myGrp );
70 aLayout->addWidget( anAngleLbl, 0, 0 );
71 aLayout->addWidget( myAngleSpinBox, 0, 1 );
72 aLayout->addWidget( myFeatureEdgesCB, 1, 0, 1, 2 );
73 aLayout->addWidget( myBoundaryEdgesCB, 2, 0, 1, 2 );
74 aLayout->addWidget( myManifoldEdgesCB, 3, 0, 1, 2 );
75 aLayout->addWidget( myNonManifoldEdgesCB, 4, 0, 1, 2 );
76 //aLayout->addWidget( myColoringCB, 5, 0, 1, 2 );
78 aTopLayout->addWidget( myGrp );
80 SalomeApp_Application* anApp =
81 dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
82 LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
83 connect( aSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionEvent() ) );
86 VisuGUI_FeatureEdgesPanel::~VisuGUI_FeatureEdgesPanel()
90 void VisuGUI_FeatureEdgesPanel::showEvent( QShowEvent* theEvent )
94 VisuGUI_Panel::showEvent(theEvent);
97 VISU_Actor* VisuGUI_FeatureEdgesPanel::getSelectedActor() const
99 SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule );
103 _PTR(SObject) aSObject;
104 VISU::Prs3d_i* aPrs3d = 0;
105 Handle(SALOME_InteractiveObject) anIO;
107 VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( myModule );
108 if( aSelectionInfo.size() != 1 )
111 VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
112 VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
113 aPrs3d = GetPrs3dFromBase( anObjectInfo.myBase );
117 anIO = aSelectionItem.myIO;
118 aSObject = anObjectInfo.mySObject;
120 VISU_Actor* anActor =
121 VISU::FindActor( VISU::GetAppStudy( myModule ), aViewWindow, aSObject->GetID().c_str() );
126 void VisuGUI_FeatureEdgesPanel::onSelectionEvent()
128 myActor = getSelectedActor();
129 bool anIsSelected = myActor && myActor->IsFeatureEdgesAllowed();
131 myGrp->setEnabled( anIsSelected );
132 myApply->setEnabled( anIsSelected );
137 if( !myActor->IsFeatureEdgesAllowed() )
140 float anAngle = myActor->GetFeatureEdgesAngle();
142 bool anIsFeatureEdges = false,
143 anIsBoundaryEdges = false,
144 anIsManifoldEdges = false,
145 anIsNonManifoldEdges = false;
146 myActor->GetFeatureEdgesFlags( anIsFeatureEdges,
149 anIsNonManifoldEdges );
151 float aColoring = myActor->GetFeatureEdgesColoring();
153 myAngleSpinBox->setValue( anAngle );
154 myFeatureEdgesCB->setChecked( anIsFeatureEdges );
155 myBoundaryEdgesCB->setChecked( anIsBoundaryEdges );
156 myManifoldEdgesCB->setChecked( anIsManifoldEdges );
157 myNonManifoldEdgesCB->setChecked( anIsNonManifoldEdges );
158 //myColoringCB->setChecked( aColoring );
161 void VisuGUI_FeatureEdgesPanel::onApply()
165 myActor->SetFeatureEdgesAngle( myAngleSpinBox->value() );
166 myActor->SetFeatureEdgesFlags( myFeatureEdgesCB->isChecked(),
167 myBoundaryEdgesCB->isChecked(),
168 myManifoldEdgesCB->isChecked(),
169 myNonManifoldEdgesCB->isChecked() );
170 //myActor->SetFeatureEdgesColoring( myColoringCB->isChecked() );
174 VisuGUI_Panel::onApply();
177 void VisuGUI_FeatureEdgesPanel::onClose()
180 VisuGUI_Panel::onClose();
183 void VisuGUI_FeatureEdgesPanel::onHelp()
185 QString aHelpFileName = "feature_edges_page.html";
186 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
188 app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
192 platform = "winapplication";
194 platform = "application";
196 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
197 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
198 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
201 VisuGUI_Panel::onHelp();
204 void VisuGUI_FeatureEdgesPanel::keyPressEvent( QKeyEvent* e )
206 VisuGUI_Panel::keyPressEvent( e );
207 if ( e->isAccepted() )
210 if ( e->key() == Qt::Key_F1 )