set(PROJECT_HEADERS
HYDROGUI.h
+ HYDROGUI_AISCurve.h
HYDROGUI_ColorWidget.h
HYDROGUI_DataModel.h
HYDROGUI_DataObject.h
HYDROGUI_TwoImagesDlg.h
HYDROGUI_TwoImagesOp.h
HYDROGUI_UpdateFlags.h
+ HYDROGUI_UpdateImageOp.h
HYDROGUI_VisualStateOp.h
- HYDROGUI_AISCurve.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
set(PROJECT_SOURCES
+ HYDROGUI_AISCurve.cxx
HYDROGUI_ColorWidget.cxx
HYDROGUI_DataModel.cxx
HYDROGUI_DataObject.cxx
HYDROGUI_Tool.cxx
HYDROGUI_TwoImagesDlg.cxx
HYDROGUI_TwoImagesOp.cxx
+ HYDROGUI_UpdateImageOp.cxx
HYDROGUI_VisualStateOp.cxx
- HYDROGUI_AISCurve.cxx
)
add_definitions(
RelativePath=".\HYDROGUI_TwoImagesOp.cxx"
>
</File>
+ <File
+ RelativePath=".\HYDROGUI_UpdateImageOp.cxx"
+ >
+ </File>
<File
RelativePath=".\HYDROGUI_VisualStateOp.cxx"
>
RelativePath=".\HYDROGUI_UpdateFlags.h"
>
</File>
+ <File
+ RelativePath=".\HYDROGUI_UpdateImageOp.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ Outputs="moc/moc_$(InputName).cxx"
+ />
+ </FileConfiguration>
+ </File>
<File
RelativePath=".\HYDROGUI_VisualStateOp.h"
>
RelativePath=".\moc\moc_HYDROGUI_TwoImagesOp.cxx"
>
</File>
+ <File
+ RelativePath=".\moc\moc_HYDROGUI_UpdateImageOp.cxx"
+ >
+ </File>
<File
RelativePath=".\moc\moc_HYDROGUI_VisualStateOp.cxx"
>
#include "HYDROGUI_DataObject.h"
+#include <HYDROData_Image.h>
+
#include <SUIT_DataObject.h>
#include <TDF_Tool.hxx>
return QString();
}
+QFont HYDROGUI_DataObject::font( const int theId ) const
+{
+ QFont aFont = LightApp_DataObject::font( theId );
+ if( theId == NameId )
+ {
+ Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( modelObject() );
+ if( !anImage.IsNull() && anImage->MustBeUpdated() )
+ aFont.setItalic( true );
+ }
+ return aFont;
+}
+
QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Object)& theObject )
{
QString aEntryStr = QString::null;
*/
virtual QString name() const;
+ /**
+ * Returns the font of displayed object name.
+ */
+ virtual QFont font( const int = SUIT_DataObject::NameId ) const;
+
/**
* Returns the model data object.
*/
{
HYDROGUI_Operation::startOperation();
+ HYDROData_SequenceOfObjects aFullSeq; // selected objects with their back-references
+ QStringList aFullNames;
+
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
if( !aSeq.IsEmpty() )
{
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() )
+ {
+ aFullSeq.Append( anObject );
+ aFullNames.append( anObject->GetName() );
+
+ // collect the back-references
+ ObjectKind aKind = anObject->GetKind();
+ if( aKind == KIND_IMAGE || aKind == KIND_POLYLINE )
+ {
+ HYDROData_SequenceOfObjects anObjects;
+ QStringList aNames;
+ HYDROGUI_Tool::GetObjectBackReferences( module(), anObject, anObjects, aNames );
+ aFullSeq.Append( anObjects );
+ aFullNames.append( aNames );
+ }
+ }
+ }
+
+ aFullNames.removeDuplicates();
+ aFullNames.sort();
+
+ QString aList = aFullNames.join( "\n" );
int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(),
tr( "DELETE_OBJECTS" ),
- tr( "CONFIRM_DELETION" ),
+ tr( "CONFIRM_DELETION" ).arg( aList ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No );
if( anAnswer == QMessageBox::No )
}
startDocOperation();
- for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+ for( Standard_Integer anIndex = 1, aLength = aFullSeq.Length(); anIndex <= aLength; anIndex++ )
{
- Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
- if( !anObject.IsNull() )
+ Handle(HYDROData_Object) anObject = aFullSeq.Value( anIndex );
+ if( !anObject.IsNull() && !anObject->IsRemoved() )
anObject->Remove();
}
commitDocOperation();
#include <HYDROData_Iterator.h>
+#include <HYDROOperations_Factory.h>
+
#include <GraphicsView_ViewManager.h>
#include <GraphicsView_ViewPort.h>
#include <GraphicsView_Viewer.h>
// must be done after all checks and before calling SetVisible() method below
closePreview();
- anImageObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
+ if( !myIsEdit )
+ anImageObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
+
+ if( myIsEdit )
+ if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
+ aFactory->UpdateImage( doc(), anImageObj );
theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
return true;
bool anIsImage = false;
bool anIsCompositeImage = false;
+ bool anIsMustBeUpdatedImage = false;
bool anIsPolyline = false;
bool anIsVisualState = false;
anIsImage = true;
Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
if( !anImage.IsNull() )
+ {
anIsCompositeImage = anImage->NbReferences() > 0;
+ anIsMustBeUpdatedImage = anImage->MustBeUpdated();
+ }
}
else if( anObject->GetKind() == KIND_POLYLINE )
anIsPolyline = true;
theMenu->addAction( action( SaveVisualStateId ) );
theMenu->addSeparator();
}
- else if( anIsSelection && aSeq.Length() == 1 )
+
+ if( anIsSelection && anIsMustBeUpdatedImage )
+ {
+ theMenu->addAction( action( UpdateImageId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsSelection && aSeq.Length() == 1 )
{
if( anIsImage )
{
// from one of the methods called below
setUpdateEnabled( false );
- if( ( flags & UF_Model ) && getDataModel() )
+ if( ( flags & UF_Model ) && getDataModel() && getApp() )
+ {
getDataModel()->update( getStudyId() );
- if( ( flags & UF_ObjBrowser ) && getApp() )
+ // Temporary workaround to prevent breaking
+ // the selection in the object browser
+ qApp->processEvents();
getApp()->updateObjectBrowser( true );
+ }
+
+ // Object browser is currently updated by using UF_Model flag
+ //if( ( flags & UF_ObjBrowser ) && getApp() )
+ // getApp()->updateObjectBrowser( true );
if( ( flags & UF_Viewer ) )
updateGV( flags & UF_GV_Init,
#include "HYDROGUI_ShowHideOp.h"
#include "HYDROGUI_TwoImagesOp.h"
#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_UpdateImageOp.h"
#include "HYDROGUI_VisualStateOp.h"
#include <CAM_Application.h>
createAction( EditCompositeImageId, "EDIT_COMPOSITE_IMAGE" );
createAction( ObserveImageId, "OBSERVE_IMAGE" );
createAction( ExportImageId, "EXPORT_IMAGE" );
+ createAction( UpdateImageId, "UPDATE_IMAGE" );
createAction( CreatePolylineId, "CREATE_POLYLINE" );
createAction( EditPolylineId, "EDIT_POLYLINE" );
case ExportImageId:
anOp = new HYDROGUI_ExportImageOp( aModule );
break;
+ case UpdateImageId:
+ anOp = new HYDROGUI_UpdateImageOp( aModule );
+ break;
case CreatePolylineId:
case EditPolylineId:
anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
EditCompositeImageId,
ObserveImageId,
ExportImageId,
+ UpdateImageId,
CreatePolylineId,
EditPolylineId,
if( !aParent )
return aRect;
- QTransform aTransform = aParent->getViewTransform();
- double aScale = aTransform.m11(); // same as m22(), viewer specific
- if( fabs( aScale ) < EPSILON )
+ // take into account a transformation of the base image item
+ double aXScale = 1.0;
+ double aYScale = 1.0;
+ if( QGraphicsItem* aGrandParent = aParent->parentItem() )
+ {
+ QTransform aTransform = aGrandParent->transform();
+ QLineF aLine( 0, 0, 1, 1 );
+ aLine = aTransform.map( aLine );
+ aXScale = aLine.dx();
+ aYScale = aLine.dy();
+ }
+
+ QTransform aViewTransform = aParent->getViewTransform();
+ double aScale = aViewTransform.m11(); // same as m22(), viewer specific
+ if( fabs( aScale ) < EPSILON || fabs( aXScale ) < EPSILON || fabs( aYScale ) < EPSILON)
return aRect;
QPointF aCenter = aRect.center();
- double aWidth = aRect.width() / aScale;
- double aHeight = aRect.height() / aScale;
+ double aWidth = aRect.width() / aScale / aXScale;
+ double aHeight = aRect.height() / aScale / aYScale;
aRect = QRectF( aCenter.x() - aWidth / 2, aCenter.y() - aHeight / 2, aWidth, aHeight );
return aRect;
thePainter->save();
thePainter->setTransform( GenerateTranslationOnlyTransform( thePainter->transform(),
myBasePoint ) );
-
QGraphicsEllipseItem::paint( thePainter, theOption, theWidget );
thePainter->restore();
}
}
return aList;
}
+
+void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage,
+ HYDROData_SequenceOfObjects& theRefObjects,
+ QStringList& theRefNames )
+{
+ if( theImage.IsNull() )
+ return;
+
+ for( int anIndex = 0, aNbRef = theImage->NbReferences(); anIndex < aNbRef; anIndex++ )
+ {
+ Handle(HYDROData_Image) aRefImage = theImage->Reference( anIndex );
+ if( !aRefImage.IsNull() && !aRefImage->IsRemoved() )
+ {
+ QString aName = aRefImage->GetName();
+ if( !theRefNames.contains( aName ) )
+ {
+ theRefObjects.Append( aRefImage );
+ theRefNames.append( aRefImage->GetName() );
+ GetObjectReferences( aRefImage, theRefObjects, theRefNames );
+ }
+ }
+ }
+}
+
+void HYDROGUI_Tool::GetObjectBackReferences( HYDROGUI_Module* theModule,
+ const Handle(HYDROData_Object)& theObj,
+ HYDROData_SequenceOfObjects& theBackRefObjects,
+ QStringList& theBackRefNames )
+{
+ if( theObj.IsNull() )
+ return;
+
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
+ if( aDocument.IsNull() )
+ return;
+
+ QString aName = theObj->GetName();
+
+ HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
+ if( !anImage.IsNull() )
+ {
+ HYDROData_SequenceOfObjects aRefObjects;
+ QStringList aRefNames;
+ GetObjectReferences( anImage, aRefObjects, aRefNames );
+ if( aRefNames.contains( aName ) )
+ {
+ theBackRefObjects.Append( anImage );
+ theBackRefNames.append( anImage->GetName() );
+ }
+ }
+ }
+}
#ifndef HYDROGUI_TOOL_H
#define HYDROGUI_TOOL_H
-#include <HYDROData_Object.h>
+#include <HYDROData_Image.h>
#include <GraphicsView_Defs.h>
#include <GraphicsView_ViewPort.h>
* \return list of view ids
*/
static QList<size_t> GetGraphicsViewIdList( HYDROGUI_Module* theModule );
+
+ /**
+ * \brief Get the list of references (recursively) for the specified image object
+ * \param theImage image data object
+ * \param theRefObjects list of reference objects
+ * \param theRefNames list of reference object names
+ */
+ static void GetObjectReferences( const Handle(HYDROData_Image)& theImage,
+ HYDROData_SequenceOfObjects& theRefObjects,
+ QStringList& theRefNames );
+
+ /**
+ * \brief Get the list of back-references for the specified object
+ * \param theModule module
+ * \param theObj data object
+ * \param theBackRefObjects list of back-reference objects
+ * \param theBackRefNames list of back-reference object names
+ */
+ static void GetObjectBackReferences( HYDROGUI_Module* theModule,
+ const Handle(HYDROData_Object)& theObj,
+ HYDROData_SequenceOfObjects& theBackRefObjects,
+ QStringList& theBackRefNames );
};
#endif
aResult->AppendReference( anImage2 );
aFactory->UpdateImage( doc(), aResult );
- size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
- anImage1->SetVisible( aViewId, false );
- anImage2->SetVisible( aViewId, false );
- aResult->SetVisible( aViewId, true );
+ if( !myIsEdit )
+ {
+ size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+ anImage1->SetVisible( aViewId, false );
+ anImage2->SetVisible( aViewId, false );
+ aResult->SetVisible( aViewId, true );
+ }
theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
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
+//
+
+#include "HYDROGUI_UpdateImageOp.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
+
+#include <HYDROOperations_Factory.h>
+
+HYDROGUI_UpdateImageOp::HYDROGUI_UpdateImageOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "UPDATE_IMAGE" ) );
+}
+
+HYDROGUI_UpdateImageOp::~HYDROGUI_UpdateImageOp()
+{
+}
+
+void HYDROGUI_UpdateImageOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ startDocOperation();
+
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Image) anImage =
+ Handle(HYDROData_Image)::DownCast( aSeq.Value( anIndex ) );
+ if( !anImage.IsNull() && anImage->MustBeUpdated() )
+ {
+ HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
+ aFactory->UpdateImage( doc(), anImage );
+ }
+ }
+
+ commitDocOperation();
+
+ module()->update( UF_Model | UF_Viewer | UF_GV_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_UPDATEIMAGEOP_H
+#define HYDROGUI_UPDATEIMAGEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_UpdateImageOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_UpdateImageOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_UpdateImageOp();
+
+protected:
+ virtual void startOperation();
+};
+
+#endif
</message>
<message>
<source>CONFIRM_DELETION</source>
- <translation>Do you really want to delete the selected object(s)?</translation>
+ <translation>The following objects (including the dependencies) will be deleted:
+%1
+Do you want to continue?</translation>
</message>
</context>
<source>DSK_UNDO</source>
<translation>Undo</translation>
</message>
+ <message>
+ <source>DSK_UPDATE_IMAGE</source>
+ <translation>Update image</translation>
+ </message>
<message>
<source>HYDRO_TOOLBAR</source>
<translation>HYDRO toolbar</translation>
<source>MEN_UNDO</source>
<translation>Undo</translation>
</message>
+ <message>
+ <source>MEN_UPDATE_IMAGE</source>
+ <translation>Update image</translation>
+ </message>
<message>
<source>STB_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
<source>STB_UNDO</source>
<translation>Undo</translation>
</message>
+ <message>
+ <source>STB_UPDATE_IMAGE</source>
+ <translation>Update image</translation>
+ </message>
</context>
<context>
<translation>Fuse</translation>
</message>
</context>
-
+
+ <context>
+ <name>HYDROGUI_UpdateImageOp</name>
+ <message>
+ <source>UPDATE_IMAGE</source>
+ <translation>Update image</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_VisualStateOp</name>
<message>