return anEmptyList;
}
-void HYDROData_Entity::Update( const bool theIsForce )
+void HYDROData_Entity::Update()
{
}
HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
/**
- * Updates object state.
- * Base implementation dose nothing.
- * \param theIsForce force reupdating of data object
+ * Updates object state. Base implementation dose nothing.
*/
- HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
+ HYDRODATA_EXPORT virtual void Update();
/**
* Returns data of object wrapped to QVariant.
#include "HYDROData_Image.h"
#include "HYDROData_Document.h"
+#include "HYDROData_Lambert93.h"
#include "HYDROData_Tool.h"
#include "HYDROData_OperationsFactory.h"
{
QStringList aResList;
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
if ( aDocument.IsNull() )
return aResList;
aResList << QString( "%1.SetOperatorName( \"%2\" );" )
.arg( anImageName ).arg( anOperatorName );
- ImageComposer_Operator* anImageOp = HYDROData_OperationsFactory::Factory()->Operator( this );
+ ImageComposer_Operator* anImageOp =
+ HYDROData_OperationsFactory::Factory()->Operator( OperatorName() );
if ( anImageOp )
{
// Dump operation arguments
// Necessary to update image in case of composed operator
aResList << QString( "" );
- aResList << QString( "%1.Update( False );" ).arg( anImageName );
+ aResList << QString( "%1.Update();" ).arg( anImageName );
}
return aResList;
}
-void HYDROData_Image::Update( const bool theIsForce )
+void HYDROData_Image::Update()
{
HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
- // Update image only if there is an operation
ImageComposer_Operator* anOp = aFactory->Operator( OperatorName() );
- if ( anOp )
+ if ( anOp ) // Update image if there is an operation
{
// Fill by arguments and process the operation
QVariant anObj1, anObj2;
ImageComposer_Image aResImg = anOp->process( anObj1, anObj2 );
SetImage( aResImg );
}
+ else // Update image if it positioned relatively to other image
+ {
+ UpdateTrsf();
+ }
- if ( theIsForce )
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( !aDocument.IsNull() )
{
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
- if ( !aDocument.IsNull() )
- {
- // Change the states of this and all depended images
- MustBeUpdated( true );
- HYDROData_Tool::SetMustBeUpdatedImages( aDocument );
- MustBeUpdated( false );
- }
+ // Change the states of this and all depended images
+ MustBeUpdated( true );
+ HYDROData_Tool::SetMustBeUpdatedImages( aDocument );
+ MustBeUpdated( false );
}
}
aRefTransform = aRefImage->Trsf();
}
+ bool anIsByTwoPoints = IsByTwoPoints();
+
+ // Convert lambert coordinates to cartesian
+ if ( aTrsfMode == ManualLambert )
+ {
+ double aXCart = 0, aYCart = 0;
+
+ HYDROData_Lambert93::toXY( aTrsfPointA.x(), aTrsfPointA.y(), aXCart, aYCart );
+ aTrsfPointA = QPointF( aXCart, aYCart );
+
+ HYDROData_Lambert93::toXY( aTrsfPointB.x(), aTrsfPointB.y(), aXCart, aYCart );
+ aTrsfPointB = QPointF( aXCart, aYCart );
+
+ if ( !anIsByTwoPoints )
+ {
+ HYDROData_Lambert93::toXY( aTrsfPointC.x(), aTrsfPointC.y(), aXCart, aYCart );
+ aTrsfPointC = QPointF( aXCart, aYCart );
+ }
+ }
+
// generate third points if needed
- if ( IsByTwoPoints() )
+ if ( anIsByTwoPoints )
{
aPointC = generateThirdPoint( aPointA, aPointB, true ).toPoint();
aTrsfPointC = generateThirdPoint( aTrsfPointA, aTrsfPointB, anIsRefImage );
if( !anIsInvertible )
return;
- QTransform aResTransform;
+ QTransform aResTransform = aTransform1Inverted * aTransform2;
if( anIsRefImage )
- aResTransform = aTransform1Inverted * aTransform2 * aRefTransform;
- else
- aResTransform = aTransform1Inverted * aTransform2;
+ aResTransform *= aRefTransform;
SetTrsf( aResTransform );
}
return aPointC.x() < 0 && aPointC.y() < 0;
}
+bool HYDROData_Image::HasReferences() const
+{
+ Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
+ int aNbReferences = NbReferences();
+
+ return !aRefImage.IsNull() || aNbReferences > 0;
+}
+
+void HYDROData_Image::RemoveAllReferences()
+{
+ if ( !HasReferences() )
+ return;
+
+ Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
+ if ( !aRefImage.IsNull() )
+ {
+ RemoveTrsfReferenceImage();
+ }
+ else
+ {
+ ClearReferences();
+ SetOperatorName( "" );
+ SetArgs( "" );
+ SetIsSelfSplitted( false );
+ }
+
+ MustBeUpdated( false );
+
+ bool anIsByTwoPoints = IsByTwoPoints();
+
+ QImage anImage = Image();
+ if ( anImage.isNull() )
+ return;
+
+ // Set local points to default position
+ QPoint aLocalPointA = QPoint( 0, 0 );
+ QPoint aLocalPointB = QPoint( anImage.width(), 0 );
+ QPoint aLocalPointC = anIsByTwoPoints ? QPoint( INT_MIN, INT_MIN ) : QPoint( 0, anImage.height() );
+
+ SetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC, false );
+
+ // Calculate global points
+ QTransform aTransform = Trsf();
+
+ QPointF aTrsfPointA = QPointF( aTransform.map( aLocalPointA ) );
+ QPointF aTrsfPointB = QPointF( aTransform.map( aLocalPointB ) );
+ QPointF aTrsfPointC = anIsByTwoPoints ? QPointF( INT_MIN, INT_MIN ) :
+ QPointF( aTransform.map( aLocalPointC ) );
+
+ SetGlobalPoints( ManualCartesian, aTrsfPointA, aTrsfPointB, aTrsfPointC );
+}
+
void HYDROData_Image::SetLocalPoints( const QPoint& thePointA,
const QPoint& thePointB,
- const QPoint& thePointC )
+ const QPoint& thePointC,
+ const bool theIsUpdate )
{
Handle(TDataStd_RealArray) anArray;
if ( !myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
TDataStd_UAttribute::Set( myLab.FindChild( DataTag_TrsfPoints ), GUID_HAS_LOCAL_POINTS );
- UpdateTrsf();
+ if ( theIsUpdate )
+ UpdateTrsf();
}
bool HYDROData_Image::GetLocalPoints( QPoint& thePointA,
void HYDROData_Image::SetGlobalPoints( const TransformationMode& theMode,
const QPointF& thePointA,
const QPointF& thePointB,
- const QPointF& thePointC )
+ const QPointF& thePointC,
+ const bool theIsUpdate )
{
Handle(TDataStd_RealArray) anArray;
if ( !myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
TDataStd_UAttribute::Set( myLab.FindChild( DataTag_TrsfPoints ), GUID_HAS_GLOBAL_POINTS );
- UpdateTrsf();
+ if ( theIsUpdate )
+ UpdateTrsf();
/*
if( anIsRefImage )
void HYDROData_Image::SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
const QPointF& thePointA,
const QPointF& thePointB,
- const QPointF& thePointC )
+ const QPointF& thePointC,
+ const bool theIsUpdate )
{
SetTrsfReferenceImage( theRefImage );
- SetGlobalPoints( ReferenceImage, thePointA, thePointB, thePointC );
-
- UpdateTrsf();
+ SetGlobalPoints( ReferenceImage, thePointA, thePointB, thePointC, theIsUpdate );
}
bool HYDROData_Image::GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
return Handle(HYDROData_Image)::DownCast( GetReferenceObject( DataTag_TrsfImage ) );
}
+void HYDROData_Image::RemoveTrsfReferenceImage()
+{
+ return RemoveReferenceObject( DataTag_TrsfImage );
+}
+
void HYDROData_Image::AppendReference( const Handle(HYDROData_Entity)& theReferenced )
{
AddReferenceObject( theReferenced, 0 );
* Reimplemented to update an Image object in the data structure.
* Call this method whenever you made changes for operator or reference objects.
* If it is changed, sets "MustBeUpdated" flag to other depended images.
- * \param theIsForce force reupdating of data object
*/
- HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
+ HYDRODATA_EXPORT virtual void Update();
/**
* Returns data of object wrapped to QVariant.
HYDRODATA_EXPORT bool IsByTwoPoints() const;
+ /**
+ * Removes all references from this image.
+ */
+ HYDRODATA_EXPORT bool HasReferences() const;
+
+ /**
+ * Removes all references from this image.
+ */
+ HYDRODATA_EXPORT void RemoveAllReferences();
+
+
/**
* Stores the transformation points in local cs of image
* \param thePointA point A
*/
HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
const QPoint& thePointB,
- const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ) );
+ const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
+ const bool theIsUpdate = true );
/**
* Returns the transformation points in local cs of image
HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
const QPointF& thePointA,
const QPointF& thePointB,
- const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ) );
+ const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
+ const bool theIsUpdate = true );
/**
* Returns the transformation points in global cs
HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
const QPointF& thePointA,
const QPointF& thePointB,
- const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ) );
+ const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
+ const bool theIsUpdate = true );
/**
* Returns the transformation points in reference image local cs
*/
HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
+ /**
+ * Removes the reference image for transformation
+ */
+ HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
+
/**
* Stores the transformation mode
*/
HYDRODATA_EXPORT void ClearReferences();
+
/**
* Stores the operator name
* \param theOpName name of the operator that must be executed for image update
if ( anImage.IsNull() || anImage->MustBeUpdated() )
continue;
+ Handle(HYDROData_Image) aTrsfRefImage = anImage->GetTrsfReferenceImage();
+ if ( !aTrsfRefImage.IsNull() && aTrsfRefImage->MustBeUpdated() )
+ {
+ anImage->MustBeUpdated( true );
+ aChanged = true;
+ continue;
+ }
+
for ( int i = 0, aNBRefs = anImage->NbReferences(); i < aNBRefs; ++i )
{
Handle(HYDROData_Image) aRefImage =
HYDROGUI_PrsZone.h
HYDROGUI_PrsZoneDriver.h
HYDROGUI_Region.h
+ HYDROGUI_RemoveImageRefsOp.h
HYDROGUI_Shape.h
HYDROGUI_ShowHideOp.h
HYDROGUI_Tool.h
HYDROGUI_PrsZone.cxx
HYDROGUI_PrsZoneDriver.cxx
HYDROGUI_Region.cxx
+ HYDROGUI_RemoveImageRefsOp.cxx
HYDROGUI_Shape.cxx
HYDROGUI_ShowHideOp.cxx
HYDROGUI_Tool.cxx
anImageObj->SetName( anImageName );
anImageObj->SetImage( myImage );
- anImageObj->SetLocalPoints( aPointA, aPointB, aPointC );
+ anImageObj->SetLocalPoints( aPointA, aPointB, aPointC, false );
if ( aTransformationMode == HYDROData_Image::ReferenceImage )
{
bool anIsImage = false;
bool anIsImportedImage = false;
- bool anIsCompositeImage = false;
+ bool anIsImageHasRefs = false;
bool anIsFusedImage = false;
bool anIsCutImage = false;
bool anIsSplittedImage = false;
if( !anImage.IsNull() )
{
anIsImportedImage = anImage->HasLocalPoints() && !anImage->IsSelfSplitted();
- anIsCompositeImage = anImage->NbReferences() > 0;
+ anIsImageHasRefs = anImage->HasReferences();
if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
{
if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
{
if( anIsImportedImage )
theMenu->addAction( action( EditImportedImageId ) );
- else if( anIsCompositeImage )
+ else if( anIsImageHasRefs )
{
if( anIsFusedImage )
theMenu->addAction( action( EditFusedImageId ) );
theMenu->addAction( action( ExportImageId ) );
theMenu->addSeparator();
+ if( anIsImageHasRefs )
+ {
+ theMenu->addAction( action( RemoveImageRefsId ) );
+ theMenu->addSeparator();
+ }
+
theMenu->addAction( action( FuseImagesId ) );
theMenu->addAction( action( CutImagesId ) );
theMenu->addAction( action( SplitImageId ) );
#include "HYDROGUI_Operations.h"
#include "HYDROGUI_CopyPasteOp.h"
+#include "HYDROGUI_CalculationOp.h"
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_DeleteOp.h"
#include "HYDROGUI_ExportImageOp.h"
#include "HYDROGUI_ImportImageOp.h"
#include "HYDROGUI_ImportBathymetryOp.h"
-#include "HYDROGUI_CalculationOp.h"
+#include "HYDROGUI_ImmersibleZoneOp.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_ObserveImageOp.h"
#include "HYDROGUI_PolylineOp.h"
+#include "HYDROGUI_RemoveImageRefsOp.h"
#include "HYDROGUI_ShowHideOp.h"
#include "HYDROData_SplitToZonesTool.h"
#include "HYDROGUI_TwoImagesOp.h"
#include "HYDROGUI_UpdateFlags.h"
#include "HYDROGUI_UpdateImageOp.h"
#include "HYDROGUI_VisualStateOp.h"
-#include "HYDROGUI_ImmersibleZoneOp.h"
#include <CAM_Application.h>
createAction( ObserveImageId, "OBSERVE_IMAGE" );
createAction( ExportImageId, "EXPORT_IMAGE" );
createAction( UpdateImageId, "UPDATE_IMAGE" );
+ createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE" );
createAction( CreatePolylineId, "CREATE_POLYLINE" );
createAction( EditPolylineId, "EDIT_POLYLINE" );
case UpdateImageId:
anOp = new HYDROGUI_UpdateImageOp( aModule );
break;
+ case RemoveImageRefsId:
+ anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
+ break;
case CreatePolylineId:
case EditPolylineId:
anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
ObserveImageId,
ExportImageId,
UpdateImageId,
+ RemoveImageRefsId,
CreatePolylineId,
EditPolylineId,
--- /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_RemoveImageRefsOp.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
+
+HYDROGUI_RemoveImageRefsOp::HYDROGUI_RemoveImageRefsOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "REMOVE_IMAGE_REFERENCE" ) );
+}
+
+HYDROGUI_RemoveImageRefsOp::~HYDROGUI_RemoveImageRefsOp()
+{
+}
+
+void HYDROGUI_RemoveImageRefsOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ startDocOperation();
+
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
+ for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Image) anImage =
+ Handle(HYDROData_Image)::DownCast( aSeq.Value( anIndex ) );
+ if ( !anImage.IsNull() )
+ anImage->RemoveAllReferences();
+ }
+
+ commitDocOperation();
+
+ module()->update( UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced );
+ commit();
+}
--- /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_RemoveImageRefsOp_H
+#define HYDROGUI_RemoveImageRefsOp_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_RemoveImageRefsOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_RemoveImageRefsOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_RemoveImageRefsOp();
+
+protected:
+ virtual void startOperation();
+};
+
+#endif
<source>DSK_REDO</source>
<translation>Redo</translation>
</message>
+ <message>
+ <source>DSK_REMOVE_IMAGE_REFERENCE</source>
+ <translation>Remove reference</translation>
+ </message>
<message>
<source>DSK_SAVE_VISUAL_STATE</source>
<translation>Save visual state</translation>
<source>MEN_REDO</source>
<translation>Redo</translation>
</message>
+ <message>
+ <source>MEN_REMOVE_IMAGE_REFERENCE</source>
+ <translation>Remove reference</translation>
+ </message>
<message>
<source>MEN_SAVE_VISUAL_STATE</source>
<translation>Save visual state</translation>
<source>STB_REDO</source>
<translation>Redo</translation>
</message>
+ <message>
+ <source>STB_REMOVE_IMAGE_REFERENCE</source>
+ <translation>Remove reference</translation>
+ </message>
<message>
<source>STB_SAVE_VISUAL_STATE</source>
<translation>Save visual state</translation>
<translation>Update image</translation>
</message>
</context>
-
+
+ <context>
+ <name>HYDROGUI_ObserveImageOp</name>
+ <message>
+ <source>OBSERVE_IMAGE</source>
+ <translation>Observe image</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>HYDROGUI_PolylineDlg</name>
+ <message>
+ <source>ADD_ELEMENT</source>
+ <translation>Add element</translation>
+ </message>
+ <message>
+ <source>CURVE_NAME_TLT</source>
+ <translation>Name</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_PolylineOp</name>
<message>
<translation>Edit polyline</translation>
</message>
</context>
-
+
+ <context>
+ <name>HYDROGUI_RemoveImageRefsOp</name>
+ <message>
+ <source>REMOVE_IMAGE_REFERENCE</source>
+ <translation>Remove image reference</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_ShowHideOp</name>
<message>
</message>
</context>
- <context>
- <name>HYDROGUI_ObserveImageOp</name>
- <message>
- <source>OBSERVE_IMAGE</source>
- <translation>Observe image</translation>
- </message>
- </context>
-
- <context>
- <name>HYDROGUI_PolylineDlg</name>
- <message>
- <source>ADD_ELEMENT</source>
- <translation>Add element</translation>
- </message>
- <message>
- <source>CURVE_NAME_TLT</source>
- <translation>Name</translation>
- </message>
- </context>
-
<context>
<name>HYDROGUI_TwoImagesDlg</name>
<message>