Implementation of GUI part.
HYDROGUI_ImportGeomObjectOp.h
HYDROGUI_ImportObstacleFromFileOp.h
HYDROGUI_ExportCalculationOp.h
- HYDROGUI_ObstacleDlg.h
+ HYDROGUI_GeomObjectDlg.h
HYDROGUI_SetColorOp.h
HYDROGUI_ColorDlg.h
HYDROGUI_ImportProfilesOp.h
HYDROGUI_ImportGeomObjectOp.cxx
HYDROGUI_ImportObstacleFromFileOp.cxx
HYDROGUI_ExportCalculationOp.cxx
- HYDROGUI_ObstacleDlg.cxx
+ HYDROGUI_GeomObjectDlg.cxx
HYDROGUI_SetColorOp.cxx
HYDROGUI_ColorDlg.cxx
HYDROGUI_ImportProfilesOp.cxx
#include "HYDROGUI_ImportGeomObjectOp.h"
-#include "HYDROGUI_ObstacleDlg.h"
+#include "HYDROGUI_GeomObjectDlg.h"
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_UpdateFlags.h"
#include <HYDROData_Obstacle.h>
+#include <HYDROData_PolylineXY.h>
#include <HYDROData_Iterator.h>
#include <GEOMBase.h>
myOpType ( theOpType ),
myIsToShowPanel ( theIsToShowPanel )
{
- setName( tr( "IMPORT_GEOM_OBJECT" ) );
+ if ( myOpType == ImportSelectedAsPolyline ) {
+ setName( tr( "IMPORT_GEOM_OBJECT_AS_POLYLINE" ) );
+ } else {
+ setName( tr( "IMPORT_GEOM_OBJECT_AS_OBSTACLE" ) );
+ }
}
HYDROGUI_ImportGeomObjectOp::~HYDROGUI_ImportGeomObjectOp()
// Get GEOM objects to import
myGeomObjects.clear();
- if ( myOpType == ImportCreated ) {
+ if ( myOpType == ImportCreatedAsObstacle ) {
myGeomObjects = module()->GetGeomObjectsToImport();
- } else if ( myOpType == ImportSelected ) {
- myGeomObjects = HYDROGUI_Tool::GetSelectedGeomObjects( module() );
+ } else if ( myOpType == ImportSelectedAsObstacle ) {
+ myGeomObjects =
+ HYDROGUI_Tool::GetSelectedGeomObjects( module(), getObstacleTypes() );
+ } else if ( myOpType == ImportSelectedAsPolyline ) {
+ myGeomObjects =
+ HYDROGUI_Tool::GetSelectedGeomObjects( module(), getPolylineTypes() );
}
- HYDROGUI_ObstacleDlg* aPanel = 0;
+ HYDROGUI_GeomObjectDlg* aPanel = 0;
if ( myGeomObjects.count() == 1 ) {
// Get panel
- aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+ aPanel = ::qobject_cast<HYDROGUI_GeomObjectDlg*>( inputPanel() );
if ( aPanel ) {
// Reset the panel state
}
}
- // Pass the existing obstacle names to the panel
- QStringList anObstacles =
- HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_OBSTACLE );
+ // Pass the existing object names to the panel
+ QStringList anExistingNames;
+ if ( myOpType == ImportCreatedAsObstacle ||
+ myOpType == ImportSelectedAsObstacle ) {
+ anExistingNames = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_OBSTACLE );
+ } else if ( myOpType == ImportSelectedAsPolyline ) {
+ anExistingNames = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY );
+ }
- aPanel->setObstacleNames( anObstacles );
+ aPanel->setObjectNames( anExistingNames );
}
}
return false;
}
- QString anObstacleName;
- Handle(HYDROData_Obstacle) anObstacleToEdit;
+ QString anObjectName;
+ Handle(HYDROData_Entity) anObjectToEdit;
+ ObjectKind anObjectKind =
+ myOpType == ImportSelectedAsPolyline ? KIND_POLYLINEXY : KIND_OBSTACLE;
if ( myGeomObjects.count() == 1 ) {
// Get panel
- HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+ HYDROGUI_GeomObjectDlg* aPanel = ::qobject_cast<HYDROGUI_GeomObjectDlg*>( inputPanel() );
if ( aPanel ) {
- // Check obstacle name
- anObstacleName = aPanel->getObstacleName().simplified();
- if ( anObstacleName.isEmpty() ) {
+ // Check object name
+ anObjectName = aPanel->getObjectName().simplified();
+ if ( anObjectName.isEmpty() ) {
theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
return false;
}
- // Get obstacle to edit
- QString anEditedName = aPanel->getEditedObstacleName().simplified();
+ // Get object to edit
+ QString anEditedName = aPanel->getEditedObjectName().simplified();
if ( !anEditedName.isEmpty() ) {
- anObstacleToEdit = Handle(HYDROData_Obstacle)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), anEditedName, KIND_OBSTACLE ) );
+ anObjectToEdit = HYDROGUI_Tool::FindObjectByName( module(), anEditedName, anObjectKind );
}
}
- if( anObstacleToEdit.IsNull() || anObstacleToEdit->GetName() != anObstacleName ) {
+ if( anObjectToEdit.IsNull() || anObjectToEdit->GetName() != anObjectName ) {
// check that there are no other objects with the same name in the document
- Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObstacleName );
+ Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName/*, anObjectKind*/ );
if( !anObject.IsNull() ) {
- theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObstacleName );
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
return false;
}
}
bool anIsOk = false;
- // Get the created object as SObject
+ // Get the GEOM object as SObject
foreach ( const QString& anEntry, myGeomObjects ) {
_PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID( qPrintable(anEntry)) );
- if (aSObject) {
+ if ( aSObject ) {
// Get the corresponding TopoDS_Shape
TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( aSObject->GetIOR().c_str() );
- if ( !aShape.IsNull() ) {
- // Create/edit an obstacle object
- Handle(HYDROData_Obstacle) anObstacle;
+ if ( aShape.IsNull() ) {
+ continue;
+ }
+
+ // Create/edit an object
+ Handle(HYDROData_Entity) anObject;
- if ( anObstacleToEdit.IsNull() ) {
- anObstacle =
+ if ( anObjectToEdit.IsNull() ) {
+ if ( myOpType == ImportCreatedAsObstacle || myOpType == ImportSelectedAsObstacle ) {
+ anObject =
Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
-
+ Handle(HYDROData_Obstacle) anObstacle = Handle(HYDROData_Obstacle)::DownCast( anObject );
anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() );
anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() );
- } else {
- anObstacle = anObstacleToEdit;
+ } else if ( myOpType == ImportSelectedAsPolyline ) {
+ anObject =
+ Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject(KIND_POLYLINEXY) );
}
+ } else {
+ anObject = anObjectToEdit;
+ }
- // Set name
- if ( anObstacleName.isEmpty() ) {
- QString aName = QString::fromStdString( aSObject->GetName() );
- anObstacleName = HYDROGUI_Tool::GenerateObjectName(
- module(), aName, QStringList(), true );
- }
- if ( anObstacle->GetName() != anObstacleName ) {
- anObstacle->SetName( anObstacleName );
- }
+ // Set name
+ if ( anObjectName.isEmpty() ) {
+ QString aName = QString::fromStdString( aSObject->GetName() );
+ anObjectName = HYDROGUI_Tool::GenerateObjectName(
+ module(), aName, QStringList(), true );
+ }
+ if ( anObject->GetName() != anObjectName ) {
+ anObject->SetName( anObjectName );
+ }
- anObstacleName.clear();
+ anObjectName.clear();
- // Set shape
+ // Set shape
+ if ( myOpType == ImportCreatedAsObstacle || myOpType == ImportSelectedAsObstacle ) {
+ Handle(HYDROData_Obstacle) anObstacle = Handle(HYDROData_Obstacle)::DownCast( anObject );
anObstacle->SetShape3D( aShape );
-
- anObstacle->Update();
-
- // Set operation status
anIsOk = true;
+ } else if ( myOpType == ImportSelectedAsPolyline ) {
+ Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( anObject );
+ // TODO ISSUE #228: set the shape ("aShape") to the polyline
+ // anIsOk = aPolyline->setShape( aShape );
+ }
+
+ // Check operation status
+ if ( anIsOk ) {
+ anObject->Update();
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
}
}
{
HYDROGUI_InputPanel* aPanel = 0;
if ( myIsToShowPanel ) {
- aPanel = new HYDROGUI_ObstacleDlg( module(), getName() );
+ QString anObjectTypeName =
+ myOpType == ImportSelectedAsPolyline ? tr("DEFAULT_POLYLINE_NAME") :
+ tr("DEFAULT_OBSTACLE_NAME");
+ aPanel = new HYDROGUI_GeomObjectDlg( module(), getName(), anObjectTypeName );
}
return aPanel;
+}
+
+QList<GEOM::shape_type> HYDROGUI_ImportGeomObjectOp::getObstacleTypes()
+{
+ QList<GEOM::shape_type> aTypes;
+
+ aTypes << GEOM::COMPOUND << GEOM::COMPOUND << GEOM::SOLID <<
+ GEOM::SHELL << GEOM::FACE << GEOM::SHAPE;
+
+ return aTypes;
+}
+
+QList<GEOM::shape_type> HYDROGUI_ImportGeomObjectOp::getPolylineTypes()
+{
+ QList<GEOM::shape_type> aTypes;
+
+ aTypes << GEOM::WIRE << GEOM::EDGE;
+
+ return aTypes;
}
\ No newline at end of file
#include <QStringList>
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
class HYDROGUI_InputPanel;
class HYDROGUI_ImportGeomObjectOp : public HYDROGUI_Operation
Q_OBJECT
public:
- enum OperationType { ImportCreated, ImportSelected };
+ enum OperationType { ImportCreatedAsObstacle,
+ ImportSelectedAsObstacle,
+ ImportSelectedAsPolyline };
public:
HYDROGUI_ImportGeomObjectOp( HYDROGUI_Module* theModule,
const bool theIsToShowPanel = true );
virtual ~HYDROGUI_ImportGeomObjectOp();
+ static QList<GEOM::shape_type> getObstacleTypes();
+ static QList<GEOM::shape_type> getPolylineTypes();
+
protected:
virtual void startOperation();
virtual void abortOperation();
#include "HYDROGUI_ImportObstacleFromFileOp.h"
-#include "HYDROGUI_ObstacleDlg.h"
+#include "HYDROGUI_GeomObjectDlg.h"
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
HYDROGUI_Operation::startOperation();
// Get panel
- HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+ HYDROGUI_GeomObjectDlg* aPanel = ::qobject_cast<HYDROGUI_GeomObjectDlg*>( inputPanel() );
if ( aPanel ) {
// Reset the panel state
aPanel->reset();
// Pass the existing obstacle names to the panel
- QStringList anObstacles =
+ QStringList anObstacleNames =
HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_OBSTACLE );
- aPanel->setObstacleNames( anObstacles );
+ aPanel->setObjectNames( anObstacleNames );
} else {
myFileDlg = new SUIT_FileDlg( module()->getApp()->desktop(), true );
myFileDlg->setWindowTitle( getName() );
Handle(HYDROData_Obstacle) anObstacle;
// Get panel
- HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+ HYDROGUI_GeomObjectDlg* aPanel = ::qobject_cast<HYDROGUI_GeomObjectDlg*>( inputPanel() );
if ( aPanel ) {
// Get file name and obstacle name defined by the user
aFileName = aPanel->getFileName();
- QString anEditedName = aPanel->getEditedObstacleName().simplified();
+ QString anEditedName = aPanel->getEditedObjectName().simplified();
// Get obstacle to edit
if ( !anEditedName.isEmpty() ) {
}
// Check obstacle name
- anObstacleName = aPanel->getObstacleName().simplified();
+ anObstacleName = aPanel->getObjectName().simplified();
if ( anObstacleName.isEmpty() ) {
theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
return false;
{
HYDROGUI_InputPanel* aPanel = 0;
if ( myIsToShowPanel ) {
- aPanel = new HYDROGUI_ObstacleDlg( module(), getName(), true );
+ aPanel = new HYDROGUI_GeomObjectDlg( module(), getName(),
+ tr( "DEFAULT_OBSTACLE_NAME" ), true );
}
return aPanel;
#include "HYDROGUI_AbstractDisplayer.h"
#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_SetColorOp.h"
+#include "HYDROGUI_ImportGeomObjectOp.h"
#include <HYDROData_Image.h>
#include <HYDROData_Profile.h>
bool anIsDummyObject3D = false;
bool anIsObjectCanBeColored = false;
- // check the selected GEOM objects
- if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
- theMenu->addAction( action( ImportGeomObjectId ) );
- theMenu->addSeparator();
+ // Check the selected GEOM objects (take into account the Object Browser only)
+ if ( anIsObjectBrowser ) {
+ QList<GEOM::shape_type> anObstacleTypes =
+ HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
+ QList<GEOM::shape_type> aPolylineTypes =
+ HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
+
+ bool isCanBeImportedAsObstacle =
+ !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
+ bool isCanBeImportedAsPolyline =
+ !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
+
+ // Add import as obstacle action
+ if ( isCanBeImportedAsObstacle ) {
+ theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
+ }
+ // Add import as polyline action
+ if ( isCanBeImportedAsPolyline ) {
+ theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
+ }
+ // Add separator
+ if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
+ theMenu->addSeparator();
+ }
}
// check the selected data model objects
createAction( EditDigueId, "EDIT_DIGUE", "EDIT_DIGUE_ICO" );
createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
- createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT", "IMPORT_GEOM_OBJECT_ICO" );
+ createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
+ 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" );
anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
break;
case ImportCreatedPrimitiveId:
- anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportCreated );
+ anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle );
break;
- case ImportGeomObjectId:
- anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelected );
+ case ImportGeomObjectAsObstacleId:
+ anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
+ break;
+ case ImportGeomObjectAsPolylineId:
+ anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
break;
case CreateBoxId:
application()->activateOperation( "Geometry", GEOMOp::OpBox );
bool HYDROGUI_Module::reusableOperation( const int id )
{
- if ( id == ImportGeomObjectId ) {
+ if ( id == ImportGeomObjectAsObstacleId ||
+ id == ImportGeomObjectAsPolylineId ) {
return false;
}
EditSplittedImageId,
ImportObstacleFromFileId,
- ImportGeomObjectId,
+ ImportGeomObjectAsObstacleId,
+ ImportGeomObjectAsPolylineId,
ImportCreatedPrimitiveId,
CreateBoxId,
CreateCylinderId,
return KIND_UNKNOWN;
}
-QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule )
+QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule,
+ QList<GEOM::shape_type> theTypes )
{
QStringList anEntryList;
GEOM::GEOM_Object_var aGeomObj =
GEOMBase::GetObjectFromIOR( aSObject->GetIOR().c_str() );
- if ( !aGeomObj->_is_nil() && aGeomObj->IsShape() ) {
+ if ( !aGeomObj->_is_nil() && aGeomObj->IsShape() &&
+ theTypes.contains( aGeomObj->GetShapeType() ) ) {
anEntryList << anEntry;
}
}
#include <TCollection_HAsciiString.hxx>
#include <TCollection_HExtendedString.hxx>
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
class SUIT_ViewManager;
class OCCViewer_ViewFrame;
/**
* \brief Get the selected GEOM objects.
* \param theModule module
+ * \param theTypes the acceptable GEOM object types
* \return list of GEOM objects entries
*/
- static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule );
+ static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule,
+ QList<GEOM::shape_type> theTypes );
/**
* \brief Find the data object with the specified name.
<source>DEFAULT_POLYLINE_NAME</source>
<translation>Polyline</translation>
</message>
+ <message>
+ <source>DEFAULT_OBSTACLE_NAME</source>
+ <translation>Obstacle</translation>
+ </message>
<message>
<source>DEFAULT_POLYLINE_3D_NAME</source>
<translation>Polyline3D</translation>
<source>OBJECT_EXISTS_IN_DOCUMENT</source>
<translation>Object with name '%1' already exists in the document.</translation>
</message>
- <message>
- <source>ZONE_OBJECT_CANNOT_BE_CREATED</source>
- <translation>Zone can not be created</translation>
- </message>
<message>
<source>SAVE_ERROR</source>
<translation>Study could not be saved</translation>
<translation>Create box obstacle</translation>
</message>
<message>
- <source>DSK_IMPORT_GEOM_OBJECT</source>
- <translation>Import GEOM object as an obstacle</translation>
+ <source>DSK_IMPORT_GEOM_OBJECT_AS_OBSTACLE</source>
+ <translation>Import GEOM object(s) as obstacle(s)</translation>
+ </message>
+ <message>
+ <source>DSK_IMPORT_GEOM_OBJECT_AS_POLYLINE</source>
+ <translation>Import GEOM object(s) as polyline(s)</translation>
</message>
<message>
<source>DSK_CREATE_CYLINDER</source>
<translation>Import obstacle</translation>
</message>
<message>
- <source>MEN_IMPORT_GEOM_OBJECT</source>
- <translation>Import</translation>
+ <source>MEN_IMPORT_GEOM_OBJECT_AS_OBSTACLE</source>
+ <translation>Import as obstacle</translation>
+ </message>
+ <message>
+ <source>MEN_IMPORT_GEOM_OBJECT_AS_POLYLINE</source>
+ <translation>Import as polyline</translation>
</message>
<message>
<source>MEN_CREATE_BOX</source>
<translation>Import obstacle from file</translation>
</message>
<message>
- <source>STB_IMPORT_GEOM_OBJECT</source>
- <translation>Import GEOM object as an obstacle</translation>
+ <source>STB_IMPORT_GEOM_OBJECT_AS_OBSTACLE</source>
+ <translation>Import GEOM object(s) as obstacle(s)</translation>
+ </message>
+ <message>
+ <source>STB_IMPORT_GEOM_OBJECT_AS_POLYLINE</source>
+ <translation>Import GEOM object(s) as polyline(s)</translation>
</message>
<message>
<source>STB_CREATE_BOX</source>
<context>
<name>HYDROGUI_ImportGeomObjectOp</name>
<message>
- <source>IMPORT_GEOM_OBJECT</source>
- <translation>Import GEOM object</translation>
+ <source>IMPORT_GEOM_OBJECT_AS_OBSTACLE</source>
+ <translation>Import GEOM object as obstacle</translation>
+ </message>
+ <message>
+ <source>IMPORT_GEOM_OBJECT_AS_POLYLINE</source>
+ <translation>Import GEOM object as polyline</translation>
</message>
</context>
</context>
<context>
- <name>HYDROGUI_ObstacleDlg</name>
- <message>
- <source>DEFAULT_OBSTACLE_NAME</source>
- <translation>Obstacle</translation>
- </message>
+ <name>HYDROGUI_GeomObjectDlg</name>
<message>
<source>GET_SHAPE_FROM_FILE</source>
<translation>Get shape from file</translation>
<translation>File name</translation>
</message>
<message>
- <source>OBSTACLE_NAME</source>
- <translation>Obstacle name</translation>
+ <source>OBJECT_NAME</source>
+ <translation>%1 name</translation>
</message>
<message>
<source>NAME</source>
<translation>Mode</translation>
</message>
<message>
- <source>CREATE_NEW_OBSTACLE</source>
+ <source>CREATE_NEW</source>
<translation>Create new</translation>
</message>
<message>
- <source>MODIFY_OBSTACLE</source>
+ <source>MODIFY</source>
<translation>Modify</translation>
</message>
<message>
- <source>OBSTACLE_TO_EDIT</source>
- <translation>Obstacle to edit</translation>
- </message>
- <message>
- <source>OBSTACLE</source>
- <translation>Obstacle</translation>
+ <source>OBJECT_TO_EDIT</source>
+ <translation>%1 to edit</translation>
</message>
</context>