// Try to import the file
if ( aFileSuf == "xyz" )
aRes = importFromXYZFile( aFile, aPoints );
-
+
// Close the file
aFile.close();
+
+
+ // Convert from global to local CS
+ Handle_HYDROData_Document aDoc = HYDROData_Document::Document( myLab );
+ AltitudePoints::Iterator anIter( aPoints );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ AltitudePoint& aPoint = anIter.ChangeValue();
+ aDoc->Transform( aPoint, true );
+ }
if ( aRes )
{
}
-bool HYDROData_Bathymetry::CreateBoundaryPolyline() const
+Handle_HYDROData_PolylineXY HYDROData_Bathymetry::CreateBoundaryPolyline() const
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
Handle_HYDROData_PolylineXY aResult =
Handle_HYDROData_PolylineXY::DownCast( aDocument->CreateObject( KIND_POLYLINEXY ) );
if( aResult.IsNull() )
- return false;
+ return aResult;
//search free name
QString aPolylinePref = GetName() + "_Boundary";
aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmax, Ymin ) );
aResult->Update();
- return true;
+ return aResult;
}
+
+void HYDROData_Bathymetry::UpdateLocalCS( double theDx, double theDy )
+{
+ gp_XYZ aDelta( theDx, theDy, 0 );
+ AltitudePoints aPoints = GetAltitudePoints();
+ AltitudePoints::Iterator anIter( aPoints );
+ for ( int i = 0 ; anIter.More(); ++i, anIter.Next() )
+ {
+ AltitudePoint& aPoint = anIter.ChangeValue();
+ aPoint += aDelta;
+ }
+ SetAltitudePoints( aPoints );
+}
+
class QFile;
class gp_XYZ;
+class Handle_HYDROData_PolylineXY;
DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
*/
HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName );
- HYDRODATA_EXPORT bool CreateBoundaryPolyline() const;
+ HYDRODATA_EXPORT Handle_HYDROData_PolylineXY CreateBoundaryPolyline() const;
+
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
private:
return getShape3D();
}
+void HYDROData_Confluence::UpdateLocalCS( double theDx, double theDy )
+{
+ //TODO
+}
+
*/
HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
+
protected:
friend class HYDROData_Iterator;
#include <HYDROData_Tool.h>
#include <TDataStd_Integer.hxx>
+#include <TDataXtd_Position.hxx>
#include <TDF_Delta.hxx>
+#include <gp_Pnt.hxx>
+
#include <QFile>
#include <QStringList>
#include <QTextStream>
static const int TAG_PROPS_NEW_ID = 1; // general properties: tag for storage of the new object ID
static const int TAG_OBJECTS = 2; // tag of the objects sub-tree
static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for History)
+static const int TAG_LOCAL_CS = 4; // tag of local coordinate system information
+static const gp_Pnt2d DEFAULT_LOCAL_CS( 0, 0 );
using namespace std;
bool aRes = true;
+ // Dump the local CS data to Python
+ UpdateLCSFields();
+ QString aLCS = QString( "%1.SetLocalCS( %2, %3 )" ).arg( GetDocPyName() ).arg( myLX ).arg( myLY );
+ HYDROData_Tool::WriteStringsToFile( aFile, QStringList() << aLCS );
+
// Dump all model objects to Python script
aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMAGE );
aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINEXY );
myDoc->SetUndoLimit(UNDO_LIMIT);
NewID(); // needed to have at least one attribute in initial document to avoid errors
myTransactionsAfterSave = 0;
+ myLX = -1;
+ myLY = -1;
}
HYDROData_Document::HYDROData_Document(const Handle(TDocStd_Document)& theDoc)
{
myDoc = theDoc;
myTransactionsAfterSave = 0;
+ myLX = -1;
+ myLY = -1;
}
HYDROData_Document::~HYDROData_Document()
{
return myDoc->Main().FindChild(TAG_OBJECTS);
}
+
+TDF_Label HYDROData_Document::LabelOfLocalCS() const
+{
+ return myDoc->Main().FindChild(TAG_LOCAL_CS);
+}
+
+void HYDROData_Document::GetLocalCS( double& theLX, double& theLY ) const
+{
+ TDF_Label aLocalCSLab = LabelOfLocalCS();
+
+ Handle( TDataXtd_Position ) aLocalCS;
+ if( aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) )
+ {
+ gp_Pnt aLocalCS3d = aLocalCS->GetPosition();
+ theLX = aLocalCS3d.X();
+ theLY = aLocalCS3d.Y();
+ }
+ else
+ {
+ theLX = DEFAULT_LOCAL_CS.X();
+ theLY = DEFAULT_LOCAL_CS.Y();
+ }
+}
+
+void HYDROData_Document::SetLocalCS( double theLX, double theLY )
+{
+ UpdateLCSFields();
+
+ // update the local CS data in attribute
+ TDF_Label aLocalCSLab = LabelOfLocalCS();
+ Handle( TDataXtd_Position ) aLocalCS;
+ if( !aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) )
+ aLocalCS = TDataXtd_Position::Set( aLocalCSLab );
+
+ gp_Pnt aLocalCS3d( theLX, theLY, 0 );
+ aLocalCS->SetPosition( aLocalCS3d );
+
+ // calculate delta for coordinates
+ double aDX = myLX - theLX;
+ double aDY = myLY - theLY;
+
+ // update the local CS data in internal fields
+ myLX = theLX;
+ myLY = theLY;
+
+ //update all objects in the document
+ HYDROData_Iterator anIterator( this, KIND_UNKNOWN );
+ for( ; anIterator.More(); anIterator.Next() )
+ anIterator.Current()->UpdateLocalCS( aDX, aDY );
+}
+
+void HYDROData_Document::UpdateLCSFields() const
+{
+ if( myLX >= 0 && myLY >= 0 )
+ return;
+
+ double aLX, aLY;
+ GetLocalCS( aLX, aLY );
+ HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
+ aThat->myLX = aLX;
+ aThat->myLY = aLY;
+}
+
+void HYDROData_Document::Transform( double& X, double& Y, bool IsToLocalCS ) const
+{
+ UpdateLCSFields();
+ if( IsToLocalCS )
+ {
+ X -= myLX;
+ Y -= myLY;
+ }
+ else
+ {
+ X += myLX;
+ Y += myLY;
+ }
+}
+
+void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const
+{
+ double X = thePnt.X();
+ double Y = thePnt.Y();
+ double Z = thePnt.Z();
+ Transform( X, Y, IsToLocalCS );
+ thePnt = gp_Pnt( X, Y, Z );
+}
+
+void HYDROData_Document::Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const
+{
+ double X = thePnt.X();
+ double Y = thePnt.Y();
+ double Z = thePnt.Z();
+ Transform( X, Y, IsToLocalCS );
+ thePnt = gp_XYZ( X, Y, Z );
+}
+
+void HYDROData_Document::Transform( gp_XY& thePnt, bool IsToLocalCS ) const
+{
+ double X = thePnt.X();
+ double Y = thePnt.Y();
+ Transform( X, Y, IsToLocalCS );
+ thePnt = gp_XY( X, Y );
+}
#include <TDocStd_Document.hxx>
class QFile;
+class gp_Pnt2d;
+class gp_Pnt;
+class gp_XYZ;
+class gp_XY;
/**
* Errors that could appear on document open/save actions.
//! Removes the order of objects presentation.
HYDRODATA_EXPORT void RemoveObjectsLayerOrder();
+ HYDRODATA_EXPORT void GetLocalCS( double&, double& ) const;
+ HYDRODATA_EXPORT void SetLocalCS( double, double );
+ HYDRODATA_EXPORT void Transform( double& X, double& Y, bool IsToLocalCS ) const;
+ HYDRODATA_EXPORT void Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const;
+ HYDRODATA_EXPORT void Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const;
+ HYDRODATA_EXPORT void Transform( gp_XY& thePnt, bool IsToLocalCS ) const;
public:
//! Returns the label where the objects are located (used by Iterator)
HYDRODATA_EXPORT TDF_Label LabelOfObjects();
+ HYDRODATA_EXPORT TDF_Label LabelOfLocalCS() const;
+
private:
// Dump header Python part in to file \c theFile
const bool theIsMultiFile,
MapOfTreatedObjects& theDumpedObjects,
const ObjectKind& theObjectKind ) const;
+ void UpdateLCSFields() const;
private:
Handle(TDocStd_Document) myDoc; ///< OCAF document instance corresponding for keeping all persistent data
int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method
+ double myLX, myLY;
};
#endif
*/
HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
-
protected:
friend class HYDROData_Iterator;
SetToUpdate( false );
}
+void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy )
+{
+ //On the base level no actions are necessary
+}
+
bool HYDROData_Entity::IsHas2dPrs() const
{
return false;
*/
HYDRODATA_EXPORT virtual void Update();
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
/**
* Checks that object has 2D presentation. Base implementation returns false.
return true;
}
+void HYDROData_Obstacle::UpdateLocalCS( double theDx, double theDy )
+{
+ Translate( theDx, theDy, 0 );
+}
+
*/
HYDRODATA_EXPORT virtual void Update();
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
+
/**
* Checks that object has 2D presentation. Reimlemented to retun true.
*/
return aPath;
}
+void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy )
+{
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ GetSections( aSectNames, aSectTypes, aSectClosures );
+
+ gp_XY aDelta( theDx, theDy );
+ for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ )
+ {
+ PointsList aPoints = GetPoints( i );
+ for( int j = 1, n = aPoints.Size(); j <= n; ++j )
+ {
+ Point& aPoint = aPoints.ChangeValue( j );
+ aPoint += aDelta;
+ }
+ SetPoints( i, aPoints );
+ }
+ SetToUpdate( true );
+}
+
+
*/
HYDRODATA_EXPORT virtual void Update();
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
+
/**
* Checks that object has 2D presentation. Reimlemented to retun true.
*/
QString aGap = QString().fill( ' ', aPntsListName.length() + 5 );
if ( anIsValidProfile )
{
- HYDROData_Profile::ProfilePoints aPointsList = GetProfilePoints();
+ HYDROData_Profile::ProfilePoints aPointsList = GetProfilePoints( true );
for ( int k = 1, aNbPoints = aPointsList.Size(); k <= aNbPoints; ++k )
{
const ProfilePoint& aPoint = aPointsList.Value( k );
TopoDS_Wire aWire;
gp_XY aFirstPoint, aLastPoint;
- if ( !GetLeftPoint( aFirstPoint ) || !GetRightPoint( aLastPoint ) )
+ if ( !GetLeftPoint( aFirstPoint, false ) || !GetRightPoint( aLastPoint, false ) )
return aWire;
gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 );
Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false );
if ( !aProfile.IsNull() )
{
- ProfilePoints aProfilePoints = GetProfilePoints();
+ ProfilePoints aProfilePoints = GetProfilePoints( false );
HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 );
aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints );
bool HYDROData_Profile::IsValid() const
{
gp_XY aFirstPoint, aLastPoint;
- if ( !GetLeftPoint( aFirstPoint ) || !GetRightPoint( aLastPoint ) )
+ if ( !GetLeftPoint( aFirstPoint, false ) || !GetRightPoint( aLastPoint, false ) )
return false;
int aNbPoints = NbPoints();
return aNbPoints > 1;
}
-void HYDROData_Profile::SetLeftPoint( const gp_XY& thePoint )
+void HYDROData_Profile::SetLeftPoint( const gp_XY& theGPoint, bool IsConvertFromGlobal )
{
TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint );
+ if ( aLabel.IsNull() )
+ return;
+
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( Label() );
+ gp_XY aLPoint = theGPoint;
+ if( IsConvertFromGlobal )
+ aDoc->Transform( aLPoint, true );
Handle(TDataStd_RealArray) anArray;
if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
anArray = TDataStd_RealArray::Set( aLabel, 0, 1 );
- anArray->SetValue( 0, thePoint.X() );
- anArray->SetValue( 1, thePoint.Y() );
+ anArray->SetValue( 0, aLPoint.X() );
+ anArray->SetValue( 1, aLPoint.Y() );
SetToUpdate( true );
}
-bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint ) const
+bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const
{
TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint, false );
if ( aLabel.IsNull() )
return false;
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
Handle(TDataStd_RealArray) anArray;
if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
return false;
thePoint.SetX( anArray->Value( 0 ) );
thePoint.SetY( anArray->Value( 1 ) );
+ if( IsConvertToGlobal )
+ aDoc->Transform( thePoint, false );
+
return true;
}
-void HYDROData_Profile::SetRightPoint( const gp_XY& thePoint )
+void HYDROData_Profile::SetRightPoint( const gp_XY& theGPoint, bool IsConvertFromGlobal )
{
TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint );
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( Label() );
+ gp_XY aLPoint = theGPoint;
+ if( IsConvertFromGlobal )
+ aDoc->Transform( aLPoint, true );
+
Handle(TDataStd_RealArray) anArray;
if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
anArray = TDataStd_RealArray::Set( aLabel, 0, 1 );
- anArray->SetValue( 0, thePoint.X() );
- anArray->SetValue( 1, thePoint.Y() );
+ anArray->SetValue( 0, aLPoint.X() );
+ anArray->SetValue( 1, aLPoint.Y() );
SetToUpdate( true );
}
-bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint ) const
+bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const
{
TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint, false );
if ( aLabel.IsNull() )
return false;
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
Handle(TDataStd_RealArray) anArray;
if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
return false;
thePoint.SetX( anArray->Value( 0 ) );
thePoint.SetY( anArray->Value( 1 ) );
+ if( IsConvertToGlobal )
+ aDoc->Transform( thePoint, false );
+
return true;
}
return aProfileUZ.IsNull() ? HYDROData_ProfileUZ::PointsList() : aProfileUZ->GetPoints();
}
-void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints )
+void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal )
{
RemovePoints();
if ( thePoints.Length() < 2 )
gp_XY aFirstPoint, aLastPoint;
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( Label() );
Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
for ( int i = 1, n = thePoints.Length(); i <= n ; ++i )
{
- const ProfilePoint& aPoint = thePoints.Value( i );
+ ProfilePoint aPoint = thePoints.Value( i );
+ if( IsConvertFromGlobal )
+ aDoc->Transform( aPoint, true );
+
gp_XY aPointXY( aPoint.X(), aPoint.Y() );
if ( i == 1 )
aProfileUZ->AddPoint( 0, aParPoint );
}
- SetLeftPoint( aFirstPoint );
- SetRightPoint( aLastPoint );
+ SetLeftPoint( aFirstPoint, false );//already converted to local CS
+ SetRightPoint( aLastPoint, false );
}
-HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints() const
+HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints( bool IsConvertToGlobal ) const
{
ProfilePoints aResPoints;
gp_XY aFirstPoint, aLastPoint;
- if ( !GetLeftPoint( aFirstPoint ) || !GetRightPoint( aLastPoint ) )
+ if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal ) ||
+ !GetRightPoint( aLastPoint, IsConvertToGlobal ) )
return aResPoints;
HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
}
else if ( anIsGeoref )
{
- SetProfilePoints( aPointsXYZ );
+ SetProfilePoints( aPointsXYZ, true );
}
Update();
return aRes;
}
+void HYDROData_Profile::UpdateLocalCS( double theDx, double theDy )
+{
+ gp_XY aDelta( theDx, theDy );
+ gp_XY aPnt;
+
+ GetLeftPoint( aPnt, false );
+ aPnt += aDelta;
+ SetLeftPoint( aPnt, false );
+
+ GetRightPoint( aPnt, false );
+ aPnt += aDelta;
+ SetRightPoint( aPnt, false );
+}
*/
HYDRODATA_EXPORT virtual void Update();
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
+
/**
* Returns default filling color for new profile.
*/
* Set first(left) point for profile.
* \param thePoint the point
*/
- HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint );
+ HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
/**
* Returns first(left) point of profile.
* \param thePoint[out] profile first point
* \return true if point has been set
*/
- HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint ) const;
+ HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
/**
* Set last(right) point for profile.
* \param thePoint the point
*/
- HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint );
+ HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
/**
* Returns last(right) point of profile.
* \param thePoint[out] profile last point
* \return true if point has been set
*/
- HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint ) const;
+ HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
/**
* First and last points will be automatically updated.
* \param thePoints the list with new profile points
*/
- HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints );
+ HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal = true );
/**
* Returns profile points.
* Empty sequence is returned if first or last point was not set.
* \return profile points list
*/
- HYDRODATA_EXPORT ProfilePoints GetProfilePoints() const;
-
+ HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const;
public:
// Public methods to work with files.
return getShape3D();
}
+void HYDROData_River::UpdateLocalCS( double theDx, double theDy )
+{
+ //TODO
+}
+
*/
HYDRODATA_EXPORT virtual void Update();
+ HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
+
/**
* Checks that object has 2D presentation. Reimlemented to retun true.
*/
}
bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
- const HYDROData_SequenceOfObjects& theProfiles,
- PrsDefinition& thePrs )
+ const HYDROData_SequenceOfObjects& theProfiles,
+ PrsDefinition& thePrs )
{
if ( theHydAxis.IsNull() || theProfiles.Length() < 2 )
return false;
const TopoDS_Shape& aProf3d = aProfile->GetShape3D();
gp_XY aPnt1, aPnt2;
- if ( !aProfile->GetLeftPoint( aPnt1 ) || !aProfile->GetRightPoint( aPnt2 ) )
+ if ( !aProfile->GetLeftPoint( aPnt1, false ) || !aProfile->GetRightPoint( aPnt2, false ) )
continue;
anArrOfProfiles.SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape();
Standard_Real aResAlt = 0.0;
gp_XY aFirstPoint, aLastPoint;
- if ( !theProfile->GetLeftPoint( aFirstPoint ) ||
- !theProfile->GetRightPoint( aLastPoint ) )
+ if ( !theProfile->GetLeftPoint( aFirstPoint, false ) ||
+ !theProfile->GetRightPoint( aLastPoint, false ) )
return aResAlt;
gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 );
gp_Pnt aPrevPoint;
gp_Lin aPrevNormal;
- HYDROData_Profile::ProfilePoints aProfilePoints = theProfile->GetProfilePoints();
+ HYDROData_Profile::ProfilePoints aProfilePoints = theProfile->GetProfilePoints( false );
for ( int i = 1, n = aProfilePoints.Length(); i <= n; ++i )
{
gp_Pnt aProfPoint( aProfilePoints.Value( i ) );
continue;
gp_XY aFirstPoint, aLastPoint;
- if ( !aProfile->GetLeftPoint( aFirstPoint ) || !aProfile->GetRightPoint( aLastPoint ) )
+ if ( !aProfile->GetLeftPoint( aFirstPoint, false ) ||
+ !aProfile->GetRightPoint( aLastPoint, false ) )
continue;
gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 );
// Interpolate altitudes
// Left profile line ( the segment between the firts and the last profile point )
- HYDROData_Profile::ProfilePoints aLeftProfilePoints = aLeftProfile->GetProfilePoints();
+ HYDROData_Profile::ProfilePoints aLeftProfilePoints = aLeftProfile->GetProfilePoints( false );
gp_Pnt aLeftProfileP1( aLeftProfilePoints.First() );
aLeftProfileP1.SetZ( 0 );
gp_Pnt aLeftProfileP2( aLeftProfilePoints.Last() );
gp_Vec aLeftProfileVec( aLeftProfileP1, aLeftProfileP2 );
Handle(Geom_Line) aLeftProfileLine = new Geom_Line( gp_Ax1( aLeftProfileP1, aLeftProfileVec ) );
// Right profile line
- HYDROData_Profile::ProfilePoints aRightProfilePoints = aRightProfile->GetProfilePoints();
+ HYDROData_Profile::ProfilePoints aRightProfilePoints = aRightProfile->GetProfilePoints( false );
gp_Pnt aRightProfileP1( aRightProfilePoints.First() );
aRightProfileP1.SetZ( 0 );
gp_Pnt aRightProfileP2( aRightProfilePoints.Last() );
*/
HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
-
protected:
friend class HYDROData_Region;
HYDROGUI_CopyPastePositionOp.h
HYDROGUI_DataBrowser.h
HYDROGUI_DataModel.h
+ HYDROGUI_DataModelSync.h
HYDROGUI_DataObject.h
HYDROGUI_DeleteDlg.h
HYDROGUI_DeleteOp.h
HYDROGUI_ImportImageDlg.h
HYDROGUI_ImportImageOp.h
HYDROGUI_InputPanel.h
+ HYDROGUI_LocalCSDlg.h
+ HYDROGUI_LocalCSOp.h
HYDROGUI_Module.h
HYDROGUI_NameValidator.h
HYDROGUI_ObjSelector.h
HYDROGUI_CopyPastePositionOp.cxx
HYDROGUI_DataBrowser.cxx
HYDROGUI_DataModel.cxx
+ HYDROGUI_DataModelSync.cxx
HYDROGUI_DataObject.cxx
HYDROGUI_DeleteDlg.cxx
HYDROGUI_DeleteOp.cxx
HYDROGUI_ImportImageDlg.cxx
HYDROGUI_ImportImageOp.cxx
HYDROGUI_InputPanel.cxx
+ HYDROGUI_LocalCSDlg.cxx
+ HYDROGUI_LocalCSOp.cxx
HYDROGUI_Module.cxx
HYDROGUI_NameValidator.cxx
HYDROGUI_ObjSelector.cxx
#include <HYDROGUI_Tool.h>
#include <HYDROGUI_UpdateFlags.h>
#include <HYDROGUI_Module.h>
+#include <HYDROGUI_DataObject.h>
+#include <HYDROData_PolylineXY.h>
HYDROGUI_BathymetryBoundsOp::HYDROGUI_BathymetryBoundsOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
onApply();
}
-bool HYDROGUI_BathymetryBoundsOp::processApply( int& theUpdateFlags, QString& theErrorMsg )
+bool HYDROGUI_BathymetryBoundsOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
- bool isOK = myBath->CreateBoundaryPolyline();
+ Handle_HYDROData_PolylineXY aPolyline = myBath->CreateBoundaryPolyline();
+ bool isOK = !aPolyline.IsNull();
theUpdateFlags = 0;
if( isOK ) {
module()->setIsToUpdate( myBath );
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aPolyline );
+ theBrowseObjectsEntries.append( anEntry );
}
else
theErrorMsg = tr( "CANNOT_CREATE_BOUNDARY_POLYLINE" );
protected:
virtual void startOperation();
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
private:
Handle(HYDROData_Bathymetry) myBath;
}
bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_CalculationDlg* aPanel =
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
if ( !aPanel )
return false;
+ if( !myIsEdit )
+ {
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
+ theBrowseObjectsEntries.append( anEntry );
+ }
+
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
return true;
int anUpdateFlags = 0;
QString anErrorMsg;
+ QStringList aBrowseObjectsEntries;
bool aResult = false;
try
{
- aResult = processApply( anUpdateFlags, anErrorMsg );
+ aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
}
catch ( Standard_Failure )
{
{
module()->update( anUpdateFlags );
commit();
+ browseObjects( aBrowseObjectsEntries );
}
else
{
virtual HYDROGUI_InputPanel* createInputPanel() const;
virtual void onApply();
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
void setAvailableGroups();
#include "HYDROGUI_ChannelOp.h"
#include "HYDROGUI_DataModel.h"
+#include <HYDROGUI_DataObject.h>
#include "HYDROGUI_ChannelDlg.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Shape.h"
}
bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
if ( !aPanel )
erasePreview();
if( !myIsEdit )
+ {
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
+ theBrowseObjectsEntries.append( anEntry );
+ }
module()->setIsToUpdate( myEditedObject );
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
protected slots:
virtual void onCreatePreview();
#include <HYDROData_Bathymetry.h>
#include <HYDROData_CalculationCase.h>
+#include <HYDROGUI_DataModelSync.h>
#include <HYDROData_Document.h>
#include <HYDROData_DummyObject3D.h>
#include <HYDROData_Image.h>
#include <HYDROData_River.h>
#include <HYDROData_Stream.h>
-#include <CAM_Application.h>
-#include <CAM_DataObject.h>
#include <CAM_Module.h>
#include <CAM_Study.h>
#include <LightApp_DataObject.h>
#include <LightApp_Study.h>
-#include <SUIT_DataObject.h>
#include <SUIT_DataBrowser.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Study.h>
#include <SUIT_Tools.h>
+#include <SUIT_TreeSync.h>
#include <HYDROData_Document.h>
static HYDROData_SequenceOfObjects myCopyingObjects;
+const int ENTRY_COLUMN = 2;
+
+
HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
: LightApp_DataModel( theModule )
{
const int aStudyId = theStudy->id();
Data_DocError res = DocError_UnknownProblem;
- if( theFileList.count() == 2 )
+ if( theFileList.count() >= 2 )
{
QString aTmpDir = theFileList[0];
- QString aFileName = theFileList[1];
+ QString aDataFileName = theFileList[1];
+ QString aStatesFileName = theFileList.count() == 3 ? theFileList[2] : "";
myStudyURL = theURL;
- QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
+ QString aDataFullPath = SUIT_Tools::addSlash( aTmpDir ) + aDataFileName;
+ QString aStatesFullPath = aStatesFileName.isEmpty() ? "" : SUIT_Tools::addSlash( aTmpDir ) + aStatesFileName;
try
{
- res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId );
+ res = HYDROData_Document::Load( (char*)aDataFullPath.toLatin1().constData(), aStudyId );
}
catch(...)
{
module()->application()->putInfo( tr( "LOAD_ERROR" ) );
return false;
}
+
+ if( !aStatesFullPath.isEmpty() )
+ {
+ QFile aFile( aStatesFullPath );
+ if( aFile.open( QFile::ReadOnly ) )
+ {
+ myStates = aFile.readAll();
+ aFile.close();
+ }
+ }
}
// if the document open was successful, the data model update happens
LightApp_DataModel::save( theFileList );
QString aTmpDir;
- QString aFileName;
SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
bool isMultiFile = false;
if( resMgr )
isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
- // save data to temporary files
+ // save module data to temporary files
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
- aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
-
- QString aFullPath = aTmpDir + aFileName;
- Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
+
+ // save OCAF data to a temporary file
+ QString aDataFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
+ QString aDataFullPath = aTmpDir + aDataFileName;
+ Data_DocError res = getDocument()->Save( (char*)aDataFullPath.toLatin1().constData() );
if( res != DocError_OK )
{
module()->application()->putInfo( tr( "SAVE_ERROR" ) );
return false;
}
+ // save tree state data to a temporary file
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
+ QByteArray aStatesData = anApp->objectBrowser()->getOpenStates( ENTRY_COLUMN );
+ QString aStatesFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO_tree_states.txt";
+ QString aStatesFullPath = aTmpDir + aStatesFileName;
+ QFile aFile( aStatesFullPath );
+ if( aFile.open( QFile::WriteOnly ) )
+ {
+ aFile.write( aStatesData );
+ aFile.close();
+ }
+
+ // add temporary files to the list
theFileList.append( aTmpDir );
- theFileList.append( aFileName );
+ theFileList.append( aDataFileName );
+ theFileList.append( aStatesFileName );
return true;
}
if( !aStudyRoot )
return;
- // create root object if not exist
- CAM_DataObject* aRootObj = root();
- if( !aRootObj )
- aRootObj = createRootModuleObject( aStudyRoot );
-
- if( !aRootObj )
- return;
-
- DataObjectList aList;
- aRootObj->children( aList );
- QListIterator<SUIT_DataObject*> anIter( aList );
- while( anIter.hasNext() )
- removeChild( aRootObj, anIter.next() );
+ // create a new root object
+ CAM_DataObject* aNewRootObj = new CAM_DataObject();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId );
if( aDocument.IsNull() )
// Create root objects:
// IMAGES
- LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
+ LightApp_DataObject* anImageRootObj = createObject( aNewRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
// BATHYMETRY
- LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
+ LightApp_DataObject* aBathymetryRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
// ARTIFICIAL OBJECTS
- LightApp_DataObject* anArtificialObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
+ LightApp_DataObject* anArtificialObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
// NATURAL OBJECTS
- LightApp_DataObject* aNaturalObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
+ LightApp_DataObject* aNaturalObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
// OBSTACLES
- LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+ LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
// CALCULATION CASES
- LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
+ LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
// POLYLINES
- LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) );
+ LightApp_DataObject* aPolylineRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) );
// POLYLINES
- LightApp_DataObject* aPolyline3DRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
+ LightApp_DataObject* aPolyline3DRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
// PROFILES
- LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
+ LightApp_DataObject* aProfileRootObj = createObject( aNewRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
// VISUAL STATES
- LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
+ LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
for( ; anIterator.More(); anIterator.Next() ) {
}
}
- if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
+ //if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
+ //{
+ // anObjectBrowser->setAutoOpenLevel( 3 );
+ // anObjectBrowser->openLevels();
+ //}
+
+ HYDROGUI_DataModelSync aSync( aNewRootObj );
+ SUIT_DataObject* aRoot = root();
+ bool isNewDoc = aRoot==0;
+ if( isNewDoc )
+ aRoot = createRootModuleObject( aStudyRoot );
+ ::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync >
+ ( aNewRootObj, aRoot, aSync );
+
+
+ if( !myStates.isEmpty() )
{
- anObjectBrowser->setAutoOpenLevel( 3 );
- anObjectBrowser->openLevels();
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
+ anApp->objectBrowser()->updateTree();
+ anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN );
+ myStates.clear();
}
}
protected:
QString myStudyURL; ///< the saved/opened document URL
+ QByteArray myStates;
};
#endif
--- /dev/null
+
+#include <HYDROGUI_DataModelSync.h>
+#include <HYDROGUI_DataObject.h>
+#include <typeinfo>
+
+HYDROGUI_DataModelSync::HYDROGUI_DataModelSync( SUIT_DataObject* theRoot )
+ : myRoot( theRoot )
+{
+}
+
+HYDROGUI_DataModelSync::~HYDROGUI_DataModelSync()
+{
+}
+
+void HYDROGUI_DataModelSync::deleteItemWithChildren( const suitPtr& theSuitPtr ) const
+{
+ if( !theSuitPtr )
+ return;
+
+ theSuitPtr->setAutoDeleteChildren( true );
+ theSuitPtr->deleteLater();
+}
+
+suitPtr HYDROGUI_DataModelSync::nullSrc() const
+{
+ return 0;
+}
+
+suitPtr HYDROGUI_DataModelSync::nullTrg() const
+{
+ return 0;
+}
+
+QList<suitPtr> HYDROGUI_DataModelSync::children( const suitPtr& theSuitPtr ) const
+{
+ QList<suitPtr> aChildren;
+ if( theSuitPtr )
+ {
+ DataObjectList anObjList;
+ theSuitPtr->children( anObjList );
+ foreach( SUIT_DataObject* anObj, anObjList )
+ aChildren.append( anObj );
+ }
+ return aChildren;
+}
+
+suitPtr HYDROGUI_DataModelSync::parent( const suitPtr& theSuitPtr ) const
+{
+ return theSuitPtr ? theSuitPtr->parent() : 0;
+}
+
+void HYDROGUI_DataModelSync::updateItem( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
+{
+ HYDROGUI_DataObject* aDataObj = dynamic_cast<HYDROGUI_DataObject*>( theTrgPtr );
+ if( aDataObj )
+ aDataObj->updateBy( theSrcPtr );
+
+ HYDROGUI_NamedObject* aNamedObj = dynamic_cast<HYDROGUI_NamedObject*>( theTrgPtr );
+ if( aNamedObj )
+ aNamedObj->updateBy( theSrcPtr );
+}
+
+bool HYDROGUI_DataModelSync::isEqual( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const
+{
+ if( theSrcPtr==myRoot )
+ return true;
+
+ if( theSrcPtr==0 )
+ return theTrgPtr==0;
+
+ if( theTrgPtr==0 )
+ return theSrcPtr==0;
+
+ QString aSrcClass = typeid( *theSrcPtr ).name();
+ QString aTrgClass = typeid( *theTrgPtr ).name();
+ return aSrcClass==aTrgClass;
+}
+
+suitPtr HYDROGUI_DataModelSync::createItem( const suitPtr& theSrcPtr,
+ const suitPtr& theParent,
+ const suitPtr& theAfter ) const
+{
+ if( theParent )
+ {
+ int aPos = theParent->childPos( theAfter );
+ if( aPos>=0 )
+ theParent->insertChild( theSrcPtr, aPos+1 );
+ else
+ theParent->appendChild( theSrcPtr );
+ }
+ return theSrcPtr;
+}
+
--- /dev/null
+
+#ifndef HYDROGUI_DATA_MODEL_SYNC_HEADER
+#define HYDROGUI_DATA_MODEL_SYNC_HEADER
+
+#include <QList>
+
+class SUIT_DataObject;
+
+typedef SUIT_DataObject* suitPtr;
+
+class HYDROGUI_DataModelSync
+{
+public:
+ HYDROGUI_DataModelSync( SUIT_DataObject* theRoot );
+ ~HYDROGUI_DataModelSync();
+
+ void deleteItemWithChildren( const suitPtr& ) const;
+ suitPtr nullSrc() const;
+ suitPtr nullTrg() const;
+ QList<suitPtr> children( const suitPtr& ) const;
+ suitPtr parent( const suitPtr& ) const;
+ void updateItem( const suitPtr&, const suitPtr& ) const;
+ bool isEqual( const suitPtr&, const suitPtr& ) const;
+ suitPtr createItem( const suitPtr&, const suitPtr&, const suitPtr& ) const;
+
+private:
+ SUIT_DataObject* myRoot;
+};
+
+#endif
return aRes;
}
+void HYDROGUI_DataObject::updateBy( SUIT_DataObject* theObj )
+{
+ HYDROGUI_DataObject* aDataObj = dynamic_cast<HYDROGUI_DataObject*>( theObj );
+ if( !aDataObj )
+ return;
+
+ myData = aDataObj->myData;
+ myParentEntry = aDataObj->myParentEntry;
+ myIsValid = aDataObj->myIsValid;
+ myIsInOperation = aDataObj->myIsInOperation;
+ myIcon = aDataObj->myIcon;
+ setModified( true );
+}
+
+
+
+
HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
return aFont;
}
+void HYDROGUI_NamedObject::updateBy( SUIT_DataObject* theObj )
+{
+ HYDROGUI_NamedObject* aNamedObj = dynamic_cast<HYDROGUI_NamedObject*>( theObj );
+ if( !aNamedObj )
+ return;
+
+ myName = aNamedObj->myName;
+ myParentEntry = aNamedObj->myParentEntry;
+ myIcon = aNamedObj->myIcon;
+ myIsInOperation = aNamedObj->myIsInOperation;
+ setModified( true );
+}
+
+
+
+
+
+
HYDROGUI_DropTargetObject::HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
const QString& theName,
const QString& theParentEntry,
*/
bool isInOperation() const { return myIsInOperation; }
+ void updateBy( SUIT_DataObject* );
+
protected:
Handle(HYDROData_Entity) myData; ///< object from data model
QString myParentEntry;
*/
bool isInOperation() const { return myIsInOperation; }
+ void updateBy( SUIT_DataObject* );
+
private:
QString myName; ///< name in the OB
QString myParentEntry;
}
bool HYDROGUI_DigueOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
- if ( !HYDROGUI_ChannelOp::processApply( theUpdateFlags, theErrorMsg ) )
+ if ( !HYDROGUI_ChannelOp::processApply( theUpdateFlags, theErrorMsg, theBrowseObjectsEntries ) )
return false;
if ( !myIsEdit )
virtual void startOperation();
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual HYDROGUI_InputPanel* createInputPanel() const;
}
bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
// Get the selected calculation case
Handle(HYDROData_CalculationCase) aCalculation =
QString anErrorMsg;
bool aResult = false;
-
+ QStringList aBrowseObjectsEntries;
+
try {
- aResult = processApply( anUpdateFlags, anErrorMsg );
+ aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
}
catch ( Standard_Failure )
{
if ( aResult ) {
module()->update( anUpdateFlags );
commit();
+ browseObjects( aBrowseObjectsEntries );
// Show message box
SUIT_MessageBox::information( module()->getApp()->desktop(),
virtual void abortOperation();
virtual void commitOperation();
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual void onApply();
};
}
bool HYDROGUI_GeoreferencementOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
if ( !aProfile->IsValid() ) // Show the profile after it became valid
aModule->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( aModule ), aProfile, true );
- aProfile->SetLeftPoint( gp_XY( aGeoData.Xg, aGeoData.Yg ) );
- aProfile->SetRightPoint( gp_XY( aGeoData.Xd, aGeoData.Yd ) );
+ aProfile->SetLeftPoint( gp_XY( aGeoData.Xg, aGeoData.Yg ), false );
+ aProfile->SetRightPoint( gp_XY( aGeoData.Xd, aGeoData.Yd ), false );
} else {
aProfile->Invalidate();
aModule->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( aModule ), aProfile, false );
HYDROGUI_GeoreferencementDlg::ProfileGeoData aGeoData( aProfile->GetName() );
gp_XY aFirstPoint, aLastPoint;
- if ( aProfile->GetLeftPoint( aFirstPoint ) && aProfile->GetRightPoint( aLastPoint ) ) {
+ if ( aProfile->GetLeftPoint( aFirstPoint, false ) &&
+ aProfile->GetRightPoint( aLastPoint, false ) ) {
aGeoData =
HYDROGUI_GeoreferencementDlg::ProfileGeoData( aGeoData.Name,
aFirstPoint.X(), aFirstPoint.Y(),
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
protected slots:
void onModeActivated( const int theActualMode );
#include "HYDROGUI_Shape.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_DataObject.h"
#include <HYDROData_Bathymetry.h>
#include <HYDROData_Iterator.h>
}
bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_ImmersibleZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ImmersibleZoneDlg*>( inputPanel() );
if ( !aPanel )
closePreview();
if( !myIsEdit )
+ {
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aZoneObj );
+ theBrowseObjectsEntries.append( anEntry );
+ }
module()->setIsToUpdate( aZoneObj );
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; };
#include "HYDROGUI_ImportBathymetryOp.h"
#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_ImportBathymetryDlg.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
}
bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_ImportBathymetryDlg* aPanel =
::qobject_cast<HYDROGUI_ImportBathymetryDlg*>( inputPanel() );
}
theUpdateFlags = UF_Model | UF_VTKViewer | UF_VTK_Init | UF_VTK_Forced;
+
+ if( !myIsEdit )
+ {
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBathymetryObj );
+ theBrowseObjectsEntries.append( anEntry );
+ }
+
return true;
}
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
protected slots:
#include "HYDROGUI_ImportGeomObjectOp.h"
#include "HYDROGUI_GeomObjectDlg.h"
-
+#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
}
bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
// Get active SalomeApp_Study
SalomeApp_Study* aStudy =
if ( anIsOk ) {
anObject->Update();
module()->setIsToUpdate( anObject );
+ QString aHydroObjEntry = HYDROGUI_DataObject::dataObjectEntry( anObject );
+ theBrowseObjectsEntries.append( aHydroObjEntry );
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
}
}
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
protected slots:
void onExternalOperationFinished( const QString&, const QString&,
#include "HYDROGUI_ImportImageOp.h"
#include "HYDROGUI_DataModel.h"
+#include <HYDROGUI_DataObject.h>
#include "HYDROGUI_ImportImageDlg.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_PrsImage.h"
}
bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
if( myIsEdit )
anImageObj = myEditedObject;
else
+ {
anImageObj = Handle(HYDROData_Image)::DownCast( doc()->CreateObject( KIND_IMAGE ) );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anImageObj );
+ theBrowseObjectsEntries.append( anEntry );
+ }
if( anImageObj.IsNull() )
return false;
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
bool isReferenceCorrect() const;
protected slots:
#include "HYDROGUI_ImportObstacleFromFileOp.h"
#include "HYDROGUI_GeomObjectDlg.h"
-
+#include <HYDROGUI_DataObject.h>
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
}
bool HYDROGUI_ImportObstacleFromFileOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
QString aFileName;
QString anObstacleName;
anIsOk = true;
module()->setIsToUpdate( anObstacle );
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObstacle );
+ theBrowseObjectsEntries.append( anEntry );
+
+
} else {
theErrorMsg = tr( "BAD_IMPORTED_OBSTACLE_FILE" ).arg( aFileName );
}
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
private:
SUIT_FileDlg* myFileDlg;
}
QApplication::setOverrideCursor( Qt::WaitCursor );
+ QStringList aBrowseObjectsEntries;
+ //TODO: to implement the addition of imported profiles' entries to the list
startDocOperation();
commit();
module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
+ browseObjects( aBrowseObjectsEntries );
}
QApplication::restoreOverrideCursor();
--- /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_LocalCSDlg.h>
+#include <QtxDoubleSpinBox.h>
+#include <QLayout>
+#include <QLabel>
+
+const double RANGE = 1E+10;
+const double STEP = 1.00;
+const double PREC = 2;
+
+HYDROGUI_LocalCSDlg::HYDROGUI_LocalCSDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+ QFrame* aFrame = new QFrame( mainFrame() );
+ addWidget( aFrame, 1 );
+
+ QGridLayout* aLayout = new QGridLayout( aFrame );
+
+ myLX = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, aFrame );
+ myLX->setValue( 0.0 );
+ myLY = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, aFrame );
+ myLY->setValue( 0.0 );
+
+ aLayout->addWidget( new QLabel( tr( "LX" ), aFrame ), 0, 0 );
+ aLayout->addWidget( myLX, 0, 1 );
+ aLayout->addWidget( new QLabel( tr( "LY" ), aFrame ), 1, 0 );
+ aLayout->addWidget( myLY, 1, 1 );
+ aLayout->setColumnStretch( 0, 0 );
+ aLayout->setColumnStretch( 1, 1 );
+ aLayout->setRowStretch( 2, 1 );
+}
+
+HYDROGUI_LocalCSDlg::~HYDROGUI_LocalCSDlg()
+{
+}
+
+double HYDROGUI_LocalCSDlg::GetLocalX() const
+{
+ return myLX->value();
+}
+
+double HYDROGUI_LocalCSDlg::GetLocalY() const
+{
+ return myLY->value();
+}
+
+void HYDROGUI_LocalCSDlg::SetLocalCS( double theLX, double theLY )
+{
+ myLX->setValue( theLX );
+ myLY->setValue( theLY );
+}
+
--- /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_LocalCSDlg_H
+#define HYDROGUI_LocalCSDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QtxDoubleSpinBox;
+
+class HYDROGUI_LocalCSDlg : public HYDROGUI_InputPanel
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_LocalCSDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+ virtual ~HYDROGUI_LocalCSDlg();
+
+ double GetLocalX() const;
+ double GetLocalY() const;
+ void SetLocalCS( double theLX, double theLY );
+
+private:
+ QtxDoubleSpinBox* myLX;
+ QtxDoubleSpinBox* myLY;
+};
+
+#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_LocalCSOp.h>
+#include <HYDROGUI_LocalCSDlg.h>
+#include <HYDROData_Document.h>
+#include <HYDROGUI_UpdateFlags.h>
+#include <gp_Pnt2d.hxx>
+
+HYDROGUI_LocalCSOp::HYDROGUI_LocalCSOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "EDIT_LOCAL_CS" ) );
+}
+
+HYDROGUI_LocalCSOp::~HYDROGUI_LocalCSOp()
+{
+}
+
+void HYDROGUI_LocalCSOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast<HYDROGUI_LocalCSDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ double aLX, aLY;
+ doc()->GetLocalCS( aLX, aLY );
+ aPanel->SetLocalCS( aLX, aLY );
+}
+
+HYDROGUI_InputPanel* HYDROGUI_LocalCSOp::createInputPanel() const
+{
+ return new HYDROGUI_LocalCSDlg( module(), getName() );
+}
+
+bool HYDROGUI_LocalCSOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
+{
+ HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast<HYDROGUI_LocalCSDlg*>( inputPanel() );
+ if ( !aPanel )
+ return false;
+
+ double aLX = aPanel->GetLocalX();
+ double aLY = aPanel->GetLocalY();
+ doc()->SetLocalCS( aLX, aLY );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+
+ return true;
+}
--- /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_LocalCSOp_H
+#define HYDROGUI_LocalCSOp_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_LocalCSOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_LocalCSOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_LocalCSOp();
+
+protected:
+ virtual void startOperation();
+
+ virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
+};
+
+#endif
bool anIsDummyObject3D = false;
bool anIsGroup = false;
bool anIsObjectCanBeColored = false;
+ bool isRoot = false;
+
+ SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
+ SUIT_DataOwnerPtrList anOwners;
+ aSelectionMgr->selected( anOwners );
+ if( anIsObjectBrowser && anOwners.size()==1 )
+ {
+ QString anEntry = anOwners[0]->keyString();
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
+ if( aStudy )
+ isRoot = aStudy->isComponent( anEntry );
+ }
// Check the selected GEOM objects (take into account the Object Browser only)
if ( anIsObjectBrowser ) {
theMenu->addSeparator();
theMenu->addAction( action( CopyViewerPositionId ) );
}
+
+ if( isRoot )
+ theMenu->addAction( action( EditLocalCSId ) );
}
void HYDROGUI_Module::update( const int flags )
void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
{
- double aX, aY, aZ;
+ double X, Y, Z;
bool doShow = false;
HYDROGUI_Displayer* aDisplayer = getDisplayer();
if ( aDisplayer )
aDisplayer->SaveCursorViewPosition( theViewWindow );
- doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, aX, aY, aZ );
+ doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
if ( doShow )
{
// Show the coordinates in the status bar
SUIT_Desktop* aDesktop = getApp()->desktop();
- if ( aDesktop && aDesktop->statusBar() ) {
- QString aXStr = HYDROGUI_Tool::GetCoordinateString( aX );
- QString anYStr = HYDROGUI_Tool::GetCoordinateString( aY );
- aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aXStr ).arg( anYStr ) );
+ if ( aDesktop && aDesktop->statusBar() )
+ {
+ gp_Pnt aWPnt( X, Y, Z );
+ int aStudyId = application()->activeStudy()->id();
+ HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
+ double WX = aWPnt.X(), WY = aWPnt.Y();
+
+ QString aXStr = HYDROGUI_Tool::GetCoordinateString( X );
+ QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y );
+ QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX );
+ QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY );
+ QString aMsg = tr( "COORDINATES_INFO" );
+ aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
+ aDesktop->statusBar()->showMessage( aMsg );
}
}
}
}
bool HYDROGUI_Operation::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
return false;
}
QString anErrorMsg;
bool aResult = false;
-
+ QStringList aBrowseObjectsEntries;
+
try
{
- aResult = processApply( anUpdateFlags, anErrorMsg );
+ aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
}
catch ( Standard_Failure )
{
module()->update( anUpdateFlags );
commitDocOperation();
commit();
+ browseObjects( aBrowseObjectsEntries );
}
else
{
return QString();
}
-
+void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries )
+{
+ bool isApplyAndClose = true;
+ bool isOptimizedBrowse = true;
+ module()->getApp()->browseObjects( theBrowseObjectsEntries, isApplyAndClose, isOptimizedBrowse );
+}
virtual HYDROGUI_InputPanel* createInputPanel() const;
virtual void closeInputPanel();
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual void processCancel();
void startDocOperation();
void printErrorMessage( const QString& theErrorMsg );
void setPrintErrorMessage( const bool theIsPrint );
+ void browseObjects( const QStringList& theBrowseObjectsEntries );
+
protected slots:
virtual void onApply();
#include "HYDROGUI_BathymetryBoundsOp.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_ZLevelsOp.h"
+#include "HYDROGUI_LocalCSOp.h"
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
createAction( SetColorId, "COLOR" );
createAction( SetZLevelId, "ZLEVEL" );
+ createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
createAction( ShowId, "SHOW" );
createAction( ShowOnlyId, "SHOW_ONLY" );
createMenu( ImportBathymetryId, aHydroId, -1, -1 );
createMenu( CreatePolylineId, aHydroId, -1, -1 );
createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
+ createMenu( EditLocalCSId, aHydroId, -1, -1 );
int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
createMenu( CreateProfileId, aNewProfileId, -1, -1 );
case SetZLevelId:
anOp = new HYDROGUI_ZLevelsOp( aModule );
break;
+ case EditLocalCSId:
+ anOp = new HYDROGUI_LocalCSOp( aModule );
+ break;
case ShowId:
case ShowOnlyId:
case ShowAllId:
SetColorId,
SetZLevelId,
+ EditLocalCSId,
};
#include "HYDROGUI_Poly3DOp.h"
#include "HYDROGUI_Module.h"
+#include <HYDROGUI_DataObject.h>
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_Poly3DDlg.h"
#include "HYDROGUI_UpdateFlags.h"
}
bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_Poly3DDlg* aPanel = dynamic_cast<HYDROGUI_Poly3DDlg*>( inputPanel() );
else
{
aResult = Handle(HYDROData_Polyline3D)::DownCast( doc()->CreateObject( KIND_POLYLINE ) );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aResult );
+ theBrowseObjectsEntries.append( anEntry );
}
if( aResult.IsNull() )
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
private:
bool myIsEdit;
#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_Module.h"
+#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_PolylineDlg.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
}
bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_PolylineDlg* aPanel = ::qobject_cast<HYDROGUI_PolylineDlg*>( inputPanel() );
if ( !aPanel )
if( !myIsEdit )
{
module()->setObjectVisible( anActiveViewId, aPolylineObj, true );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aPolylineObj );
+ theBrowseObjectsEntries.append( anEntry );
}
return true;
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
protected slots:
void onEditorSelectionChanged();
#include "HYDROGUI_ProfileDlg.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
-
+#include <HYDROGUI_DataObject.h>
#include "HYDROData_Document.h"
#include "HYDROData_Profile.h"
#include "CurveCreator_Profile.hxx"
}
bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_ProfileDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
if ( !aPanel )
theUpdateFlags = UF_Model;
if ( myIsEdit )
theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+ else
+ {
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aProfileObj );
+ theBrowseObjectsEntries.append( anEntry );
+ }
return true;
}
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
private:
void displayPreview();
}
bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
if ( !myColorDlg || myEditedObject.IsNull() )
return false;
protected:
virtual void startOperation();
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
private:
HYDROGUI_ColorDlg* myColorDlg;
gp_Pnt aPnt3( aRect.bottomRight().x(), aRect.bottomRight().y(), 0 );
gp_Pnt aPnt4( aRect.bottomLeft().x(), aRect.bottomLeft().y(), 0 );
+ Handle_HYDROData_Document aDoc = HYDROData_Document::Document( anImageObj->Label() );
+ aDoc->Transform( aPnt1, true );
+ aDoc->Transform( aPnt2, true );
+ aDoc->Transform( aPnt3, true );
+ aDoc->Transform( aPnt4, true );
+
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge( aPnt2, aPnt3 ).Edge();
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge( aPnt3, aPnt4 ).Edge();
#include "HYDROGUI_StreamOp.h"
#include "HYDROGUI_Module.h"
+#include <HYDROGUI_DataObject.h>
#include "HYDROGUI_Shape.h"
#include "HYDROGUI_StreamDlg.h"
#include "HYDROGUI_Tool.h"
}
bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
if ( !aPanel )
// Show the object in case of creation mode of the operation
if( !myIsEdit ) {
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
+ theBrowseObjectsEntries.append( anEntry );
}
module()->setIsToUpdate( myEditedObject );
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual bool isToAbortOnApply() const { return false; }
QString HYDROGUI_Tool::GetCoordinateString( const double theNumber )
{
- return QString::number( theNumber, 'f', 2 );
-}
\ No newline at end of file
+ //return QString::number( theNumber, 'f', 2 );
+ static QLocale aLocale( QLocale::English, QLocale::France );
+ return aLocale.toString( theNumber, 'f', 2 );
+}
+
}
bool HYDROGUI_TranslateObstacleOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_TranslateObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_TranslateObstacleDlg*>( inputPanel() );
if ( !aPanel || myEditedObject.IsNull() ) {
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; };
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_TwoImagesDlg.h"
#include "HYDROGUI_UpdateFlags.h"
+#include <HYDROGUI_DataObject.h>
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
}
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
anOperator = aFactory->Operator( anOperatorName );
aResult = aFactory->CreateImage( doc(), anOperator );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aResult );
+ theBrowseObjectsEntries.append( anEntry );
}
if( aResult.IsNull() || !anOperator )
virtual HYDROGUI_InputPanel* createInputPanel() const;
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
protected slots:
/** Show warning if the name has already been selected
/**
*/
bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
bool aRes = false;
protected:
virtual void startOperation();
- virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
virtual void processCancel();
private:
</message>
<message>
<source>COORDINATES_INFO</source>
- <translation>X: %1, Y: %2</translation>
+ <translation>Local CS: (%1, %2); Global CS: (%3, %4)</translation>
</message>
<message>
<source>POLYLINE3D_POLYLINE</source>
<source>DSK_ZLEVEL</source>
<translation>Change layer order</translation>
</message>
+ <message>
+ <source>DSK_EDIT_LOCAL_CS</source>
+ <translation>Change local CS</translation>
+ </message>
<message>
<source>MEN_CREATE_CALCULATION</source>
<translation>Create calculation case</translation>
<source>MEN_ZLEVEL</source>
<translation>Change layer order</translation>
</message>
+ <message>
+ <source>MEN_EDIT_LOCAL_CS</source>
+ <translation>Change local CS</translation>
+ </message>
<message>
<source>STB_CREATE_CALCULATION</source>
<translation>Create calculation case</translation>
<source>STB_ZLEVEL</source>
<translation>Change layer order</translation>
</message>
+ <message>
+ <source>STB_EDIT_LOCAL_CS</source>
+ <translation>Change local CS</translation>
+ </message>
</context>
<context>
</message>
</context>
+ <context>
+ <name>HYDROGUI_LocalCSOp</name>
+ <message>
+ <source>EDIT_LOCAL_CS</source>
+ <translation>Local CS transformation</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_ImportGeomObjectOp</name>
<message>
HYDROData_SequenceOfObjects FindObjectsByNames( const QStringList& theNames,
const ObjectKind theKind = KIND_UNKNOWN );
+ void SetLocalCS( double, double );
+
protected:
//! Creates new document: private because "Document" method must be used instead of direct creation.