1 // Copyright (C) 2007-2013 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
23 #include "HYDROGUI_ProfileDlg.h"
25 #include "HYDROGUI_Module.h"
26 #include <CurveCreator_Widget.h>
27 #include <CurveCreator_ICurve.hxx>
29 #include <OCCViewer_ViewPort3d.h>
30 #include <OCCViewer_Utilities.h>
31 #include <OCCViewer_ViewManager.h>
32 #include <OCCViewer_ViewFrame.h>
33 #include <LightApp_Application.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_ResourceMgr.h>
39 #include <QHBoxLayout>
43 HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle )
44 : HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
46 QHBoxLayout* aNameLayout = new QHBoxLayout();
47 QLabel* aNameLabel = new QLabel(tr("PROFILE_NAME_TLT"), this);
48 aNameLayout->addWidget(aNameLabel);
49 myName = new QLineEdit(this);
50 aNameLayout->addWidget(myName);
52 addLayout(aNameLayout);
54 myEditorWidget = new CurveCreator_Widget( this, NULL );
55 addWidget( myEditorWidget, 3 );
57 OCCViewer_ViewManager* aViewMgr = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 );
58 myViewer = new OCCViewer_Viewer( true );
60 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
61 myViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
62 aResMgr->backgroundValue( "OCCViewer", "xz_background", myViewer->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
63 myViewer->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
64 aResMgr->backgroundValue( "OCCViewer", "yz_background", myViewer->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
65 myViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
66 aResMgr->backgroundValue( "OCCViewer", "xy_background", myViewer->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
67 myViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
68 aResMgr->backgroundValue( "OCCViewer", "background", myViewer->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
70 myViewer->setTrihedronSize( aResMgr->doubleValue( "3DViewer", "trihedron_size", myViewer->trihedronSize() ),
71 aResMgr->booleanValue( "3DViewer", "relative_size", myViewer->trihedronRelative() ));
72 myViewer->setInteractionStyle( aResMgr->integerValue( "3DViewer", "navigation_mode", myViewer->interactionStyle() ) );
73 myViewer->setZoomingStyle( aResMgr->integerValue( "3DViewer", "zooming_mode", myViewer->zoomingStyle() ) );
74 myViewer->enablePreselection( aResMgr->booleanValue( "OCCViewer", "enable_preselection", myViewer->isPreselectionEnabled() ) );
75 myViewer->enableSelection( aResMgr->booleanValue( "OCCViewer", "enable_selection", myViewer->isSelectionEnabled() ) );
77 aViewMgr->setViewModel( myViewer );// custom view model, which extends SALOME_View interface
78 SUIT_ViewWindow* aViewWin = aViewMgr->createViewWindow();
79 addWidget( aViewWin, 4 );
80 myEditorWidget->setOCCViewer( myViewer );
82 connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
83 connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*) ), this, SLOT( processStartedSubOperation(QWidget*) ) );
84 connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
87 HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg()
91 void HYDROGUI_ProfileDlg::reset()
93 myEditorWidget->reset();
96 Handle(AIS_InteractiveContext) HYDROGUI_ProfileDlg::getAISContext()
98 return myViewer->getAISContext();
101 void HYDROGUI_ProfileDlg::setProfileName( const QString& theName )
103 myName->setText(theName);
106 QString HYDROGUI_ProfileDlg::getProfileName() const
108 return myName->text();
111 void HYDROGUI_ProfileDlg::setProfile( CurveCreator_ICurve* theProfile )
113 myEditorWidget->setCurve( theProfile );
116 QList<int> HYDROGUI_ProfileDlg::getSelectedSections()
118 return myEditorWidget->getSelectedSections();
121 QList< QPair< int, int > > HYDROGUI_ProfileDlg::getSelectedPoints()
123 return myEditorWidget->getSelectedPoints();
127 * Redirect the delete action to editor widget
129 void HYDROGUI_ProfileDlg::deleteSelected()
131 myEditorWidget->removeSelected();
135 * Checks whether there are some to delete
137 bool HYDROGUI_ProfileDlg::deleteEnabled()
139 return myEditorWidget->removeEnabled();