QString anObstacleName = GetObjPyName();
- QString aGeomObjectEntry = GetGeomObjectEntry();
+ TCollection_AsciiString aGeomObjectEntry = GetGeomObjectEntry();
QString aFilePath = GetFilePath();
- if ( !aGeomObjectEntry.isEmpty() )
+ if ( !aGeomObjectEntry.IsEmpty() )
{
QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "obstacle_sobj" );
- aResList << QString( "%1 = salome.sg.IDToObject( \"%2\" );" )
- .arg( aSalomeObjName ).arg( aGeomObjectEntry );
+ aResList << QString( "%1 = salome.myStudy.FindObjectID( \"%2\" );" )
+ .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() );
aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" )
.arg( anObstacleName ).arg( aSalomeObjName );
+
+ aResList << QString( "%1.SetGeomObjectEntry( \"%2\" );" )
+ .arg( anObstacleName ).arg( aGeomObjectEntry.ToCString() );
}
else if ( !aFilePath.isEmpty() )
{
return aRes;
}
-bool HYDROData_Obstacle::ImportFromGeomIOR( const QString& theIOR )
-{
- TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR );
- if ( aShape.IsNull() )
- return false;
-
- SetShape3D( aShape );
- SetGeomObjectEntry( theIOR );
-
- return true;
-}
-
void HYDROData_Obstacle::SetFilePath( const QString& theFilePath )
{
TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
return aRes;
}
-void HYDROData_Obstacle::SetGeomObjectEntry( const QString& theEntry )
+bool HYDROData_Obstacle::ImportFromGeomIOR( const TCollection_AsciiString& theIOR )
{
- TCollection_AsciiString anAsciiStr( theEntry.toStdString().c_str() );
- TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), anAsciiStr );
+ if ( theIOR.IsEmpty() )
+ return false;
+
+ TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR.ToCString() );
+ if ( aShape.IsNull() )
+ return false;
+
+ SetShape3D( aShape );
+
+ return true;
}
-QString HYDROData_Obstacle::GetGeomObjectEntry() const
+void HYDROData_Obstacle::SetGeomObjectEntry( const TCollection_AsciiString& theEntry )
{
- QString aRes;
+ TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), theEntry );
+}
+
+TCollection_AsciiString HYDROData_Obstacle::GetGeomObjectEntry() const
+{
+ TCollection_AsciiString aRes;
TDF_Label aLabel = myLab.FindChild( DataTag_GeomObjectEntry, false );
if ( !aLabel.IsNull() )
{
Handle(TDataStd_AsciiString) anAsciiStr;
if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
- aRes = QString( anAsciiStr->Get().ToCString() );
+ aRes = anAsciiStr->Get();
}
return aRes;
*/
HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFilePath );
- /**
- * Imports shape from IOR.
- * \param theIOR the IOR of Geom object
- * \return \c true if shape has been successfully imported
- */
- HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const QString& theIOR );
-
/**
* Stores the file path of the imported file.
* \param theFilePath file path
*/
HYDRODATA_EXPORT QString GetFilePath() const;
- /**
+
+ /**
+ * Imports shape from IOR.
+ * \param theIOR the IOR of Geom object
+ * \return \c true if shape has been successfully imported
+ */
+ HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
+
+ /**
* Stores the study entry of the imported GEOM object.
* \param theEntry GEOM object entry
*/
- HYDRODATA_EXPORT void SetGeomObjectEntry( const QString& theEntry );
+ HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
/**
* Returns the imported GEOM object entry.
*/
- HYDRODATA_EXPORT QString GetGeomObjectEntry() const;
+ HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
protected:
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepOffsetAPI_NormalProjection.hxx>
+#include <GEOMBase.h>
+
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Line.hxx>
#include <TColStd_Array1OfReal.hxx>
+#include <TDataStd_AsciiString.hxx>
#include <TDataStd_BooleanList.hxx>
#include <TDataStd_ExtStringList.hxx>
#include <TDataStd_IntegerList.hxx>
aResList << QString( "" );
}
- // Set polilyne data
- NCollection_Sequence<TCollection_AsciiString> aSectNames;
- NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
- NCollection_Sequence<bool> aSectClosures;
- GetSections( aSectNames, aSectTypes, aSectClosures );
-
- for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
+ bool anIsEditable = IsEditable();
+ if ( !anIsEditable )
{
- const TCollection_AsciiString& aSectName = aSectNames.Value( i );
- const SectionType& aSectType = aSectTypes.Value( i );
- bool aSectClosure = aSectClosures.Value( i );
+ // If polyline is not editable we try to import the shape from geom
+ TCollection_AsciiString aGeomObjectEntry = GetGeomObjectEntry();
+ if ( !aGeomObjectEntry.IsEmpty() )
+ {
+ QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "polyline_sobj" );
+ aResList << QString( "%1 = salome.myStudy.FindObjectID( \"%2\" );" )
+ .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() );
- aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName )
- .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
+ aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" )
+ .arg( aPolylineName ).arg( aSalomeObjName );
- HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( i - 1 );
- for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+ aResList << QString( "%1.SetGeomObjectEntry( \"%2\" );" )
+ .arg( aPolylineName ).arg( aGeomObjectEntry.ToCString() );
+ }
+ }
+ else
+ {
+ // Set polilyne data
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ GetSections( aSectNames, aSectTypes, aSectClosures );
+
+ for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
{
- const Point& aSectPoint = aSectPointsList.Value( k );
+ const TCollection_AsciiString& aSectName = aSectNames.Value( i );
+ const SectionType& aSectType = aSectTypes.Value( i );
+ bool aSectClosure = aSectClosures.Value( i );
+
+ aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName )
+ .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
- aResList << QString( "%1.AddPoint( %2, gp_XY( %3, %4 ) );" ).arg( aPolylineName )
- .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() );
+ HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( i - 1 );
+ for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+ {
+ const Point& aSectPoint = aSectPointsList.Value( k );
+
+ aResList << QString( "%1.AddPoint( %2, gp_XY( %3, %4 ) );" ).arg( aPolylineName )
+ .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() );
+ }
}
}
-
aResList << QString( "" );
aResList << QString( "%1.Update();" ).arg( aPolylineName );
aResList << QString( "" );
return QColor( Qt::red );
}
+bool HYDROData_PolylineXY::ImportFromGeomIOR( const TCollection_AsciiString& theIOR )
+{
+ if ( theIOR.IsEmpty() )
+ return false;
+
+ TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR.ToCString() );
+ if ( aShape.IsNull() )
+ return false;
+
+ return ImportShape( aShape );
+}
+
+void HYDROData_PolylineXY::SetGeomObjectEntry( const TCollection_AsciiString& theEntry )
+{
+ TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), theEntry );
+}
+
+TCollection_AsciiString HYDROData_PolylineXY::GetGeomObjectEntry() const
+{
+ TCollection_AsciiString aRes;
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_GeomObjectEntry, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_AsciiString) anAsciiStr;
+ if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
+ aRes = anAsciiStr->Get();
+ }
+
+ return aRes;
+}
+
TopoDS_Shape HYDROData_PolylineXY::GetShape() const
{
return getPolylineShape();
enum DataTag
{
DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
};
public:
const bool& theIsClosed,
const NCollection_Sequence<gp_XYZ>& thePoints );
+public:
+
+ /**
+ * Imports shape from IOR.
+ * \param theIOR the IOR of Geom object
+ * \return \c true if shape has been successfully imported
+ */
+ HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
+
+ /**
+ * Stores the study entry of the imported GEOM object.
+ * \param theEntry GEOM object entry
+ */
+ HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
+
+ /**
+ * Returns the imported GEOM object entry.
+ */
+ HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
+
public:
/**
Handle(HYDROData_Obstacle) anObstacle = Handle(HYDROData_Obstacle)::DownCast( anObject );
anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() );
anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() );
- anObstacle->SetGeomObjectEntry( anEntry );
+ anObstacle->SetGeomObjectEntry( anEntry.toLatin1().constData() );
} else if ( myOpType == ImportSelectedAsPolyline ) {
anObject = doc()->CreateObject( KIND_POLYLINEXY );
Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anObject );
aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
+ aPolylineObj->SetGeomObjectEntry( anEntry.toLatin1().constData() );
}
} else {
anObject = anObjectToEdit;
bool ImportFromFile( const QString& theFilePath );
- /**
- * Imports shape from IOR.
- * \param theIOR the IOR of Geom object
- * \return \c true if shape has been successfully imported
- */
- bool ImportFromGeomIOR( const QString& theIOR );
-
/**
* Stores the file path of the imported file.
* \param theFilePath file path
*/
QString GetFilePath() const;
- /**
+
+public:
+
+ /**
+ * Imports shape from IOR.
+ * \param theIOR the IOR of Geom object
+ * \return \c true if shape has been successfully imported
+ */
+ bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
+
+ /**
* Stores the study entry of the imported GEOM object.
* \param theEntry GEOM object entry
*/
- void SetGeomObjectEntry(const QString& theEntry);
+ void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
/**
* Returns the imported GEOM object entry.
*/
- QString GetGeomObjectEntry() const;
+ TCollection_AsciiString GetGeomObjectEntry() const;
+
protected:
virtual bool IsEditable() const;
+public:
+
+ /**
+ * Imports shape from IOR.
+ * \param theIOR the IOR of Geom object
+ * \return \c true if shape has been successfully imported
+ */
+ bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
+
+ /**
+ * Stores the study entry of the imported GEOM object.
+ * \param theEntry GEOM object entry
+ */
+ void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
+
+ /**
+ * Returns the imported GEOM object entry.
+ */
+ TCollection_AsciiString GetGeomObjectEntry() const;
+
+
+public:
+
/**
* Returns true if polyline is closed
* \param theIsSimpleCheck flag indicating the type of checking