{
a2dShellBuilder.Add( a2dShell, aMakeFace.Face() );
}
+
+ aPrevFirstPoint = aCurFirstPoint;
+ aPrevLastPoint = aCurLastPoint;
}
SetTopShape( a2dShell );
bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
{
Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
- if ( theAxis.IsNull() || IsEqual( aPrevAxis, theAxis ) )
+
+ if ( theAxis.IsNull() )
+ {
+ RemoveHydraulicAxis();
+ return !aPrevAxis.IsNull();
+ }
+
+ if ( IsEqual( aPrevAxis, theAxis ) )
return false;
-
+
TopoDS_Wire aHydraulicWire = TopoDS::Wire( theAxis->GetShape() );
if ( aHydraulicWire.IsNull() )
return false; // The polyline must be a single wire
return;
// TODO
+ AddReferenceObject( theProfile, DataTag_Profile ); // temporary for testing only
}
void HYDROData_Stream::updateProfilesOrder()
HYDROGUI_RemoveImageRefsOp.h
HYDROGUI_Shape.h
HYDROGUI_ShowHideOp.h
+ HYDROGUI_StreamDlg.h
+ HYDROGUI_StreamOp.h
HYDROGUI_Tool.h
HYDROGUI_TwoImagesDlg.h
HYDROGUI_TwoImagesOp.h
HYDROGUI_RemoveImageRefsOp.cxx
HYDROGUI_Shape.cxx
HYDROGUI_ShowHideOp.cxx
+ HYDROGUI_StreamDlg.cxx
+ HYDROGUI_StreamOp.cxx
HYDROGUI_Tool.cxx
HYDROGUI_TwoImagesDlg.cxx
HYDROGUI_TwoImagesOp.cxx
bool anIsRegion = false;
bool anIsZone = false;
bool anIsObstacle = false;
+ bool anIsStream = false;
bool anIsGeomObject = false;
// check the selected GEOM objects
anIsVisibleInSelection |= aVisibility;
anIsHiddenInSelection |= !aVisibility;
- if( anObject->GetKind() == KIND_IMAGE )
+ ObjectKind anObjectKind = anObject->GetKind();
+ if( anObjectKind == KIND_IMAGE )
{
anIsImage = true;
Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
}
}
}
- else if( anObject->GetKind() == KIND_POLYLINEXY )
+ else if( anObjectKind == KIND_POLYLINEXY )
anIsPolyline = true;
- else if( anObject->GetKind() == KIND_POLYLINE )
+ else if( anObjectKind == KIND_POLYLINE )
anIsPolyline3D = true;
- else if( anObject->GetKind() == KIND_PROFILE ) {
+ else if( anObjectKind == KIND_PROFILE )
+ {
anIsProfile = true;
aNbOfSelectedProfiles++;
anIsValidProfile = true;
}
}
- else if( anObject->GetKind() == KIND_CALCULATION )
+ else if( anObjectKind == KIND_CALCULATION )
anIsCalculation = true;
- else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
+ else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
anIsImmersibleZone = true;
- else if( anObject->GetKind() == KIND_VISUAL_STATE )
+ else if( anObjectKind == KIND_VISUAL_STATE )
anIsVisualState = true;
- else if( anObject->GetKind() == KIND_REGION )
+ else if( anObjectKind == KIND_REGION )
anIsRegion = true;
- else if( anObject->GetKind() == KIND_ZONE )
+ else if( anObjectKind == KIND_ZONE )
anIsZone = true;
- else if( anObject->GetKind() == KIND_BATHYMETRY )
+ else if( anObjectKind == KIND_BATHYMETRY )
anIsBathymetry = true;
- else if( anObject->GetKind() == KIND_OBSTACLE )
+ else if( anObjectKind == KIND_OBSTACLE )
anIsObstacle = true;
+ else if( anObjectKind == KIND_STREAM )
+ anIsStream = true;
}
anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
theMenu->addAction( action( EditImmersibleZoneId ) );
theMenu->addSeparator();
}
+ else if( anIsStream )
+ {
+ theMenu->addAction( action( EditStreamId ) );
+ theMenu->addSeparator();
+ }
else if( anIsVisualState && anIsObjectBrowser )
{
theMenu->addAction( action( SaveVisualStateId ) );
theMenu->addSeparator();
if( anIsImage || anIsPolyline || anIsPolyline3D || anIsImmersibleZone || anIsZone ||
- anIsRegion || anIsBathymetry || anIsObstacle || anIsValidProfile )
+ anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || anIsValidProfile )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
void HYDROGUI_Operation::startDocOperation()
{
// Open transaction in the model document
- doc()->StartOperation();
+ if ( !doc()->IsOperation() )
+ doc()->StartOperation();
}
void HYDROGUI_Operation::abortDocOperation()
{
// Abort transaction in the model document
- doc()->AbortOperation();
+ if ( doc()->IsOperation() )
+ doc()->AbortOperation();
}
void HYDROGUI_Operation::commitDocOperation()
{
// Commit transaction in the model document
- doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
+ if ( doc()->IsOperation() )
+ doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
}
Handle_HYDROData_Document HYDROGUI_Operation::doc() const
#include "HYDROGUI_ProfileOp.h"
#include "HYDROGUI_RemoveImageRefsOp.h"
#include "HYDROGUI_ShowHideOp.h"
-#include "HYDROData_SplitToZonesTool.h"
+#include "HYDROGUI_StreamOp.h"
#include "HYDROGUI_TwoImagesOp.h"
#include "HYDROGUI_UpdateFlags.h"
#include "HYDROGUI_UpdateImageOp.h"
#include "HYDROGUI_GeoreferencementOp.h"
#include "HYDROGUI_SetColorOp.h"
-#include "HYDROData_Document.h"
-#include "HYDROData_Obstacle.h"
+#include <HYDROData_Document.h>
+#include <HYDROData_Obstacle.h>
+#include <HYDROData_SplitToZonesTool.h>
#include <GeometryGUI.h>
#include <GeometryGUI_Operations.h>
createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE" );
createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE" );
+ createAction( CreateStreamId, "CREATE_STREAM" );
+ createAction( EditStreamId, "EDIT_STREAM" );
+
createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE" );
createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT" );
createAction( CreateBoxId, "CREATE_BOX" );
createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
+ createMenu( CreateStreamId, aHydroId, -1, -1 );
int aNewObstacleId = createMenu( tr( "MEN_OBSTACLE" ), aHydroId, -1 );
createMenu( ImportObstacleFromFileId, aNewObstacleId, -1, -1 );
case EditImmersibleZoneId:
anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
break;
+ case CreateStreamId:
+ case EditStreamId:
+ anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
+ break;
case CreateCalculationId:
case EditCalculationId:
anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
CreateImmersibleZoneId,
EditImmersibleZoneId,
+ CreateStreamId,
+ EditStreamId,
+
CreateCalculationId,
EditCalculationId,
ExportCalculationId,
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_Obstacle.h>
#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Profile.h>
#include <HYDROData_Region.h>
+#include <HYDROData_Stream.h>
#include <HYDROData_Zone.h>
-#include <HYDROData_Obstacle.h>
-#include <HYDROData_Profile.h>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
TopoDS_Face aZoneFace = TopoDS::Face( aZone->GetShape() );
- // Generate the filling color for zone
- QStringList aGeomObjectsNames;
-
- HYDROData_SequenceOfObjects aRefObjects = aZone->GetGeometryObjects();
- HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects );
- for ( ; anIter.More(); anIter.Next() )
- {
- Handle(HYDROData_Object) aRefbject =
- Handle(HYDROData_Object)::DownCast( anIter.Value() );
- if ( aRefbject.IsNull() )
- continue;
-
- QString aRefObjectName = aRefbject->GetName();
- if ( aRefObjectName.isEmpty() )
- continue;
-
- aGeomObjectsNames.append( aRefObjectName );
- }
-
setFace( aZoneFace, false, false );
if (aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN )
{
}
else
{
+ // Generate the filling color for zone
+ QStringList aGeomObjectsNames;
+
+ HYDROData_SequenceOfObjects aRefObjects = aZone->GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Object) aRefbject =
+ Handle(HYDROData_Object)::DownCast( anIter.Value() );
+ if ( aRefbject.IsNull() )
+ continue;
+
+ QString aRefObjectName = aRefbject->GetName();
+ if ( aRefObjectName.isEmpty() )
+ continue;
+
+ aGeomObjectsNames.append( aRefObjectName );
+ }
+
setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
}
}
setWire( aProfileWire, false, false );
}
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) )
+ {
+ Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream)::DownCast( myObject );
+
+ TopoDS_Shell aStreamShape = TopoDS::Shell( aStream->GetTopShape() );
+
+ setShape( aStreamShape, false, false );
+ }
}
if ( myShape.IsNull() || !isVisible() )
--- /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_StreamDlg.h"
+
+#include "HYDROGUI_Tool.h"
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QListWidget>
+
+HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+ // Stream name
+ myObjectNameGroup = new QGroupBox( tr( "STREAM_NAME" ), mainFrame() );
+
+ myObjectName = new QLineEdit( myObjectNameGroup );
+
+ QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
+ aNameLayout->setMargin( 5 );
+ aNameLayout->setSpacing( 5 );
+ aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
+ aNameLayout->addWidget( myObjectName );
+
+ // Stream parameters
+ QGroupBox* aParamGroup = new QGroupBox( tr( "STREAM_PARAMETERS" ), mainFrame() );
+
+ myAxises = new QComboBox( aParamGroup );
+ myAxises->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ myProfiles = new QListWidget( aParamGroup );
+ myProfiles->setSelectionMode( QListWidget::SingleSelection );
+ myProfiles->setEditTriggers( QListWidget::NoEditTriggers );
+ myProfiles->setViewMode( QListWidget::ListMode );
+ myProfiles->setSortingEnabled( false );
+
+ QGridLayout* aParamLayout = new QGridLayout( aParamGroup );
+ aParamLayout->setMargin( 5 );
+ aParamLayout->setSpacing( 5 );
+ aParamLayout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ), aParamGroup ), 0, 0 );
+ aParamLayout->addWidget( myAxises, 0, 1 );
+ aParamLayout->addWidget( myProfiles, 1, 0, 1, 2 );
+
+ // Common
+ addWidget( myObjectNameGroup );
+ addWidget( aParamGroup );
+
+ addStretch();
+
+ // Connect signals and slots
+ connect( myAxises, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onStreamDefChanged() ) );
+}
+
+HYDROGUI_StreamDlg::~HYDROGUI_StreamDlg()
+{
+}
+
+void HYDROGUI_StreamDlg::reset()
+{
+ bool isBlocked = blockSignals( true );
+
+ myObjectName->clear();
+
+ myAxises->clear();
+ myProfiles->clear();
+
+ blockSignals( isBlocked );
+
+ onStreamDefChanged();
+}
+
+void HYDROGUI_StreamDlg::setObjectName( const QString& theName )
+{
+ myObjectName->setText( theName );
+}
+
+QString HYDROGUI_StreamDlg::getObjectName() const
+{
+ return myObjectName->text();
+}
+
+void HYDROGUI_StreamDlg::setAxisNames( const QStringList& theAxises )
+{
+ bool isBlocked = blockSignals( true );
+
+ myAxises->clear();
+ myAxises->addItems( theAxises );
+
+ blockSignals( isBlocked );
+}
+
+void HYDROGUI_StreamDlg::setAxisName( const QString& theName )
+{
+ int aNewIdx = myAxises->findText( theName );
+ if ( aNewIdx != myAxises->currentIndex() )
+ {
+ myAxises->setCurrentIndex( aNewIdx );
+ }
+ else
+ {
+ onStreamDefChanged();
+ }
+}
+
+QString HYDROGUI_StreamDlg::getAxisName() const
+{
+ return myAxises->currentText();
+}
+
+void HYDROGUI_StreamDlg::setSelectedProfiles( const QStringList& theProfiles )
+{
+ bool isBlocked = blockSignals( true );
+
+ myProfiles->setUpdatesEnabled( false );
+
+ myProfiles->clear();
+ for ( int i = 0, n = theProfiles.length(); i < n; ++i )
+ {
+ const QString& aProfileName = theProfiles.at( i );
+ QListWidgetItem* aListItem = new QListWidgetItem( aProfileName, myProfiles );
+ aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+ }
+
+ myProfiles->setUpdatesEnabled( true );
+
+ blockSignals( isBlocked );
+
+ onStreamDefChanged();
+}
+
+QStringList HYDROGUI_StreamDlg::getSelectedProfiles() const
+{
+ QStringList aProfiles;
+
+ for ( int i = 0, n = myProfiles->count(); i < n; ++i )
+ {
+ QListWidgetItem* aListItem = myProfiles->item( i );
+ if ( !aListItem )
+ continue;
+
+ QString aProfileName = aListItem->text();
+ aProfiles << aProfileName;
+ }
+
+ return aProfiles;
+}
+
+void HYDROGUI_StreamDlg::onStreamDefChanged()
+{
+ if ( signalsBlocked() )
+ return;
+
+ emit CreatePreview();
+}
--- /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_StreamDlg_H
+#define HYDROGUI_StreamDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QComboBox;
+class QGroupBox;
+class QLineEdit;
+class QListWidget;
+
+class HYDROGUI_StreamDlg : public HYDROGUI_InputPanel
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+ virtual ~HYDROGUI_StreamDlg();
+
+ void reset();
+
+ void setObjectName( const QString& theName );
+ QString getObjectName() const;
+
+ void setAxisNames( const QStringList& theAxises );
+ void setAxisName( const QString& thePolyline );
+ QString getAxisName() const;
+
+ void setSelectedProfiles( const QStringList& theProfiles );
+ QStringList getSelectedProfiles() const;
+
+signals:
+ void CreatePreview();
+
+private slots:
+ void onStreamDefChanged();
+
+private:
+
+ QGroupBox* myObjectNameGroup;
+ QLineEdit* myObjectName;
+
+ QComboBox* myAxises;
+ QListWidget* myProfiles;
+};
+
+#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_StreamOp.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_StreamDlg.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Profile.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+
+HYDROGUI_StreamOp::HYDROGUI_StreamOp( HYDROGUI_Module* theModule, bool theIsEdit )
+: HYDROGUI_Operation( theModule ),
+ myIsEdit( theIsEdit ),
+ myViewManager( NULL ),
+ myPreviewPrs( NULL )
+{
+ setName( theIsEdit ? tr( "EDIT_STREAM" ) : tr( "CREATE_STREAM" ) );
+}
+
+HYDROGUI_StreamOp::~HYDROGUI_StreamOp()
+{
+ erasePreview();
+}
+
+void HYDROGUI_StreamOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ // We start operation in the document
+ startDocOperation();
+
+ HYDROGUI_StreamDlg* aPanel = (HYDROGUI_StreamDlg*)inputPanel();
+
+ aPanel->blockSignals( true );
+
+ aPanel->reset();
+
+ if( myIsEdit )
+ myEditedObject = Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ else
+ myEditedObject = Handle(HYDROData_Stream)::DownCast( doc()->CreateObject( KIND_STREAM ) );
+
+ QString aSelectedAxis;
+ QStringList aSelectedProfiles;
+
+ QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STREAM_NAME" ) );
+ if ( myIsEdit && !myEditedObject.IsNull() )
+ {
+ anObjectName = myEditedObject->GetName();
+
+ Handle(HYDROData_PolylineXY) aHydraulicAxis = myEditedObject->GetHydraulicAxis();
+ if ( !aHydraulicAxis.IsNull() )
+ aSelectedAxis = aHydraulicAxis->GetName();
+
+ HYDROData_SequenceOfObjects aProfiles = myEditedObject->GetProfiles();
+ for ( int i = 1, n = aProfiles.Length(); i <= n; ++i )
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aProfiles.Value( i ) );
+ if ( aProfile.IsNull() )
+ continue;
+
+ QString aProfileName = aProfile->GetName();
+ aSelectedProfiles << aProfileName;
+ }
+ }
+
+ QStringList anAxises = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY );
+
+ // Temporary, to be removed
+ if ( aSelectedProfiles.isEmpty() )
+ {
+ aSelectedProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE );
+ }
+
+ aPanel->setObjectName( anObjectName );
+ aPanel->setAxisNames( anAxises );
+ aPanel->setAxisName( aSelectedAxis );
+ aPanel->setSelectedProfiles( aSelectedProfiles );
+
+ aPanel->blockSignals( false );
+
+ onCreatePreview();
+}
+
+void HYDROGUI_StreamOp::abortOperation()
+{
+ erasePreview();
+ abortDocOperation();
+
+ HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_StreamOp::commitOperation()
+{
+ erasePreview();
+
+ HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const
+{
+ HYDROGUI_StreamDlg* aPanel = new HYDROGUI_StreamDlg( module(), getName() );
+ connect( aPanel, SIGNAL( CreatePreview() ), this, SLOT( onCreatePreview() ) );
+ return aPanel;
+}
+
+bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg )
+{
+ HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
+ if ( !aPanel )
+ return false;
+
+ QString anObjectName = aPanel->getObjectName().simplified();
+ if ( anObjectName.isEmpty() )
+ {
+ theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+ return false;
+ }
+
+ if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+ {
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+ if( !anObject.IsNull() )
+ {
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+ return false;
+ }
+ }
+
+ if ( myEditedObject.IsNull() )
+ return false;
+
+ myEditedObject->SetName( anObjectName );
+
+ erasePreview();
+
+ if( !myIsEdit )
+ module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+
+ return true;
+}
+
+void HYDROGUI_StreamOp::onCreatePreview()
+{
+ HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QString anAxisName = aPanel->getAxisName();
+ QStringList aProfiles = aPanel->getSelectedProfiles();
+ if ( anAxisName.isEmpty() || aProfiles.isEmpty() )
+ {
+ erasePreview();
+ return;
+ }
+
+ if ( myEditedObject.IsNull() )
+ return;
+
+ // At first we remove all references from stream
+ myEditedObject->RemoveProfiles();
+
+ Handle(HYDROData_PolylineXY) anAxis = Handle(HYDROData_PolylineXY)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), anAxisName, KIND_POLYLINEXY ) );
+ myEditedObject->SetHydraulicAxis( anAxis );
+
+ HYDROData_SequenceOfObjects aProfileObjects =
+ HYDROGUI_Tool::FindObjectsByNames( module(), aProfiles, KIND_PROFILE );
+ for ( int i = 1, n = aProfileObjects.Length(); i <= n; ++i )
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aProfileObjects.Value( i ) );
+ if ( aProfile.IsNull() )
+ continue;
+
+ myEditedObject->AddProfile( aProfile );
+ }
+
+ myEditedObject->Update();
+
+
+ LightApp_Application* anApp = module()->getApp();
+ if ( !myViewManager )
+ myViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
+ anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+
+ if ( myViewManager && !myPreviewPrs )
+ {
+ if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ myPreviewPrs = new HYDROGUI_Shape( aCtx, myEditedObject );
+ }
+ }
+
+ if ( !myViewManager || !myPreviewPrs )
+ return;
+
+ myPreviewPrs->update();
+}
+
+void HYDROGUI_StreamOp::erasePreview()
+{
+ if( myPreviewPrs )
+ {
+ delete myPreviewPrs;
+ myPreviewPrs = 0;
+ }
+}
--- /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_StreamOp_H
+#define HYDROGUI_StreamOp_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Stream.h>
+
+class OCCViewer_ViewManager;
+class HYDROGUI_Shape;
+
+class HYDROGUI_StreamOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_StreamOp( HYDROGUI_Module* theModule, bool isEdit );
+ virtual ~HYDROGUI_StreamOp();
+
+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 onCreatePreview();
+
+private:
+ void erasePreview();
+
+private:
+ OCCViewer_ViewManager* myViewManager;
+
+ bool myIsEdit;
+ Handle(HYDROData_Stream) myEditedObject;
+
+ HYDROGUI_Shape* myPreviewPrs;
+};
+
+#endif
<source>DSK_EDIT_IMMERSIBLE_ZONE</source>
<translation>Edit immersible zone</translation>
</message>
+ <message>
+ <source>DSK_CREATE_STREAM</source>
+ <translation>Create stream</translation>
+ </message>
+ <message>
+ <source>DSK_EDIT_STREAM</source>
+ <translation>Edit stream</translation>
+ </message>
<message>
<source>DSK_COPY</source>
<translation>Copy</translation>
<source>MEN_EDIT_IMMERSIBLE_ZONE</source>
<translation>Edit immersible zone</translation>
</message>
+ <message>
+ <source>MEN_CREATE_STREAM</source>
+ <translation>Create stream</translation>
+ </message>
+ <message>
+ <source>MEN_EDIT_STREAM</source>
+ <translation>Edit stream</translation>
+ </message>
<message>
<source>MEN_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>STB_EDIT_IMMERSIBLE_ZONE</source>
<translation>Edit immersible zone</translation>
</message>
+ <message>
+ <source>STB_CREATE_STREAM</source>
+ <translation>Create stream</translation>
+ </message>
+ <message>
+ <source>STB_EDIT_STREAM</source>
+ <translation>Edit stream</translation>
+ </message>
<message>
<source>STB_COPY</source>
<translation>Copy</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_StreamDlg</name>
+ <message>
+ <source>NAME</source>
+ <translation>Name</translation>
+ </message>
+ <message>
+ <source>STREAM_NAME</source>
+ <translation>Stream name</translation>
+ </message>
+ <message>
+ <source>STREAM_PARAMETERS</source>
+ <translation>Parameters</translation>
+ </message>
+ <message>
+ <source>STREAM_HYDRAULIC_AXIS</source>
+ <translation>Hydraulic axis</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>HYDROGUI_StreamOp</name>
+ <message>
+ <source>CREATE_STREAM</source>
+ <translation>Create stream</translation>
+ </message>
+ <message>
+ <source>EDIT_STREAM</source>
+ <translation>Edit stream</translation>
+ </message>
+ <message>
+ <source>DEFAULT_STREAM_NAME</source>
+ <translation>Stream</translation>
+ </message>
+ </context>
+
</TS>