HYDROGUI_GeoreferencementOp.h
HYDROGUI_Actor.h
HYDROGUI_BathymetryBoundsOp.h
+ HYDROGUI_TranslateObstacleDlg.h
+ HYDROGUI_TranslateObstacleOp.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_GeoreferencementOp.cxx
HYDROGUI_Actor.cxx
HYDROGUI_BathymetryBoundsOp.cxx
+ HYDROGUI_TranslateObstacleDlg.cxx
+ HYDROGUI_TranslateObstacleOp.cxx
)
add_definitions(
theMenu->addAction( action( EditDigueId ) );
theMenu->addSeparator();
}
+ else if( anIsObstacle )
+ {
+ theMenu->addAction( action( TranslateObstacleId ) );
+ theMenu->addSeparator();
+ }
else if( anIsVisualState && anIsObjectBrowser )
{
theMenu->addAction( action( SaveVisualStateId ) );
#include "HYDROGUI_ImmersibleZoneOp.h"
#include "HYDROGUI_ImportGeomObjectOp.h"
#include "HYDROGUI_ImportObstacleFromFileOp.h"
+#include "HYDROGUI_TranslateObstacleOp.h"
#include "HYDROGUI_ExportCalculationOp.h"
#include "HYDROGUI_ImportProfilesOp.h"
#include "HYDROGUI_GeoreferencementOp.h"
createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
+ createAction( TranslateObstacleId, "TRANSLATE_OBSTACLE" );
createAction( CreateCalculationId, "CREATE_CALCULATION", "CREATE_CALCULATION_ICO" );
createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpCylinder );
break;
+ case TranslateObstacleId:
+ anOp = new HYDROGUI_TranslateObstacleOp( aModule );
+ break;
case CopyViewerPositionId:
anOp = new HYDROGUI_CopyPastePositionOp( aModule, false );
break;
ImportGeomObjectAsPolylineId,
CreateBoxId,
CreateCylinderId,
+ TranslateObstacleId,
CopyViewerPositionId,
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_TranslateObstacleDlg.h"
+
+#include <QtxDoubleSpinBox.h>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QGroupBox>
+#include <QGridLayout>
+
+#include <limits>
+
+HYDROGUI_TranslateObstacleDlg::HYDROGUI_TranslateObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+ // Obstacle name
+ QGroupBox* aNameGroup = new QGroupBox( tr( "OBSTACLE_NAME" ), this );
+
+ QLabel* aNameLabel = new QLabel( tr( "NAME" ), aNameGroup );
+ myName = new QLineEdit( aNameGroup );
+ myName->setEnabled( false );
+
+ QBoxLayout* aNameLayout = new QHBoxLayout( aNameGroup );
+ aNameLayout->setMargin( 5 );
+ aNameLayout->setSpacing( 5 );
+ aNameLayout->addWidget( aNameLabel );
+ aNameLayout->addWidget( myName );
+
+ // Translation arguments
+ QGroupBox* anArgGroup = new QGroupBox( tr( "TRANSLATION_ARGUMENTS" ), this );
+
+ QLabel* aDxLabel = new QLabel( tr( "DX" ), anArgGroup );
+ myDxSpin = new QtxDoubleSpinBox( -1e+15, +1e+15, 10, anArgGroup );
+
+ QLabel* aDyLabel = new QLabel( tr( "DY" ), anArgGroup );
+ myDySpin = new QtxDoubleSpinBox( -1e+15, +1e+15, 10, anArgGroup );
+
+ QLabel* aDzLabel = new QLabel( tr( "DZ" ), anArgGroup );
+ myDzSpin = new QtxDoubleSpinBox( -1e+15, +1e+15, 10, anArgGroup );
+
+ QGridLayout* anArgLayout = new QGridLayout( anArgGroup );
+ anArgLayout->setMargin( 5 );
+ anArgLayout->setSpacing( 5 );
+
+ anArgLayout->addWidget( aDxLabel, 0, 0 );
+ anArgLayout->addWidget( myDxSpin, 0, 1 );
+ anArgLayout->addWidget( aDyLabel, 1, 0 );
+ anArgLayout->addWidget( myDySpin, 1, 1 );
+ anArgLayout->addWidget( aDzLabel, 2, 0 );
+ anArgLayout->addWidget( myDzSpin, 2, 1 );
+
+ // Layout
+ addWidget( aNameGroup );
+ addWidget( anArgGroup );
+ addStretch();
+
+ // Connect signals and slots
+ connect( myDxSpin, SIGNAL( valueChanged( double ) ), this, SIGNAL( argumentsChanged() ) );
+ connect( myDySpin, SIGNAL( valueChanged( double ) ), this, SIGNAL( argumentsChanged() ) );
+ connect( myDzSpin, SIGNAL( valueChanged( double ) ), this, SIGNAL( argumentsChanged() ) );
+}
+
+HYDROGUI_TranslateObstacleDlg::~HYDROGUI_TranslateObstacleDlg()
+{
+}
+
+void HYDROGUI_TranslateObstacleDlg::reset()
+{
+ myName->clear();
+
+ myDxSpin->setValue( 0 );
+ myDySpin->setValue( 0 );
+ myDzSpin->setValue( 0 );
+}
+
+void HYDROGUI_TranslateObstacleDlg::setName( const QString& theName )
+{
+ myName->setText( theName );
+}
+
+double HYDROGUI_TranslateObstacleDlg::getDx() const
+{
+ return myDxSpin->value();
+}
+
+double HYDROGUI_TranslateObstacleDlg::getDy() const
+{
+ return myDySpin->value();
+}
+
+double HYDROGUI_TranslateObstacleDlg::getDz() const
+{
+ return myDzSpin->value();
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_TranslateObstacleDlg_H
+#define HYDROGUI_TranslateObstacleDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QtxDoubleSpinBox;
+
+class QLineEdit;
+
+class HYDROGUI_TranslateObstacleDlg : public HYDROGUI_InputPanel
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_TranslateObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+ virtual ~HYDROGUI_TranslateObstacleDlg();
+
+ void reset();
+
+ void setName( const QString& theName );
+
+ double getDx() const;
+ double getDy() const;
+ double getDz() const;
+
+signals:
+ void argumentsChanged();
+
+private:
+ QLineEdit* myName;
+
+ QtxDoubleSpinBox* myDxSpin;
+ QtxDoubleSpinBox* myDySpin;
+ QtxDoubleSpinBox* myDzSpin;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_TranslateObstacleOp.h"
+
+#include "HYDROGUI_TranslateObstacleDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+
+
+HYDROGUI_TranslateObstacleOp::HYDROGUI_TranslateObstacleOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule ),
+ myPreviewPrs( NULL )
+{
+ setName( tr( "TRANSLATE_OBSTACLE" ) );
+}
+
+HYDROGUI_TranslateObstacleOp::~HYDROGUI_TranslateObstacleOp()
+{
+ erasePreview();
+}
+
+void HYDROGUI_TranslateObstacleOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ // Get panel and reset its state
+ HYDROGUI_TranslateObstacleDlg* aPanel = (HYDROGUI_TranslateObstacleDlg*)inputPanel();
+ aPanel->reset();
+
+ // Get the edited object
+ myEditedObject = Handle(HYDROData_Obstacle)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( myEditedObject.IsNull() ) {
+ abort();
+ return;
+ }
+ else if ( myEditedObject->IsMustBeUpdated() ) {
+ myEditedObject->Update();
+ }
+
+ // Set the edited object name to the panel
+ aPanel->setName( myEditedObject->GetName() );
+
+ // Create preview
+ createPreview();
+}
+
+void HYDROGUI_TranslateObstacleOp::abortOperation()
+{
+ erasePreview();
+ abortDocOperation();
+
+ HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_TranslateObstacleOp::commitOperation()
+{
+ erasePreview();
+
+ HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_TranslateObstacleOp::createInputPanel() const
+{
+ HYDROGUI_TranslateObstacleDlg* aPanel = new HYDROGUI_TranslateObstacleDlg( module(), getName() );
+
+ connect( aPanel, SIGNAL( argumentsChanged() ), this, SLOT( onArgumentsChanged() ) );
+
+ return aPanel;
+}
+
+bool HYDROGUI_TranslateObstacleOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg )
+{
+ HYDROGUI_TranslateObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_TranslateObstacleDlg*>( inputPanel() );
+ if ( !aPanel || myEditedObject.IsNull() ) {
+ return false;
+ }
+
+ // Get the translated shape
+ TopoDS_Shape aTranslatedShape = getTranslatedShape();
+ if ( aTranslatedShape.IsNull() ) {
+ return false;
+ }
+
+ // Erase preview
+ erasePreview();
+
+ // Set the translated shape to the obstacle
+ myEditedObject->SetShape3D( aTranslatedShape );
+ myEditedObject->Update();
+
+ module()->setIsToUpdate( myEditedObject );
+
+ // Set update flags
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+
+ return true;
+}
+
+void HYDROGUI_TranslateObstacleOp::createPreview()
+{
+ if ( myEditedObject.IsNull() ) {
+ return;
+ }
+
+ // Create preview presentation if necessary
+ if ( !myPreviewPrs ) {
+ LightApp_Application* anApp = module()->getApp();
+ OCCViewer_ViewManager* aViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
+ anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+
+ if ( aViewManager ) {
+ if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() ) {
+ myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL );
+ myPreviewPrs->setFillingColor( myEditedObject->GetFillingColor(), false, false );
+ myPreviewPrs->setBorderColor( myEditedObject->GetBorderColor(), false, false );
+ }
+ }
+ }
+ }
+
+ // Get the translated shape
+ TopoDS_Shape aTranslatedShape = getTranslatedShape();
+
+ // Set the translated shape to the preview presentation
+ if ( myPreviewPrs ) {
+ myPreviewPrs->setShape( aTranslatedShape );
+ }
+}
+
+void HYDROGUI_TranslateObstacleOp::erasePreview()
+{
+ if( myPreviewPrs ) {
+ delete myPreviewPrs;
+ myPreviewPrs = 0;
+ }
+}
+
+void HYDROGUI_TranslateObstacleOp::onArgumentsChanged()
+{
+ // Update preview
+ createPreview();
+}
+
+TopoDS_Shape HYDROGUI_TranslateObstacleOp::getTranslatedShape() const
+{
+ TopoDS_Shape aTranslatedShape;
+
+ HYDROGUI_TranslateObstacleDlg* aPanel = (HYDROGUI_TranslateObstacleDlg*)inputPanel();
+ if ( aPanel && !myEditedObject.IsNull() ) {
+ double aDx = aPanel->getDx();
+ double aDy = aPanel->getDy();
+ double aDz = aPanel->getDz();
+
+ TopoDS_Shape aShape = myEditedObject->GetShape3D();
+ gp_Trsf aTrsf;
+ gp_Vec aVec( aDx, aDy, aDz );
+ aTrsf.SetTranslation(aVec);
+ TopLoc_Location aLocOrig = aShape.Location();
+ gp_Trsf aTrsfOrig = aLocOrig.Transformation();
+ TopLoc_Location aLocRes( aTrsf * aTrsfOrig );
+ aTranslatedShape = aShape.Located( aLocRes );
+ }
+
+ return aTranslatedShape;
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_TranslateObstacleOp_H
+#define HYDROGUI_TranslateObstacleOp_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Obstacle.h>
+
+class HYDROGUI_Shape;
+class TopoDS_Shape;
+
+class HYDROGUI_TranslateObstacleOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_TranslateObstacleOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_TranslateObstacleOp();
+
+protected:
+
+ virtual void startOperation();
+ virtual void abortOperation();
+ virtual void commitOperation();
+
+ virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+private slots:
+ void onArgumentsChanged();
+
+private:
+ void createPreview();
+ void erasePreview();
+
+ TopoDS_Shape getTranslatedShape() const;
+
+private:
+ Handle(HYDROData_Obstacle) myEditedObject;
+
+ HYDROGUI_Shape* myPreviewPrs;
+};
+
+#endif
<source>DSK_CREATE_CYLINDER</source>
<translation>Create cylinder obstacle</translation>
</message>
+ <message>
+ <source>DSK_TRANSLATE_OBSTACLE</source>
+ <translation>Translate obstacle</translation>
+ </message>
<message>
<source>DSK_COLOR</source>
<translation>Set object color</translation>
<source>MEN_CREATE_CYLINDER</source>
<translation>Create cylinder</translation>
</message>
+ <message>
+ <source>MEN_TRANSLATE_OBSTACLE</source>
+ <translation>Translate</translation>
+ </message>
<message>
<source>MEN_COLOR</source>
<translation>Color</translation>
<source>STB_CREATE_CYLINDER</source>
<translation>Create cylinder obstacle</translation>
</message>
+ <message>
+ <source>STB_TRANSLATE_OBSTACLE</source>
+ <translation>Translate obstacle</translation>
+ </message>
<message>
<source>STB_COLOR</source>
<translation>Set object color</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_TranslateObstacleDlg</name>
+ <message>
+ <source>OBSTACLE_NAME</source>
+ <translation>Obstacle name</translation>
+ </message>
+ <message>
+ <source>NAME</source>
+ <translation>Name</translation>
+ </message>
+ <message>
+ <source>TRANSLATION_ARGUMENTS</source>
+ <translation>Arguments</translation>
+ </message>
+ <message>
+ <source>DX</source>
+ <translation>Dx</translation>
+ </message>
+ <message>
+ <source>DY</source>
+ <translation>Dy</translation>
+ </message>
+ <message>
+ <source>DZ</source>
+ <translation>Dz</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>HYDROGUI_TranslateObstacleOp</name>
+ <message>
+ <source>TRANSLATE_OBSTACLE</source>
+ <translation>Translation of an obstacle</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_RunBrowser</name>