From: ouv Date: Mon, 5 Aug 2013 10:03:32 +0000 (+0000) Subject: 1) HYDRO: Import Image operation. X-Git-Tag: BR_hydro_v_0_1~136 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d74afc6389ed4e656c9451ac01b4065470746fd8;p=modules%2Fhydro.git 1) HYDRO: Import Image operation. 2) Moving Presentation classes from GraphicsView to HYDROGUI. 3) Raw development. --- diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 763153a3..e1e930e9 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -3,6 +3,7 @@ #include +#include #include #include @@ -64,6 +65,11 @@ public: */ HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const; + /** + * Returns the label of this object. + */ + HYDRODATA_EXPORT TDF_Label& Label() {return myLab;} + protected: friend class HYDROData_Iterator; @@ -85,11 +91,6 @@ protected: */ HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel); - /** - * Returns the label of this object. - */ - TDF_Label& Label() {return myLab;} - /** * Internal method that used to store the byte array attribute * \param theTag tag of a label to store attribute (for 0 this is myLab) @@ -112,6 +113,8 @@ protected: TDF_Label myLab; ///< label of this object }; +typedef NCollection_Sequence HYDROData_SequenceOfObjects; + ///! Is Equal for HYDROData_Object mapping HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2); diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 8b446acf..26983785 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -6,6 +6,8 @@ set(PROJECT_HEADERS HYDROGUI_ColorWidget.h HYDROGUI_DataModel.h HYDROGUI_DataObject.h + HYDROGUI_Displayer.h + HYDROGUI_GVSelector.h HYDROGUI_ImportImageDlg.h HYDROGUI_ImportImageOp.h HYDROGUI_InputPanel.h @@ -13,8 +15,15 @@ set(PROJECT_HEADERS HYDROGUI_ObjSelector.h HYDROGUI_Operation.h HYDROGUI_Operations.h + HYDROGUI_Prs.h + HYDROGUI_PrsDriver.h + HYDROGUI_PrsImage.h + HYDROGUI_PrsImageDriver.h + HYDROGUI_PrsImageFrame.h + HYDROGUI_Tool.h HYDROGUI_TwoImagesDlg.h HYDROGUI_TwoImagesOp.h + HYDROGUI_UpdateFlags.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -23,6 +32,8 @@ set(PROJECT_SOURCES HYDROGUI_ColorWidget.cxx HYDROGUI_DataModel.cxx HYDROGUI_DataObject.cxx + HYDROGUI_Displayer.cxx + HYDROGUI_GVSelector.cxx HYDROGUI_ImportImageDlg.cxx HYDROGUI_ImportImageOp.cxx HYDROGUI_InputPanel.cxx @@ -31,6 +42,12 @@ set(PROJECT_SOURCES HYDROGUI_Operation.cxx HYDROGUI_Operations.cxx HYDROGUI_TwoImagesDlg.cxx + HYDROGUI_Prs.cxx + HYDROGUI_PrsDriver.cxx + HYDROGUI_PrsImage.cxx + HYDROGUI_PrsImageDriver.cxx + HYDROGUI_PrsImageFrame.cxx + HYDROGUI_Tool.cxx HYDROGUI_TwoImagesOp.cxx ) diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index c2ed94bd..a2fda47a 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -97,7 +97,7 @@ bool HYDROGUI_DataModel::open( const QString& theURL, bool HYDROGUI_DataModel::save( QStringList& theFileList ) { - if (!module()->application()->activeStudy()) + if( !module()->application()->activeStudy() ) return false; const int aStudyId = module()->application()->activeStudy()->id(); @@ -145,8 +145,8 @@ bool HYDROGUI_DataModel::close() bool HYDROGUI_DataModel::isModified() const { - int aStudyID = module()->application()->activeStudy()->id(); - return HYDROData_Document::Document( aStudyID )->IsModified(); + int aStudyId = module()->application()->activeStudy()->id(); + return HYDROData_Document::Document( aStudyId )->IsModified(); } bool HYDROGUI_DataModel::isSaved() const @@ -209,13 +209,8 @@ HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataO SUIT_DataObject* HYDROGUI_DataModel::findObject( const QString& theEntry ) const { - SUIT_DataObject* anObject = HYDROGUI_DataObject::objectByEntry( theEntry ); - if( !anObject ) - { - LightApp_Application* anApp = dynamic_cast( module()->application() ); - anObject = anApp ? anApp->findObject( theEntry ) : 0; - } - return anObject; + LightApp_Application* anApp = dynamic_cast( module()->application() ); + return anApp ? anApp->findObject( theEntry ) : 0; } void HYDROGUI_DataModel::update( LightApp_DataObject* theObject, @@ -241,6 +236,28 @@ void HYDROGUI_DataModel::updateModel() update( aModule->getStudyId() ); } +Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry, + const ObjectKind theObjectKind ) +{ + const int aStudyId = module()->application()->activeStudy()->id(); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + if( !aDocument.IsNull() ) + { + HYDROData_Iterator anIterator( aDocument, theObjectKind ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Object) anObject = anIterator.Current(); + if( !anObject.IsNull() ) + { + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObject ); + if( anEntry == theEntry ) + return anObject; + } + } + } + return NULL; +} + LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent, Handle(HYDROData_Object) theModelObject ) { diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index 063d0166..84a07b79 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -23,8 +23,6 @@ #ifndef HYDROGUI_DATAMODEL_H #define HYDROGUI_DATAMODEL_H -#include "HYDROGUI.h" - #include #include @@ -36,25 +34,25 @@ class CAM_DataObject; class SUIT_DataObject; class HYDROGUI_DataObject; -/*! +/** * \class HYDROGUI_DataModel * \brief The class representing the HYDROGUI data model */ class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher { public: - /** - * Constructor. - * \param theModule module object - */ + /** + * Constructor. + * \param theModule module object + */ HYDROGUI_DataModel( CAM_Module* theModule ); virtual ~HYDROGUI_DataModel(); /** * Open the document into the data model. Reimplemented. - * /param theURL opened study path - * /param theStudy object study - * /param theFileList list of opened files for this model. + * \param theURL opened study path + * \param theStudy object study + * \param theFileList list of opened files for this model. */ virtual bool open( const QString& theURL, CAM_Study* theStudy, @@ -62,15 +60,15 @@ public: /** * Saves the document. Reimplemented. - * /param returned theFileList list of saved files of this model. + * \param returned theFileList list of saved files of this model. */ virtual bool save( QStringList& theFileList ); /** * Saves as the document. Reimplemented. - * /param theURL saved study path - * /param theStudy object study - * /param returned theFileList list of saved files of this model. + * \param theURL saved study path + * \param theStudy object study + * \param returned theFileList list of saved files of this model. */ virtual bool saveAs( const QString& theURL, CAM_Study* theStudy, @@ -83,7 +81,7 @@ public: /** * Returns modification status. Reimplemented. - * /return boolean value of modification status + * \return boolean value of modification status */ virtual bool isModified() const; @@ -121,8 +119,8 @@ public: /** * Updates the internal structure of data object tree starting from specified data object \a obj. - * /param theObject start data object - * /param theStudy study object + * \param theObject start data object + * \param theStudy study object */ virtual void update( LightApp_DataObject* theObject = 0, LightApp_Study* theStudy = 0 ); @@ -137,6 +135,12 @@ public: */ void updateModel(); + /** + * Find a data object by the specified entry and kind + */ + Handle(HYDROData_Object) objectByEntry( const QString& theEntry, + const ObjectKind theObjectKind ); + protected: /** * Creates the GUI data object according to the model object. diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index c1ff5a25..ff11aa74 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -24,22 +24,19 @@ #include +#include + HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, Handle(HYDROData_Object) theData ) : CAM_DataObject( theParent ), LightApp_DataObject( theParent ), myData( theData ) { - // unique identifier generated from pointer to this object, like: "HD_0x123457" - // "H" means "HYDRO", "D" means "data" to avoid conflicts with named objects - std::ostringstream aStream; - aStream << "HD_" << this; - myEntry = QString( aStream.str().c_str() ); } QString HYDROGUI_DataObject::entry() const { - return myEntry; + return HYDROGUI_DataObject::dataObjectEntry( modelObject() ); } QString HYDROGUI_DataObject::name() const @@ -49,17 +46,16 @@ QString HYDROGUI_DataObject::name() const return QString(); } -HYDROGUI_DataObject* HYDROGUI_DataObject::objectByEntry( const QString& theEntry ) +QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Object)& theObject ) { - static const QString aPrefixD( "HD_" ); - if ( theEntry.indexOf( aPrefixD ) != 0 ) - return NULL; // not HYDRO entry - - std::istringstream aStream( theEntry.toLatin1().constData() + 3 ); // start reading just after "HD_" - void* aPtr = 0; - aStream >> aPtr; - - return ( HYDROGUI_DataObject* )aPtr; + QString aEntryStr = QString::null; + if( !theObject.IsNull() ) + { + TCollection_AsciiString aLabEntr; + TDF_Tool::Entry( theObject->Label(), aLabEntr ); + aEntryStr = HYDROGUI_DataObject::entryPrefix() + QString( aLabEntr.ToCString() ); + } + return aEntryStr; } HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent, @@ -72,21 +68,10 @@ HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent, QString HYDROGUI_NamedObject::entry() const { - // unique identifier generated from pointer to this object, like: "HD_0x123457" - // "H" means "HYDRO", "N" means "named" to avoid conflicts with data objects - return "HN_" + myName; + return LightApp_DataObject::entry(); } QString HYDROGUI_NamedObject::name() const { return myName; } - -QString HYDROGUI_NamedObject::nameByEntry( const QString& theEntry ) -{ - static const QString aPrefixN( "HN_" ); - if( theEntry.indexOf( aPrefixN ) != 0 ) - return QString(); // not HYDRO entry - - return theEntry.right( 3 ); -} diff --git a/src/HYDROGUI/HYDROGUI_DataObject.h b/src/HYDROGUI/HYDROGUI_DataObject.h index 4e92dfff..cad33c21 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.h +++ b/src/HYDROGUI/HYDROGUI_DataObject.h @@ -23,8 +23,6 @@ #ifndef HYDROGUI_DATAOBJECT_H #define HYDROGUI_DATAOBJECT_H -#include "HYDROGUI.h" - #include #include @@ -74,15 +72,17 @@ public: void setObject( Handle(HYDROData_Object) theObject ) { myData = theObject; } /** - * Returns \a HYDROGUI_DataObject by the entry string of this object. - * \returns NULL if this is not HYDRO entry, or cannot cast to HYDROGUI_DataObject + * Returns the entry prefix for all HYDRO data objects. + */ + static QString entryPrefix() { return QString( "HYDRO_" ); } + + /** + * Returns the full entry for the specified data object. */ - static HYDROGUI_DataObject* objectByEntry( const QString& theEntry ); + static QString dataObjectEntry( const Handle(HYDROData_Object)& theObject ); protected: Handle(HYDROData_Object) myData; ///< object from data model - QString myEntry; ///< optimization: store generated entry to return it quickly - int myStudyId; ///< the study identifier: check an object validity in the corresponded document }; /** @@ -115,13 +115,6 @@ public: */ virtual QString name() const; - /** - * Returns name of the named object that is identified by this entry. - * \param theEntry entry of the object (used for selection identification). - * \returns name of the object, or empty string if it is not HYDRO named object - */ - static QString nameByEntry( const QString& theEntry ); - private: QString myName; ///< name in the OB }; diff --git a/src/HYDROGUI/HYDROGUI_Displayer.cxx b/src/HYDROGUI/HYDROGUI_Displayer.cxx new file mode 100644 index 00000000..fd75ba44 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Displayer.cxx @@ -0,0 +1,249 @@ +// 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_Displayer.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Prs.h" +#include "HYDROGUI_PrsImageDriver.h" +#include "HYDROGUI_Tool.h" + +#include +#include + +HYDROGUI_Displayer::HYDROGUI_Displayer( HYDROGUI_Module* theModule ) +: myModule( theModule ) +{ +} + +HYDROGUI_Displayer::~HYDROGUI_Displayer() +{ +} + +void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId ) +{ + GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId ); + if( !aViewer ) + return; + + GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort(); + if( !aViewPort ) + return; + + GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); + for( int i = 1, n = theObjs.Length(); i <= n; i++ ) + { + Handle(HYDROData_Object) anObj = theObjs.Value( i ); + if( anObj.IsNull() ) + continue; + + if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) ) + aPrs->setIsToUpdate( true ); + } +} + +void HYDROGUI_Displayer::UpdateAll( const int theViewerId, + const bool theIsInit, + const bool theIsForced ) +{ + if( theIsInit ) + EraseAll( theViewerId ); + DisplayAll( theViewerId, theIsForced ); +} + +void HYDROGUI_Displayer::EraseAll( const int theViewerId ) +{ + GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId ); + if( !aViewer ) + return; + + GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort(); + if( !aViewPort ) + return; + + GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() ); + while( anIter.hasNext() ) + { + if( GraphicsView_Object* anObject = anIter.next() ) + { + aViewPort->removeItem( anObject ); + delete anObject; + } + } +} + +void HYDROGUI_Displayer::DisplayAll( const int theViewerId, + const bool theIsForced ) +{ + HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel(); + if( aModel ) + { + HYDROData_SequenceOfObjects aSeq; + HYDROGUI_Tool::GetPrsSubObjects( aModel, theViewerId, aSeq ); + Update( aSeq, theViewerId, theIsForced ); + } +} + +void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced ) +{ + // First of all, kill all bad presentations + purgeObjects( theViewerId ); + + // Now dig in the data model + HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay; + + for( int i = 1, n = theObjs.Length(); i <= n; i++ ) + { + const Handle(HYDROData_Object)& anObj = theObjs.Value( i ); + if( anObj.IsNull() ) + anObjectsToErase.Append( anObj ); + else + anObjectsToDisplay.Append( anObj ); + } + + if( anObjectsToErase.Length() ) + Erase( anObjectsToErase, theViewerId ); + if( anObjectsToDisplay.Length() ) + Display( anObjectsToDisplay, theViewerId, theIsForced ); +} + +void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId ) +{ + GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId ); + if( !aViewer ) + return; + + GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort(); + if( !aViewPort ) + return; + + HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel(); + if( aModel ) + { + GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); + for( int i = 1, n = theObjs.Length(); i <= n; i++ ) + { + // the object may be null or dead + const Handle(HYDROData_Object)& anObj = theObjs.Value( i ); + if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) ) + { + aViewPort->removeItem( aPrs ); + delete aPrs; + } + } + } +} + +void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced ) +{ + GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId ); + if( !aViewer ) + return; + + GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort(); + if( !aViewPort ) + return; + + bool anIsDisplayed = false; + GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); + for( int i = 1, n = theObjs.Length(); i <= n; i++ ) + { + Handle(HYDROData_Object) anObj = theObjs.Value( i ); + if( anObj.IsNull() ) + continue; + + HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ); + + bool anIsInserted = ( aPrs != 0 ); + if( !aPrs || aPrs->getIsToUpdate() || theIsForced ) + { + if( HYDROGUI_PrsDriver* aDriver = getDriver( anObj ) ) + { + if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted ) + aViewPort->addItem( aPrs ); + } + } + + if( aPrs ) + { + bool isVisible = true; // anObj->IsVisible() + aPrs->setVisible( true ); + } + } + + aViewPort->fitAll(); +} + +void HYDROGUI_Displayer::purgeObjects( const int theViewerId ) +{ + GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId ); + if( !aViewer ) + return; + + GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort(); + if( !aViewPort ) + return; + + GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() ); + while( anIter.hasNext() ) + { + GraphicsView_Object* tmp = anIter.next(); + if( HYDROGUI_Prs* aPrs = dynamic_cast( tmp ) ) + { + Handle(HYDROData_Object) anObject = aPrs->getObject(); + if( anObject.IsNull() ) + { + aViewPort->removeItem( aPrs ); + //delete aPrs; // ouv: to do + } + } + } +} + +HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Object)& theObj ) +{ + HYDROGUI_PrsDriver* aDriver = NULL; + ObjectKind aKind = theObj->GetKind(); + PrsDriversMap::iterator anIter = myPrsDriversMap.find( aKind ); + if( anIter != myPrsDriversMap.end() ) + aDriver = anIter.value(); + else + { + switch( aKind ) + { + case KIND_IMAGE: + aDriver = new HYDROGUI_PrsImageDriver(); + myPrsDriversMap[ aKind ] = aDriver; + break; + default: + break; + } + } + return aDriver; +} diff --git a/src/HYDROGUI/HYDROGUI_Displayer.h b/src/HYDROGUI/HYDROGUI_Displayer.h new file mode 100644 index 00000000..f39d9c2f --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Displayer.h @@ -0,0 +1,135 @@ +// 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_DISPLAYER_H +#define HYDROGUI_DISPLAYER_H + +#include + +#include + +class HYDROGUI_Module; +class HYDROGUI_PrsDriver; + +class GraphicsView_Viewer; + +/** + * \class HYDROGUI_DataModel + * \brief Class intended to create, display and update the presentations. + */ +class HYDROGUI_Displayer +{ +public: + /** + * \brief Constructor. + * \param theModule module object + */ + HYDROGUI_Displayer( HYDROGUI_Module* theModule ); + + /** + * \brief Destructor. + */ + virtual ~HYDROGUI_Displayer(); + +public: + /** + * \brief Force the specified objects to be updated. + * \param theObjs sequence of objects to update + * \param theViewerId viewer identifier + */ + void SetToUpdate( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId ); + + /** + * \brief Update all objects in the viewer. + * \param theViewerId viewer identifier + * \param theIsInit flag used for initial update + * \param theIsForced flag used to update all objects, including the unchanged ones + */ + void UpdateAll( const int theViewerId, + const bool theIsInit, + const bool theIsForced ); + +protected: + /** + * \brief Erase all viewer objects. + * \param theViewerId viewer identifier + */ + void EraseAll( const int theViewerId ); + + /** + * \brief Update and display all objects in the viewer. + * \param theViewerId viewer identifier + * \param theIsForced flag used to update all objects, including the unchanged ones + */ + void DisplayAll( const int theViewerId, + const bool theIsForced ); + + /** + * \brief Update the specified viewer objects. + * \param theObjs sequence of objects to update + * \param theViewerId viewer identifier + * \param theIsForced flag used to update all objects, including the unchanged ones + */ + void Update( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced ); + + /** + * \brief Erase the specified viewer objects. + * \param theObjs sequence of objects to erase + * \param theViewerId viewer identifier + */ + void Erase( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId ); + + /** + * \brief Display the specified viewer objects. + * \param theObjs sequence of objects to display + * \param theViewerId viewer identifier + * \param theIsForced flag used to update all objects, including the unchanged ones + */ + void Display( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced ); + +private: + /** + * \brief Purge all invalid objects in the viewer. + * \param theViewerId viewer identifier + */ + void purgeObjects( const int theViewerId ); + + /** + * \brief Get the presentation driver for the specified data object. + * \param theObj data object + */ + HYDROGUI_PrsDriver* getDriver( const Handle(HYDROData_Object)& theObj ); + +private: + HYDROGUI_Module* myModule; + + typedef QMap< ObjectKind, HYDROGUI_PrsDriver* > PrsDriversMap; + PrsDriversMap myPrsDriversMap; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_GVSelector.cxx b/src/HYDROGUI/HYDROGUI_GVSelector.cxx new file mode 100644 index 00000000..6f0266fa --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_GVSelector.cxx @@ -0,0 +1,88 @@ +// 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_GVSelector.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_DataObject.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Prs.h" +#include "HYDROGUI_Tool.h" + +#include +#include +#include +#include + +#include + +HYDROGUI_GVSelector::HYDROGUI_GVSelector( HYDROGUI_Module* theModule, + GraphicsView_Viewer* theViewer, + SUIT_SelectionMgr* theSelMgr ) +: LightApp_GVSelector( theViewer, theSelMgr ), + myModule( theModule ) +{ +} + +HYDROGUI_GVSelector::~HYDROGUI_GVSelector() +{ +} + +void HYDROGUI_GVSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const +{ + if( GraphicsView_ViewPort* aViewPort = myViewer->getActiveViewPort() ) + { + for( aViewPort->initSelected(); aViewPort->moreSelected(); aViewPort->nextSelected() ) + { + if( HYDROGUI_Prs* aPrs = dynamic_cast( aViewPort->selectedObject() ) ) + { + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aPrs->getObject() ); + theList.append( new LightApp_DataOwner( anEntry ) ); + } + } + } +} + +void HYDROGUI_GVSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) +{ + HYDROGUI_DataModel* aModel = myModule->getDataModel(); + if( GraphicsView_ViewPort* aViewPort = myViewer->getActiveViewPort() ) + { + aViewPort->clearSelected(); + SUIT_DataOwnerPtrList::const_iterator it; + GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); + for ( it = theList.begin(); it != theList.end(); ++it ) + { + LightApp_DataOwner* anOwner = dynamic_cast( (*it).operator->() ); + if ( anOwner ) + { + QString anEntry = anOwner->entry(); + Handle(HYDROData_Object) aModelObject = aModel->objectByEntry( anEntry, KIND_IMAGE ); + if( !aModelObject.IsNull() ) + { + if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( aModelObject, anObjectList ) ) + aViewPort->setSelected( aPrs ); + } + } + } + } +} diff --git a/src/HYDROGUI/HYDROGUI_GVSelector.h b/src/HYDROGUI/HYDROGUI_GVSelector.h new file mode 100644 index 00000000..23233b96 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_GVSelector.h @@ -0,0 +1,48 @@ +// 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_GVSELECTOR_H +#define HYDROGUI_GVSELECTOR_H + +#include + +class HYDROGUI_Module; + +class HYDROGUI_GVSelector : public LightApp_GVSelector +{ + Q_OBJECT + +public: + HYDROGUI_GVSelector( HYDROGUI_Module*, + GraphicsView_Viewer*, + SUIT_SelectionMgr* ); + virtual ~HYDROGUI_GVSelector(); + +protected: + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + virtual void setSelection( const SUIT_DataOwnerPtrList& ); + +private: + HYDROGUI_Module* myModule; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index e69de29b..b8f1ddeb 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -0,0 +1,268 @@ +// 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_ImportImageDlg.h" + +#include "HYDROGUI_PrsImage.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + // Import image from file + QGroupBox* aFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) ); + + QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileGroup ); + + myFileName = new QLineEdit( aFileGroup ); + myFileName->setReadOnly( true ); + + QToolButton* aBrowseBtn = new QToolButton( aFileGroup ); + aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); + + QBoxLayout* aFileLayout = new QHBoxLayout( aFileGroup ); + aFileLayout->setMargin( 5 ); + aFileLayout->setSpacing( 5 ); + aFileLayout->addWidget( aFileNameLabel ); + aFileLayout->addWidget( myFileName ); + aFileLayout->addWidget( aBrowseBtn ); + + // Mapping + myMappingGroup = new QGroupBox( tr( "MAPPING" ) ); + + QGridLayout* aMappingLayout = new QGridLayout( myMappingGroup ); + aMappingLayout->setMargin( 5 ); + aMappingLayout->setSpacing( 5 ); + + // Make a pixmap for arrow + QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) ); + + QPicture anArrowPicture; + anArrowPicture.setBoundingRect( QRect( QPoint( 0, 0 ), anArrowPixmap.size() ) ); + + QPainter aPainter; + aPainter.begin( &anArrowPicture ); + aPainter.drawPixmap( 0, 0, anArrowPixmap ); + aPainter.end(); + + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + QString aPointStr; + switch( aPointType ) + { + case HYDROGUI_PrsImage::PointA: aPointStr = tr( "POINT_A" ); break; + case HYDROGUI_PrsImage::PointB: aPointStr = tr( "POINT_B" ); break; + case HYDROGUI_PrsImage::PointC: aPointStr = tr( "POINT_C" ); break; + } + QPushButton* aPointBtn = new QPushButton( aPointStr, myMappingGroup ); + aPointBtn->setCheckable( true ); + + QLabel* aPointXLabel = new QLabel( tr( "X" ), myMappingGroup ); + QLabel* aPointYLabel = new QLabel( tr( "Y" ), myMappingGroup ); + + QLineEdit* aPointX1 = new QLineEdit( myMappingGroup ); + QLineEdit* aPointY1 = new QLineEdit( myMappingGroup ); + + aPointX1->setReadOnly( true ); + aPointY1->setReadOnly( true ); + + //QLabel* aPointArrowLabel = new QLabel( ">", myMappingGroup ); + QLabel* aPointArrowLabel = new QLabel( myMappingGroup ); + aPointArrowLabel->setPicture( anArrowPicture ); + + QLineEdit* aPointX2 = new QLineEdit( myMappingGroup ); + QLineEdit* aPointY2 = new QLineEdit( myMappingGroup ); + + QDoubleValidator* aDoubleValidator = new QDoubleValidator(); + aPointX2->setValidator( aDoubleValidator ); + aPointY2->setValidator( aDoubleValidator ); + + int aRow = 3 * aPointType; + aMappingLayout->addWidget( aPointBtn, aRow, 0, 2, 1 ); + aMappingLayout->addWidget( aPointXLabel, aRow, 1 ); + aMappingLayout->addWidget( aPointX1, aRow, 2 ); + aMappingLayout->addWidget( aPointArrowLabel, aRow, 3, 2, 1 ); + aMappingLayout->addWidget( aPointX2, aRow, 4 ); + aMappingLayout->addWidget( aPointYLabel, aRow + 1, 1 ); + aMappingLayout->addWidget( aPointY1, aRow + 1, 2 ); + aMappingLayout->addWidget( aPointY2, aRow + 1, 4 ); + + if( aPointType != HYDROGUI_PrsImage::PointC ) + { + QFrame* aLine = new QFrame( myMappingGroup ); + aLine->setFrameShape( QFrame::HLine ); + aLine->setFrameShadow( QFrame::Sunken ); + aMappingLayout->addWidget( aLine, aRow + 2, 0, 1, 5 ); + } + + myPointBtnMap[ aPointType ] = aPointBtn; + myPointX1Map[ aPointType ] = aPointX1; + myPointY1Map[ aPointType ] = aPointY1; + myPointX2Map[ aPointType ] = aPointX2; + myPointY2Map[ aPointType ] = aPointY2; + + connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) ); + } + + // Common + addWidget( aFileGroup, 0, 0 ); + addWidget( myMappingGroup, 1, 0 ); + + setRowStretch(); + + connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); +} + +HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg() +{ +} + +void HYDROGUI_ImportImageDlg::reset() +{ + myFileName->clear(); + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + QPushButton* aBtn = myPointBtnMap[ aPointType ]; + bool anIsBlocked = aBtn->blockSignals( true ); + aBtn->setChecked( false ); + aBtn->blockSignals( anIsBlocked ); + + myPointX1Map[ aPointType ]->clear(); + myPointY1Map[ aPointType ]->clear(); + myPointX2Map[ aPointType ]->clear(); + myPointY2Map[ aPointType ]->clear(); + } + myMappingGroup->setEnabled( false ); +} + +void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap ) +{ + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + if( theMap.contains( aPointType ) ) + { + const TransformationData& aData = theMap[ aPointType ]; + myPointX1Map[ aPointType ]->setText( QString::number( aData.first.x() ) ); + myPointY1Map[ aPointType ]->setText( QString::number( aData.first.y() ) ); + } + } +} + +bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap ) const +{ + theMap.clear(); + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + bool anIsOk = false; + int aX1 = myPointX1Map[ aPointType ]->text().toInt( &anIsOk ); + if( !anIsOk ) + return false; + + anIsOk = false; + int aY1 = myPointY1Map[ aPointType ]->text().toInt( &anIsOk ); + if( !anIsOk ) + return false; + + anIsOk = false; + double aX2 = myPointX2Map[ aPointType ]->text().toDouble( &anIsOk ); + if( !anIsOk ) + return false; + + anIsOk = false; + double aY2 = myPointY2Map[ aPointType ]->text().toDouble( &anIsOk ); + if( !anIsOk ) + return false; + + TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ) ); + theMap[ aPointType ] = aData; + } + return true; +} + +void HYDROGUI_ImportImageDlg::initializePointSelection() +{ + myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true ); +} + +void HYDROGUI_ImportImageDlg::synchronizeTransformedPoints() +{ + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + myPointX2Map[ aPointType ]->setText( myPointX1Map[ aPointType ]->text() ); + myPointY2Map[ aPointType ]->setText( myPointY1Map[ aPointType ]->text() ); + } +} + +void HYDROGUI_ImportImageDlg::onBrowse() +{ + QString aFilter( tr( "IMAGE_FILTER" ) ); + QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter ); + if( !aFileName.isEmpty() ) + { + myFileName->setText( aFileName ); + emit createPreview( aFileName ); + myMappingGroup->setEnabled( true ); + } +} + +void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState ) +{ + int aPointType = HYDROGUI_PrsImage::None; + if( theState ) + { + QMapIterator anIter( myPointBtnMap ); + while( anIter.hasNext() ) + { + int aBtnPointType = anIter.next().key(); + QPushButton* aBtn = anIter.value(); + if( aBtn == sender() ) + aPointType = aBtnPointType; + else + { + bool anIsBlocked = aBtn->blockSignals( true ); + aBtn->setChecked( false ); + aBtn->blockSignals( anIsBlocked ); + } + } + } + emit activatePointSelection( aPointType ); +} diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h index e69de29b..49efc9ec 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h @@ -0,0 +1,72 @@ +// 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_IMPORTIMAGEDLG_H +#define HYDROGUI_IMPORTIMAGEDLG_H + +#include "HYDROGUI_InputPanel.h" + +#include + +class QGroupBox; +class QLineEdit; + +class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + typedef QPair< QPoint, QPointF > TransformationData; + typedef QMap< int, TransformationData > TransformationDataMap; + +public: + HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_ImportImageDlg(); + + void reset(); + + void setTransformationDataMap( const TransformationDataMap& theMap ); + bool getTransformationDataMap( TransformationDataMap& theMap ) const; + + void initializePointSelection(); + void synchronizeTransformedPoints(); + +protected slots: + void onBrowse(); + void onPointBtnToggled( bool ); + +signals: + void createPreview( QString ); + void activatePointSelection( int ); + +private: + QLineEdit* myFileName; + + QGroupBox* myMappingGroup; + QMap myPointBtnMap; + QMap myPointX1Map; + QMap myPointY1Map; + QMap myPointX2Map; + QMap myPointY2Map; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 9b0093c2..a1f390c9 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -1,8 +1,51 @@ +// 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 +#include "HYDROGUI_ImportImageOp.h" + +#include "HYDROGUI_ImportImageDlg.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_PrsImage.h" +#include "HYDROGUI_Tool.h" + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule ) - : HYDROGUI_Operation( theModule ) +: HYDROGUI_Operation( theModule ), + myActiveViewManager( 0 ), + myPreviewViewManager( 0 ), + myPreviewPrs( 0 ), + myPointType( HYDROGUI_PrsImage::None ) { } @@ -10,7 +53,170 @@ HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp() { } +void HYDROGUI_ImportImageOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); + aPanel->reset(); +} + HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const { - return 0; + HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), tr( "IMPORT_IMAGE" ) ); + connect( aPanel, SIGNAL( createPreview( QString ) ), + this, SLOT( onCreatePreview( QString ) ) ); + connect( aPanel, SIGNAL( activatePointSelection( int ) ), + this, SLOT( onActivatePointSelection( int ) ) ); + return aPanel; +} + +void HYDROGUI_ImportImageOp::OnApply() +{ + HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); + + HYDROGUI_ImportImageDlg::TransformationDataMap aMap; + bool anIsOk = aPanel->getTransformationDataMap( aMap ); + if( !anIsOk || !myPreviewPrs ) + { + SUIT_MessageBox::critical( module()->getApp()->desktop(), + tr( "INSUFFICIENT_INPUT_DATA" ), + tr( "INPUT_VALID_DATA" ) ); + return; + } + + double xa1 = aMap[ HYDROGUI_PrsImage::PointA ].first.x(); + double ya1 = aMap[ HYDROGUI_PrsImage::PointA ].first.y(); + double xb1 = aMap[ HYDROGUI_PrsImage::PointB ].first.x(); + double yb1 = aMap[ HYDROGUI_PrsImage::PointB ].first.y(); + double xc1 = aMap[ HYDROGUI_PrsImage::PointC ].first.x(); + double yc1 = aMap[ HYDROGUI_PrsImage::PointC ].first.y(); + + double xa2 = aMap[ HYDROGUI_PrsImage::PointA ].second.x(); + double ya2 = aMap[ HYDROGUI_PrsImage::PointA ].second.y(); + double xb2 = aMap[ HYDROGUI_PrsImage::PointB ].second.x(); + double yb2 = aMap[ HYDROGUI_PrsImage::PointB ].second.y(); + double xc2 = aMap[ HYDROGUI_PrsImage::PointC ].second.x(); + double yc2 = aMap[ HYDROGUI_PrsImage::PointC ].second.y(); + + QTransform aTransform1( xa1, ya1, 1, xb1, yb1, 1, xc1, yc1, 1 ); + QTransform aTransform2( xa2, ya2, 1, xb2, yb2, 1, xc2, yc2, 1 ); + + QTransform aTransform = aTransform1.inverted() * aTransform2; + + QImage anImage = myPreviewPrs->getImage(); + + closePreview(); + + int aStudyId = module()->getStudyId(); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + if( !aDocument.IsNull() ) + { + Handle(HYDROData_Image) anImageObj = + Handle(HYDROData_Image)::DownCast( aDocument->CreateObject( KIND_IMAGE ) ); + if( !anImageObj.IsNull() ) + { + static int ImageId = 0; + anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) ); + + anImageObj->SetImage( anImage ); + anImageObj->SetTrsf( aTransform ); + + module()->update( UF_Model | UF_Viewer ); + } + } + commit(); +} + +void HYDROGUI_ImportImageOp::OnCancel() +{ + closePreview(); + abort(); +} + +void HYDROGUI_ImportImageOp::onCreatePreview( QString theFileName ) +{ + LightApp_Application* anApp = module()->getApp(); + + myActiveViewManager = anApp->activeViewManager(); + + myPreviewPrs = new HYDROGUI_PrsImage( 0 ); // no data object + + QImage anImage( theFileName ); + myPreviewPrs->setImage( anImage ); + + myPreviewPrs->compute(); + + myPreviewViewManager = + dynamic_cast( anApp->createViewManager( GraphicsView_Viewer::Type() ) ); + if( myPreviewViewManager ) + { + myPreviewViewManager->setTitle( tr( "MAPPING" ) ); + if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() ) + { + if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) + { + aViewPort->setMousePositionEnabled( true ); + + aViewPort->addItem( myPreviewPrs ); + aViewPort->fitAll(); + + myPreviewPrs->setIsTransformationPointPreview( true ); + } + connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ), + this, SLOT( onPointSelected() ) ); + } + } + + HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); + + aPanel->initializePointSelection(); + onPointSelected(); + + aPanel->synchronizeTransformedPoints(); +} + +void HYDROGUI_ImportImageOp::onActivatePointSelection( int thePointType ) +{ + myPointType = thePointType; + if( myPreviewPrs ) + myPreviewPrs->setTransformationPointMode( thePointType ); +} + +void HYDROGUI_ImportImageOp::onPointSelected() +{ + HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap; + + const HYDROGUI_PrsImage::TransformationPointMap& aPointMap = + myPreviewPrs->getTransformationPointMap(); + HYDROGUI_PrsImage::TransformationPointMapIterator anIter( aPointMap ); + while( anIter.hasNext() ) + { + int aPointType = anIter.next().key(); + const HYDROGUI_PrsImage::TransformationPoint& aTransformationPoint = anIter.value(); + const QPoint& aPoint = aTransformationPoint.Point; + + HYDROGUI_ImportImageDlg::TransformationData aData( aPoint, QPointF() ); + aDataMap[ aPointType ] = aData; + } + + ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap ); +} + +void HYDROGUI_ImportImageOp::closePreview() +{ + if( myPreviewPrs ) + { + delete myPreviewPrs; + myPreviewPrs = 0; + } + + if( myPreviewViewManager ) + { + module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here + myPreviewViewManager = 0; + } + + if( myActiveViewManager ) + HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager ); } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index d9011c56..66537e25 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -1,17 +1,67 @@ +// 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_IMPORT_IMAGE_OP_HEADER -#define HYDROGUI_IMPORT_IMAGE_OP_HEADER +#ifndef HYDROGUI_IMPORTIMAGEOP_H +#define HYDROGUI_IMPORTIMAGEOP_H -#include +#include "HYDROGUI_Operation.h" + +class GraphicsView_ViewManager; + +class SUIT_ViewManager; + +class HYDROGUI_PrsImage; class HYDROGUI_ImportImageOp : public HYDROGUI_Operation { + Q_OBJECT + public: HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule ); virtual ~HYDROGUI_ImportImageOp(); protected: + virtual void startOperation(); + virtual HYDROGUI_InputPanel* createInputPanel() const; + +protected slots: + virtual void OnApply(); + virtual void OnCancel(); + + void onCreatePreview( QString ); + void onActivatePointSelection( int ); + void onPointSelected(); + +private: + void closePreview(); + +private: + SUIT_ViewManager* myActiveViewManager; + + GraphicsView_ViewManager* myPreviewViewManager; + HYDROGUI_PrsImage* myPreviewPrs; + + int myPointType; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index fb9144b8..269e5ca3 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -43,6 +43,9 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr myMainFrame = new QFrame( this ); QGridLayout* aMainLayout = new QGridLayout( myMainFrame ); + aMainLayout->setMargin( 0 ); + aMainLayout->setSpacing( 5 ); + myBtnFrame = new QFrame( this ); aLayout->addWidget( myMainFrame, 1 ); aLayout->addWidget( myBtnFrame, 0 ); @@ -96,6 +99,14 @@ void HYDROGUI_InputPanel::addWidget( const QString& theLabel, QWidget* theWidget aMainLayout->addWidget( theWidget, aRow, 1 ); } +void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, + const int theRow, + const int theColumn ) +{ + QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->addWidget( theWidget, theRow, theColumn ); +} + void HYDROGUI_InputPanel::addSeparator() { QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 319086fe..24603ea4 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -23,13 +23,13 @@ #ifndef HYDROGUI_INPUTPANEL_H #define HYDROGUI_INPUTPANEL_H -#include "HYDROGUI.h" #include -class HYDROGUI_Module; class QFrame; class QPushButton; +class HYDROGUI_Module; + /**\class HYDROGUI_Dialog *\brief The base class representing base input panel for all HYDROGUI panels */ @@ -42,6 +42,7 @@ public: virtual ~HYDROGUI_InputPanel(); void addWidget( const QString& theLabel, QWidget* theWidget ); + void addWidget( QWidget* theWidget, const int theRow, const int theColumn ); void addSeparator(); void setRowStretch(); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 5b58847d..670246be 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -22,21 +22,26 @@ #include "HYDROGUI_Module.h" +#include "HYDROGUI.h" #include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Displayer.h" +#include "HYDROGUI_GVSelector.h" #include "HYDROGUI_InputPanel.h" #include "HYDROGUI_ObjSelector.h" #include "HYDROGUI_Operations.h" +#include "HYDROGUI_PrsImage.h" +#include "HYDROGUI_UpdateFlags.h" -#include #include +#include #include #include #include #include #include +#include -#include #include #include @@ -48,7 +53,9 @@ extern "C" HYDRO_EXPORT CAM_Module* createModule() } HYDROGUI_Module::HYDROGUI_Module() -: LightApp_Module( "HYDRO GUI" ) +: LightApp_Module( "HYDRO" ), + myDisplayer( 0 ), + myIsUpdateEnabled( true ) { } @@ -64,7 +71,6 @@ int HYDROGUI_Module::getStudyId() const void HYDROGUI_Module::initialize( CAM_Application* theApp ) { - printf( "Initialization of the HYDROGUI module\n" ); LightApp_Module::initialize( theApp ); CreateActions(); @@ -74,8 +80,7 @@ void HYDROGUI_Module::initialize( CAM_Application* theApp ) setMenuShown( false ); - //startOperation( ImportImageId ); - startOperation( FuseId ); + myDisplayer = new HYDROGUI_Displayer( this ); } bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) @@ -96,48 +101,156 @@ void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const theTypesList << GraphicsView_Viewer::Type(); } -HYDROGUI_DataModel* HYDROGUI_Module::getModel() const +void HYDROGUI_Module::update( const int flags ) +{ + if( !isUpdateEnabled() ) + return; + + QApplication::setOverrideCursor( Qt::WaitCursor ); + + // To prevent calling this method recursively + // from one of the methods called below + setUpdateEnabled( false ); + + if( ( flags & UF_Model ) && getDataModel() ) + { + getDataModel()->update( getStudyId() ); + } + else + { + /* to do + if( ( flags & UF_ObjBrowser ) && getObjectBrowser() ) + updateObjectBrowser(); + */ + } + + if( ( flags & UF_Viewer ) ) + updateGV( flags & UF_GV_Init, + flags & UF_GV_Forced ); + + if( ( flags & UF_Controls ) && getApp() ) + getApp()->updateActions(); + + setUpdateEnabled( true ); + + QApplication::restoreOverrideCursor(); +} + +HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const { return (HYDROGUI_DataModel*)dataModel(); } +HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const +{ + return myDisplayer; +} + +GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theViewerId ) const +{ + ViewManagerList aViewManagerList; + getApp()->viewManagers( GraphicsView_Viewer::Type(), aViewManagerList ); + + ViewManagerList::iterator anIter, anIterEnd = aViewManagerList.end(); + for( anIter = aViewManagerList.begin(); anIter != anIterEnd; anIter++ ) + { + GraphicsView_ViewManager* aViewManager = + dynamic_cast( *anIter ); + if( aViewManager && aViewManager->getId() == theViewerId ) + return aViewManager->getViewer(); + } + return NULL; +} + CAM_DataModel* HYDROGUI_Module::createDataModel() { return new HYDROGUI_DataModel( this ); } -void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) +void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) { - LightApp_Module::onViewManagerAdded( theMgr ); - connect( theMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), - this, SLOT( onViewWindowAdded( SUIT_ViewWindow* ) ) ); + LightApp_Module::onViewManagerAdded( theViewManager ); + + if( theViewManager->getType() == GraphicsView_Viewer::Type() ) + { + createSelector( theViewManager ); // replace the default selector + + connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), + this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) ); + } } -void HYDROGUI_Module::onViewWindowAdded( SUIT_ViewWindow* theWnd ) +void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager ) { - GraphicsView_ViewFrame* aViewFrame = dynamic_cast( theWnd ); + LightApp_Module::onViewManagerRemoved( theViewManager ); - LightApp_SelectionMgr* aSelMgr = getApp()->selectionMgr(); - LightApp_GVSelector* aSelector = new LightApp_GVSelector( aViewFrame->getViewer(), aSelMgr ); + createSelector( theViewManager ); // replace the default selector +} - GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort(); +void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theWnd ) +{ +} + +void HYDROGUI_Module::updateGV( const bool theIsInit, + const bool theIsForced ) +{ + if( !getDisplayer() ) + return; + + ViewManagerList aViewManagerList; + getApp()->viewManagers( GraphicsView_Viewer::Type(), aViewManagerList ); + + ViewManagerList::iterator anIter, anIterEnd = aViewManagerList.end(); + for( anIter = aViewManagerList.begin(); anIter != anIterEnd; anIter++ ) + { + GraphicsView_ViewManager* aViewManager = + dynamic_cast( *anIter ); + if( aViewManager ) + getDisplayer()->UpdateAll( aViewManager->getId(), theIsInit, theIsForced ); + } +} + +void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) +{ + if( !theViewManager ) + return; + + LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); + if( !aSelectionMgr ) + return; - GraphicsView_PrsImage* aPrs1 = new GraphicsView_PrsImage(); - QImage anImage1( "W:/Work/HYDRO/data/samples/1.bmp" ); - aPrs1->setImage( anImage1 ); - aPrs1->setName( "example_1" ); - aPrs1->compute(); - aViewPort->addItem( aPrs1 ); + QString aViewType = theViewManager->getType(); + if( aViewType != GraphicsView_Viewer::Type() ) + return; - GraphicsView_PrsImage* aPrs2 = new GraphicsView_PrsImage(); - QImage anImage2( "W:/Work/HYDRO/data/samples/2.bmp" ); - aPrs2->setImage( anImage2 ); - aPrs2->setName( "example_2" ); - aPrs2->setRotationAngle( 30 ); - aPrs2->setPosition( 200, 50 ); - aPrs2->compute(); - aViewPort->addItem( aPrs2 ); - - //qApp->processEvents(); - aViewPort->fitAll(); + GraphicsView_ViewManager* aViewManager = + dynamic_cast( theViewManager ); + if( !aViewManager ) + return; + + QList aSelectorList; + aSelectionMgr->selectors( aViewType, aSelectorList ); + + // disable all alien selectors + QList::iterator anIter, anIterEnd = aSelectorList.end(); + for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) + { + SUIT_Selector* aSelector = *anIter; + if( aSelector && !dynamic_cast( aSelector ) ) + aSelector->setEnabled( false ); + } + + new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr ); +} + +bool HYDROGUI_Module::setUpdateEnabled( const bool theState ) +{ + bool aPrevState = myIsUpdateEnabled; + myIsUpdateEnabled = theState; + return aPrevState; +} + +bool HYDROGUI_Module::isUpdateEnabled() const +{ + return myIsUpdateEnabled; } diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index b930a167..a93a3f44 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -23,13 +23,14 @@ #ifndef HYDROGUI_MODULE_H #define HYDROGUI_MODULE_H -#include "HYDROGUI.h" - #include +class GraphicsView_Viewer; + class SUIT_ViewWindow; class HYDROGUI_DataModel; +class HYDROGUI_Displayer; /**\class HYDROGUI_Module *\brief The class representing the HYDROGUI module @@ -51,7 +52,12 @@ public: virtual void windows( QMap& ) const; virtual void viewManagers( QStringList& ) const; - HYDROGUI_DataModel* getModel() const; + virtual void update( const int ); + + HYDROGUI_DataModel* getDataModel() const; + HYDROGUI_Displayer* getDisplayer() const; + + GraphicsView_Viewer* getViewer( const int theViewerId ) const; protected: CAM_DataModel* createDataModel(); @@ -65,7 +71,17 @@ protected: protected slots: void onOperation(); virtual void onViewManagerAdded( SUIT_ViewManager* ); - virtual void onViewWindowAdded( SUIT_ViewWindow* ); + virtual void onViewManagerRemoved( SUIT_ViewManager* ); + virtual void onViewCreated( SUIT_ViewWindow* ); + +private: + void updateGV( const bool theIsInit = false, + const bool theIsForced = false ); + + void createSelector( SUIT_ViewManager* viewMgr ); + + bool setUpdateEnabled( const bool theState ); + bool isUpdateEnabled() const; private: void CreateActions(); @@ -78,6 +94,11 @@ private: const QString& theImg = QString::null, const int theKey = 0, const bool isToggle = false, const QString& theSlot = QString::null ); + +private: + HYDROGUI_Displayer* myDisplayer; + + bool myIsUpdateEnabled; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index 95c4aa60..bbcc599b 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -79,6 +79,7 @@ void HYDROGUI_ObjSelector::OnToggled( bool isChecked ) void HYDROGUI_ObjSelector::OnSelectionChanged() { + /* ouv: to do if( !myBtn->isChecked() ) return; @@ -97,6 +98,7 @@ void HYDROGUI_ObjSelector::OnSelectionChanged() } } myObjName->setText( anObjName ); + */ } QString HYDROGUI_ObjSelector::GetName() const diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 0d7310d6..29336412 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -54,22 +54,45 @@ HYDROGUI_Module* HYDROGUI_Operation::module() const void HYDROGUI_Operation::startOperation() { + LightApp_Operation::startOperation(); + doc()->StartOperation(); if( inputPanel() ) { - connect( inputPanel(), SIGNAL( panelApply() ), this, SLOT( OnApply() ) ); - connect( inputPanel(), SIGNAL( panelCancel() ), this, SLOT( OnCancel() ) ); - inputPanel()->show(); myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() ); } } +void HYDROGUI_Operation::abortOperation() +{ + doc()->AbortOperation(); + + LightApp_Operation::abortOperation(); + + if( inputPanel() ) + inputPanel()->hide(); +} + +void HYDROGUI_Operation::commitOperation() +{ + doc()->CommitOperation(); + + LightApp_Operation::commitOperation(); + + if( inputPanel() ) + inputPanel()->hide(); +} + HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const { if( !myPanel ) + { ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel(); + connect( myPanel, SIGNAL( panelApply() ), this, SLOT( OnApply() ) ); + connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( OnCancel() ) ); + } return myPanel; } diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 57330060..2afd8dac 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -23,8 +23,6 @@ #ifndef HYDROGUI_OPERATION_H #define HYDROGUI_OPERATION_H -#include "HYDROGUI.h" - #include class HYDROGUI_Module; @@ -47,6 +45,9 @@ public: protected: virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + virtual HYDROGUI_InputPanel* createInputPanel() const = 0; Handle_HYDROData_Document doc() const; diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 568da592..8f717cad 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -27,16 +27,12 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_TwoImagesOp.h" -#include -#include - #include #include #include #include -#include QAction* HYDROGUI_Module::CreateAction( const int theId, const QString& theSuffix, const QString& theImg, const int theKey, const bool isToggle, const QString& theSlot ) @@ -59,6 +55,8 @@ QAction* HYDROGUI_Module::CreateAction( const int theId, const QString& theSuffi void HYDROGUI_Module::CreateActions() { CreateAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); + CreateAction( FuseId, "FUSE_IMAGES" ); + CreateAction( CutId, "CUT_IMAGES" ); } void HYDROGUI_Module::CreateMenus() @@ -66,6 +64,8 @@ void HYDROGUI_Module::CreateMenus() int aHydroMenuIndex = 6; // Edit menu id == 5, View menu id == 10 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenuIndex ); createMenu( ImportImageId, aHydroId, -1, -1 ); + createMenu( FuseId, aHydroId, -1, -1 ); + createMenu( CutId, aHydroId, -1, -1 ); } void HYDROGUI_Module::CreatePopups() @@ -82,34 +82,6 @@ void HYDROGUI_Module::onOperation() int anId = actionId( anAction ); if( anId >= 0 ) startOperation( anId ); - - // tmp - if( anId == ImportImageId ) - { - QString aFileName = QFileDialog::getOpenFileName(); - if( !aFileName.isEmpty() ) - { - int aStudyId = getStudyId(); - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); - if( !aDocument.IsNull() ) - { - Handle(HYDROData_Image) anImageObj = - Handle(HYDROData_Image)::DownCast( aDocument->CreateObject( KIND_IMAGE ) ); - if( !anImageObj.IsNull() ) - { - static int ImageId = 0; - anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) ); - - QImage anImage( aFileName ); - QTransform aTransform; - anImageObj->SetImage( anImage ); - anImageObj->SetTrsf( aTransform ); - - getModel()->updateModel(); - } - } - } - } } LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const diff --git a/src/HYDROGUI/HYDROGUI_Prs.cxx b/src/HYDROGUI/HYDROGUI_Prs.cxx new file mode 100644 index 00000000..f0a9f554 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Prs.cxx @@ -0,0 +1,42 @@ +// 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_Prs.h" + +//======================================================================= +// name : HYDROGUI_Prs +// Purpose : Constructor +//======================================================================= +HYDROGUI_Prs::HYDROGUI_Prs( const Handle(HYDROData_Object)& theObject ) +: GraphicsView_Object(), + myObject( theObject ), + myIsToUpdate( false ) +{ +} + +//======================================================================= +// name : HYDROGUI_Prs +// Purpose : Destructor +//======================================================================= +HYDROGUI_Prs::~HYDROGUI_Prs() +{ +} diff --git a/src/HYDROGUI/HYDROGUI_Prs.h b/src/HYDROGUI/HYDROGUI_Prs.h new file mode 100644 index 00000000..8c39308d --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Prs.h @@ -0,0 +1,51 @@ +// 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_PRS_H +#define HYDROGUI_PRS_H + +#include + +#include + +/* + Class : HYDROGUI_Prs + Description : Base class for all HYDRO presentation +*/ +class HYDROGUI_Prs : public GraphicsView_Object +{ +public: + HYDROGUI_Prs( const Handle(HYDROData_Object)& theObject ); + virtual ~HYDROGUI_Prs(); + +public: + Handle(HYDROData_Object) getObject() const { return myObject; } + + bool getIsToUpdate() const { return myIsToUpdate; } + void setIsToUpdate( bool theState ) { myIsToUpdate = theState; } + +private: + Handle(HYDROData_Object) myObject; + bool myIsToUpdate; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_PrsDriver.cxx b/src/HYDROGUI/HYDROGUI_PrsDriver.cxx new file mode 100644 index 00000000..4e13c1c5 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsDriver.cxx @@ -0,0 +1,41 @@ +// 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_PrsDriver.h" + +#include "HYDROGUI_Prs.h" + +HYDROGUI_PrsDriver::HYDROGUI_PrsDriver() +{ +} + +HYDROGUI_PrsDriver::~HYDROGUI_PrsDriver() +{ +} + +bool HYDROGUI_PrsDriver::Update( const Handle(HYDROData_Object)& theObj, + HYDROGUI_Prs*& thePrs ) +{ + if ( thePrs ) + thePrs->setIsToUpdate( false ); + return true; +} diff --git a/src/HYDROGUI/HYDROGUI_PrsDriver.h b/src/HYDROGUI/HYDROGUI_PrsDriver.h new file mode 100644 index 00000000..f73c0081 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsDriver.h @@ -0,0 +1,60 @@ +// 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_PRSDRIVER_H +#define HYDROGUI_PRSDRIVER_H + +#include + +class HYDROGUI_Prs; + +/** + * \class HYDROGUI_PrsDriver + * \brief Base class of presentation driver, which allows to build a + * presentation on a basis of data object. + */ +class HYDROGUI_PrsDriver +{ +public: + /** + * \brief Constructor. + */ + HYDROGUI_PrsDriver(); + + /** + * \brief Destructor. + */ + virtual ~HYDROGUI_PrsDriver(); + +public: + /** + * \brief Virtual method intended to update or create the presentation + * on a basis of data object. + * \param theObj data object + * \param thePrs presentation + * \return status of the operation + */ + virtual bool Update( const Handle(HYDROData_Object)& theObj, + HYDROGUI_Prs*& thePrs ); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx new file mode 100644 index 00000000..fa75c25e --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -0,0 +1,306 @@ +// 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_PrsImage.h" + +#include "HYDROGUI_PrsImageFrame.h" + +#include + +#include + +//======================================================================= +// name : HYDROGUI_PrsImage +// Purpose : Constructor +//======================================================================= +HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject ) +: HYDROGUI_Prs( theObject ), + myPixmapItem( 0 ), + myPrsImageFrame( 0 ), + myIsTransformationPointPreview( false ), + myTransformationPointMode( None ) +{ + myHighlightCursor = new QCursor( Qt::PointingHandCursor ); + myTransformationPointCursor = new QCursor( Qt::CrossCursor ); +} + +//======================================================================= +// name : HYDROGUI_PrsImage +// Purpose : Destructor +//======================================================================= +HYDROGUI_PrsImage::~HYDROGUI_PrsImage() +{ + if( myHighlightCursor ) + { + delete myHighlightCursor; + myHighlightCursor = 0; + } + + if( myTransformationPointCursor ) + { + delete myTransformationPointCursor; + myTransformationPointCursor = 0; + } +} + +//================================================================ +// Function : setImage +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setImage( const QImage& theImage ) +{ + myImage = theImage; +} + +//================================================================ +// Function : getImage +// Purpose : +//================================================================ +QImage HYDROGUI_PrsImage::getImage() const +{ + return myImage; +} + +//================================================================ +// Function : setIsTransformationPointPreview +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setIsTransformationPointPreview( const bool theState ) +{ + myIsTransformationPointPreview = theState; +} + +//================================================================ +// Function : getIsTransformationPointPreview +// Purpose : +//================================================================ +bool HYDROGUI_PrsImage::getIsTransformationPointPreview() const +{ + return myIsTransformationPointPreview; +} + +//================================================================ +// Function : setTransformationPointMode +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setTransformationPointMode( const int theMode ) +{ + myTransformationPointMode = theMode; + if( theMode != None ) + computeTransformationPoints(); +} + +//================================================================ +// Function : boundingRect +// Purpose : +//================================================================ +QRectF HYDROGUI_PrsImage::boundingRect() const +{ + return myPixmapItem->boundingRect(); +} + +//================================================================ +// Function : compute +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::compute() +{ + if( !myPixmapItem ) + { + myPixmapItem = new QGraphicsPixmapItem( this ); + addToGroup( myPixmapItem ); + } + if( !myPrsImageFrame ) + { + myPrsImageFrame = new HYDROGUI_PrsImageFrame( this ); + addToGroup( myPrsImageFrame ); + } + myPixmapItem->setPixmap( QPixmap::fromImage( myImage ) ); + myPrsImageFrame->compute(); +} + +//================================================================ +// Function : addTo +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::addTo( GraphicsView_ViewPort* theViewPort ) +{ + GraphicsView_Object::addTo( theViewPort ); + theViewPort->addItem( myPrsImageFrame ); + + double aZValue = 0; + GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() ); + while( anIter.hasNext() ) + { + if( HYDROGUI_PrsImage* aPrs = dynamic_cast( anIter.next() ) ) + { + double aZValueRef = aPrs->zValue(); + aZValue = qMax( aZValue, aZValueRef ); + } + } + setZValue( aZValue + 1 ); +} + +//================================================================ +// Function : removeFrom +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::removeFrom( GraphicsView_ViewPort* theViewPort ) +{ + GraphicsView_Object::removeFrom( theViewPort ); + theViewPort->removeItem( myPrsImageFrame ); +} + +//================================================================ +// Function : checkHighlight +// Purpose : +//================================================================ +bool HYDROGUI_PrsImage::checkHighlight( double theX, double theY, QCursor& theCursor ) const +{ + QRect aRect = myPixmapItem->boundingRect().toRect(); + QPolygon aPolygon = sceneTransform().mapToPolygon( aRect ); + if( aPolygon.containsPoint( QPoint( theX, theY ), Qt::OddEvenFill ) ) + { + if( myIsTransformationPointPreview ) + { + if( myTransformationPointMode != None ) + theCursor = *getTransformationPointCursor(); + } + else + theCursor = *getHighlightCursor(); + return true; + } + return false; +} + +//================================================================ +// Function : select +// Purpose : +//================================================================ +bool HYDROGUI_PrsImage::select( double theX, double theY, const QRectF& theRect ) +{ + if( myIsTransformationPointPreview ) + { + if( myTransformationPointMode == None || !theRect.isEmpty() ) + return false; + + TransformationPoint& aTransformationPoint = myTransformationPointMap[ myTransformationPointMode ]; + aTransformationPoint.Point = QPoint( (int)theX, (int)theY ); + computeTransformationPoints(); + return true; + } + + bool anIsSelected = GraphicsView_Object::select( theX, theY, theRect ); + myPrsImageFrame->updateVisibility(); + return anIsSelected; +} + +//================================================================ +// Function : unselect +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::unselect() +{ + GraphicsView_Object::unselect(); + myPrsImageFrame->updateVisibility(); +} + +//================================================================ +// Function : setSelected +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setSelected( bool theState ) +{ + GraphicsView_Object::setSelected( theState ); + myPrsImageFrame->updateVisibility(); +} + +//================================================================ +// Function : computeTransformationPoints +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::computeTransformationPoints() +{ + if( myTransformationPointMap.isEmpty() ) + { + int aWidth = myImage.width(); + int aHeight = myImage.height(); + + for( int aPointType = PointA; aPointType <= PointC; aPointType++ ) + { + TransformationPoint aTransformationPoint; + + QPoint aPoint; + QString aCaption; + QColor aColor = Qt::black; + switch( aPointType ) + { + case PointA: + aPoint = QPoint( 0, 0 ); + aCaption = "A"; + aColor = Qt::darkRed; + break; + case PointB: + aPoint = QPoint( aWidth, 0 ); + aCaption = "B"; + aColor = Qt::darkGreen; + break; + case PointC: + aPoint = QPoint( 0, aHeight ); + aCaption = "C"; + aColor = Qt::darkBlue; + break; + } + + aTransformationPoint.Point = aPoint; + aTransformationPoint.Caption = aCaption; + + aTransformationPoint.PointItem = new QGraphicsEllipseItem( this ); + aTransformationPoint.PointItem->setVisible( false ); + aTransformationPoint.PointItem->setPen( QPen( aColor ) ); + aTransformationPoint.PointItem->setBrush( QBrush( aColor ) ); + + aTransformationPoint.CaptionItem = new QGraphicsSimpleTextItem( aCaption, this ); + aTransformationPoint.CaptionItem->setVisible( false ); + aTransformationPoint.CaptionItem->setPen( QPen( aColor ) ); + aTransformationPoint.CaptionItem->setBrush( QBrush( aColor ) ); + + myTransformationPointMap[ aPointType ] = aTransformationPoint; + } + } + + bool anIsVisible = myIsTransformationPointPreview; + for( int aPointType = PointA; aPointType <= PointC; aPointType++ ) + { + TransformationPoint& aTransformationPoint = myTransformationPointMap[ aPointType ]; + + double aRadius = 5; + const QPointF& aPoint = aTransformationPoint.Point; + QRectF aRect( aPoint - QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) ); + aTransformationPoint.PointItem->setRect( aRect ); + aTransformationPoint.PointItem->setVisible( anIsVisible ); + + QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); + aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); + aTransformationPoint.CaptionItem->setVisible( anIsVisible ); + } +} diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h new file mode 100644 index 00000000..8f385185 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -0,0 +1,102 @@ +// 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_PRSIMAGE_H +#define HYDROGUI_PRSIMAGE_H + +#include "HYDROGUI_Prs.h" + +class HYDROGUI_PrsImageFrame; + +/* + Class : HYDROGUI_PrsImage + Description : Presentation for image object +*/ +class HYDROGUI_PrsImage : public HYDROGUI_Prs +{ +public: + enum TransformationPointType { None = 0, PointA, PointB, PointC }; + struct TransformationPoint + { + QPoint Point; + QString Caption; + QGraphicsEllipseItem* PointItem; + QGraphicsSimpleTextItem* CaptionItem; + }; + typedef QMap < int, TransformationPoint > TransformationPointMap; + typedef QMapIterator< int, TransformationPoint > TransformationPointMapIterator; + +public: + HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject ); + virtual ~HYDROGUI_PrsImage(); + +public: + void setImage( const QImage& theImage ); + QImage getImage() const; + + void setIsTransformationPointPreview( const bool theState ); + bool getIsTransformationPointPreview() const; + + void setTransformationPointMode( const int theMode ); + const TransformationPointMap& getTransformationPointMap() const { return myTransformationPointMap; } + +public: + // from QGraphicsItem + virtual QRectF boundingRect() const; + + // from GraphicsView_Object + virtual void compute(); + + virtual void addTo( GraphicsView_ViewPort* theViewPort ); + virtual void removeFrom( GraphicsView_ViewPort* theViewPort ); + + virtual bool isMovable() const { return false; } + + virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const; + + virtual bool select( double theX, double theY, const QRectF& theRect ); + virtual void unselect(); + virtual void setSelected( bool theState ); + +protected: + void computeTransformationPoints(); + +protected: + QCursor* getHighlightCursor() const { return myHighlightCursor; } + QCursor* getTransformationPointCursor() const { return myTransformationPointCursor; } + +protected: + QImage myImage; + + QGraphicsPixmapItem* myPixmapItem; + HYDROGUI_PrsImageFrame* myPrsImageFrame; + + bool myIsTransformationPointPreview; + int myTransformationPointMode; + TransformationPointMap myTransformationPointMap; + +private: + QCursor* myHighlightCursor; + QCursor* myTransformationPointCursor; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_PrsImageDriver.cxx b/src/HYDROGUI/HYDROGUI_PrsImageDriver.cxx new file mode 100644 index 00000000..cac25c91 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsImageDriver.cxx @@ -0,0 +1,62 @@ +// 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_PrsImageDriver.h" + +#include "HYDROGUI_PrsImage.h" + +#include + +HYDROGUI_PrsImageDriver::HYDROGUI_PrsImageDriver() +:HYDROGUI_PrsDriver() +{ +} + +HYDROGUI_PrsImageDriver::~HYDROGUI_PrsImageDriver() +{ +} + +bool HYDROGUI_PrsImageDriver::Update( const Handle(HYDROData_Object)& theObj, + HYDROGUI_Prs*& thePrs ) +{ + HYDROGUI_PrsDriver::Update( theObj, thePrs ); + + if( theObj.IsNull() ) + return false; + + Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( theObj ); + if( anImage.IsNull() ) + return false; + + if( !thePrs ) + thePrs = new HYDROGUI_PrsImage( theObj ); + + HYDROGUI_PrsImage* aPrsImage = (HYDROGUI_PrsImage*)thePrs; + + aPrsImage->setName( anImage->GetName() ); + aPrsImage->setImage( anImage->Image() ); + aPrsImage->setTransform( anImage->Trsf() ); + + aPrsImage->compute(); + + return true; +} diff --git a/src/HYDROGUI/HYDROGUI_PrsImageDriver.h b/src/HYDROGUI/HYDROGUI_PrsImageDriver.h new file mode 100644 index 00000000..5da63d5b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsImageDriver.h @@ -0,0 +1,56 @@ +// 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_PRSIMAGEDRIVER_H +#define HYDROGUI_PRSIMAGEDRIVER_H + +#include + +/** + * \class HYDROGUI_PrsImageDriver + * \brief Presentation driver for image objects. + */ +class HYDROGUI_PrsImageDriver : public HYDROGUI_PrsDriver +{ +public: + /** + * \brief Constructor. + */ + HYDROGUI_PrsImageDriver(); + + /** + * \brief Destructor. + */ + virtual ~HYDROGUI_PrsImageDriver(); + +public: + /** + * \brief Update or create the image presentation on a basis of data object. + * \param theObj data object + * \param thePrs presentation + * \return status of the operation + */ + virtual bool Update( const Handle(HYDROData_Object)& theObj, + HYDROGUI_Prs*& thePrs ); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx b/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx new file mode 100644 index 00000000..058d0ea6 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx @@ -0,0 +1,211 @@ +// 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_PrsImageFrame.h" + +#include "HYDROGUI_PrsImage.h" + +#include + +#define FRAME_Z_VALUE 1000 +#define ANCHOR_RADIUS 3 +#define EPSILON 1e-6 + +//======================================================================= +// name : HYDROGUI_PrsImageFrame +// Purpose : Constructor +//======================================================================= +HYDROGUI_PrsImageFrame::HYDROGUI_PrsImageFrame( HYDROGUI_PrsImage* thePrsImage ) +: GraphicsView_Object( thePrsImage ), + myPrsImage( thePrsImage ) +{ +} + +//======================================================================= +// name : HYDROGUI_PrsImageFrame +// Purpose : Destructor +//======================================================================= +HYDROGUI_PrsImageFrame::~HYDROGUI_PrsImageFrame() +{ +} + +//================================================================ +// Function : boundingRect +// Purpose : +//================================================================ +QRectF HYDROGUI_PrsImageFrame::boundingRect() const +{ + QRectF aRect; + AnchorMapIterator anIter( myAnchorMap ); + while( anIter.hasNext() ) + { + if( QGraphicsEllipseItem* anAnchorItem = anIter.next().value() ) + { + QRectF anAnchorRect = anAnchorItem->boundingRect(); + if( !anAnchorRect.isNull() ) + { + if( aRect.isNull() ) + aRect = anAnchorRect; + else + aRect |= anAnchorRect; + } + } + } + return aRect; +} + +//================================================================ +// Function : compute +// Purpose : +//================================================================ +void HYDROGUI_PrsImageFrame::compute() +{ + if( myAnchorMap.isEmpty() ) + { + for( int aType = TopLeft; aType <= BottomRight; aType++ ) + { + UnscaledGraphicsEllipseItem* anAnchorItem = new UnscaledGraphicsEllipseItem( this ); + anAnchorItem->setBrush( QBrush( Qt::white ) ); + myAnchorMap.insert( aType, anAnchorItem ); + addToGroup( anAnchorItem ); + } + } + + setZValue( FRAME_Z_VALUE ); + + computeAnchorItems(); + updateVisibility(); +} + +//================================================================ +// Function : computeAnchorItems +// Purpose : +//================================================================ +void HYDROGUI_PrsImageFrame::computeAnchorItems() +{ + if( !myPrsImage ) + return; + + QRectF aRect = myPrsImage->boundingRect(); + + QMap anAnchorPointMap; + anAnchorPointMap[ TopLeft ] = aRect.topLeft(); + anAnchorPointMap[ TopRight ] = aRect.topRight(); + anAnchorPointMap[ BottomLeft ] = aRect.bottomLeft(); + anAnchorPointMap[ BottomRight ] = aRect.bottomRight(); + + qreal ar = ANCHOR_RADIUS; + QMapIterator anIter( anAnchorPointMap ); + while( anIter.hasNext() ) + { + int anAnchorType = anIter.next().key(); + const QPointF& anAnchorPoint = anIter.value(); + + QRectF anAnchorRect( anAnchorPoint - QPointF( ar, ar ), QSizeF( ar * 2, ar * 2 ) ); + myAnchorMap[ anAnchorType ]->setRect( anAnchorRect ); + myAnchorMap[ anAnchorType ]->setBasePoint( anAnchorPoint ); + } +} + +//================================================================ +// Function : updateVisibility +// Purpose : +//================================================================ +void HYDROGUI_PrsImageFrame::updateVisibility() +{ + setVisible( myPrsImage && myPrsImage->isSelected() ); +} + +//======================================================================= +// name : HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem +// Purpose : Constructor +//======================================================================= +HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem::UnscaledGraphicsEllipseItem( QGraphicsItem* theParent ) +: QGraphicsEllipseItem( theParent ) +{ +} + +//======================================================================= +// name : HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem +// Purpose : Destructor +//======================================================================= +HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem::~UnscaledGraphicsEllipseItem() +{ +} + +//================================================================ +// Function : boundingRect +// Purpose : +//================================================================ +QRectF HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem::boundingRect() const +{ + QRectF aRect = QGraphicsEllipseItem::boundingRect(); + + GraphicsView_Object* aParent = dynamic_cast( parentItem() ); + if( !aParent ) + return aRect; + + QTransform aTransform = aParent->getViewTransform(); + double aScale = aTransform.m11(); // same as m22(), viewer specific + if( fabs( aScale ) < EPSILON ) + return aRect; + + QPointF aCenter = aRect.center(); + double aWidth = aRect.width() / aScale; + double aHeight = aRect.height() / aScale; + + aRect = QRectF( aCenter.x() - aWidth / 2, aCenter.y() - aHeight / 2, aWidth, aHeight ); + return aRect; +} + +//================================================================ +// Function : GenerateTranslationOnlyTransform +// Purpose : +//================================================================ +static QTransform GenerateTranslationOnlyTransform( const QTransform &theOriginalTransform, + const QPointF &theTargetPoint ) +{ + qreal dx = theOriginalTransform.m11() * theTargetPoint.x() - theTargetPoint.x() + + theOriginalTransform.m21() * theTargetPoint.y() + + theOriginalTransform.m31(); + qreal dy = theOriginalTransform.m22() * theTargetPoint.y() - theTargetPoint.y() + + theOriginalTransform.m12() * theTargetPoint.x() + + theOriginalTransform.m32(); + return QTransform::fromTranslate( dx, dy ); +} + +//================================================================ +// Function : paint +// Purpose : +//================================================================ +void HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem::paint( + QPainter* thePainter, + const QStyleOptionGraphicsItem* theOption, + QWidget* theWidget ) +{ + thePainter->save(); + thePainter->setTransform( GenerateTranslationOnlyTransform( thePainter->transform(), + myBasePoint ) ); + + QGraphicsEllipseItem::paint( thePainter, theOption, theWidget ); + thePainter->restore(); +} diff --git a/src/HYDROGUI/HYDROGUI_PrsImageFrame.h b/src/HYDROGUI/HYDROGUI_PrsImageFrame.h new file mode 100644 index 00000000..faf33822 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PrsImageFrame.h @@ -0,0 +1,93 @@ +// 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_PRSIMAGEFRAME_H +#define HYDROGUI_PRSIMAGEFRAME_H + +#include + +#include + +class HYDROGUI_PrsImage; + +/* + Class : HYDROGUI_PrsImageFrame + Description : Presentation for image frame object +*/ +class HYDROGUI_PrsImageFrame : public GraphicsView_Object +{ +public: + class UnscaledGraphicsEllipseItem; + + enum AnchorType { Undefined = 0, TopLeft, TopRight, BottomLeft, BottomRight }; + + typedef QMap AnchorMap; + typedef QMapIterator AnchorMapIterator; + +public: + HYDROGUI_PrsImageFrame( HYDROGUI_PrsImage* thePrsImage ); + virtual ~HYDROGUI_PrsImageFrame(); + +public: + // from QGraphicsItem + virtual QRectF boundingRect() const; + + // from GraphicsView_Object + virtual void compute(); + + virtual bool hasSpecificZValue() const { return true; } + + virtual bool isSelectable() const { return false; } + virtual bool isMovable() const { return false; } + +public: + void computeAnchorItems(); + void updateVisibility(); + +protected: + HYDROGUI_PrsImage* myPrsImage; + AnchorMap myAnchorMap; +}; + +/* + Class : UnscaledGraphicsEllipseItem + Description : Class for unscaled ellipse item +*/ +class HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem : public QGraphicsEllipseItem +{ +public: + UnscaledGraphicsEllipseItem( QGraphicsItem* ); + virtual ~UnscaledGraphicsEllipseItem(); + +public: + void setBasePoint( const QPointF& thePoint ) { myBasePoint = thePoint; } + const QPointF& getBasePoint() const { return myBasePoint; } + +public: + virtual QRectF boundingRect() const; + virtual void paint( QPainter*, const QStyleOptionGraphicsItem*, QWidget* ); + +private: + QPointF myBasePoint; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx new file mode 100644 index 00000000..5bfab0b2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -0,0 +1,85 @@ +// 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_Tool.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Prs.h" + +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include + +void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule, + SUIT_ViewManager* theViewManager ) +{ + if( theViewManager ) + if( SUIT_ViewWindow* aViewWindow = theViewManager->getActiveView() ) + if( STD_TabDesktop* aTabDesktop = dynamic_cast( theModule->getApp()->desktop() ) ) + if( QtxWorkstack* aWorkstack = aTabDesktop->workstack() ) + aWorkstack->setActiveWindow( aViewWindow ); +} + +void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theGUIModel, + const int theViewerId, // currently unused + HYDROData_SequenceOfObjects& theSeq ) +{ + if( !theGUIModel ) + return; + + const int aStudyId = theGUIModel->module()->application()->activeStudy()->id(); + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + if( aDocument.IsNull() ) + return; + + HYDROData_Iterator anIterator( aDocument, KIND_IMAGE ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Image) anImageObj = + Handle(HYDROData_Image)::DownCast( anIterator.Current() ); + if( !anImageObj.IsNull() ) + theSeq.Append( anImageObj ); + } +} + +HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& theObj, + const GraphicsView_ObjectList& theObjects ) +{ + GraphicsView_ObjectListIterator anIter( theObjects ); + while( anIter.hasNext() ) + if( HYDROGUI_Prs* aPrs = dynamic_cast( anIter.next() ) ) + if( aPrs->getObject()->Label() == theObj->Label() ) + return aPrs; + return NULL; +} diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h new file mode 100644 index 00000000..29bd4de7 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -0,0 +1,71 @@ +// 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_TOOL_H +#define HYDROGUI_TOOL_H + +#include + +#include + +class SUIT_ViewManager; + +class HYDROGUI_DataModel; +class HYDROGUI_Module; +class HYDROGUI_Prs; + +/** + * \class HYDROGUI_Tool + * \brief This class contains several useful methods. + */ +class HYDROGUI_Tool +{ +public: + /** + * \brief Set the specified view manager to be active on the desktop. + * \param theModule module + * \param theViewManager view manager + */ + static void SetActiveViewManager( HYDROGUI_Module* theModule, + SUIT_ViewManager* theViewManager ); + + /** + * \brief Get sub-objects to build presentations. + * \param theGUIModel data model + * \param theViewerId viewer id + * \param theSeq sequence of sub-objects + */ + static void GetPrsSubObjects( const HYDROGUI_DataModel* theGUIModel, + const int theViewerId, + HYDROData_SequenceOfObjects& theSeq ); + + /** + * \brief Get presentation built for specified data object. + * \param theObj data object + * \param theObjects list of existing presentations + * \return presentation + */ + static HYDROGUI_Prs* GetPresentation( const Handle(HYDROData_Object)& theObj, + const GraphicsView_ObjectList& theObjects ); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_UpdateFlags.h b/src/HYDROGUI/HYDROGUI_UpdateFlags.h new file mode 100644 index 00000000..33773f20 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_UpdateFlags.h @@ -0,0 +1,38 @@ +// 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_UPDATEFLAGS_H +#define HYDROGUI_UPDATEFLAGS_H + +/** + * \enum HYDRO_UpdateFlags + * Enumeration for update flags. First byte is reserved for LightApp_Module. + * Modules derived from this model must use other 3 bytes to define their + * own update flags. + */ +typedef enum +{ + UF_GV_Init = 0x00000020, //!< initial update (used with UF_Viewer) + UF_GV_Forced = 0x00000040, //!< to force recomputing all presentations (used with UF_Viewer) +} HYDRO_UpdateFlags; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index aec9f527..02f6bb27 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -3,8 +3,12 @@ @default - TEST_ICO - icon_test.png + ARROW_RIGHT_ICO + icon_arrow_right.png + + + BROWSE_ICO + icon_browse.png diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 1344d4a1..4d462fd0 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2,6 +2,14 @@ @default + + INSUFFICIENT_INPUT_DATA + Insufficient input data + + + INPUT_VALID_DATA + Please enter valid data and try again. + HYDROGUI_DataModel @@ -14,12 +22,89 @@ Study could not be saved + + HYDROGUI_InputPanel + + APPLY + Apply + + + CANCEL + Cancel + + + HELP + Help + + + + HYDROGUI_ImportImageDlg + + BROWSE_IMAGE_FILE + Browse image file + + + FILE_NAME + File name + + + IMAGE_FILTER + Image files (*.bmp *.jpg *.jpeg *.png);;All files (*.* *) + + + IMPORT_IMAGE_FROM_FILE + Import image from file + + + MAPPING + Mapping + + + POINT_A + Point A + + + POINT_B + Point B + + + POINT_C + Point C + + + + HYDROGUI_ImportImageOp + + IMPORT_IMAGE + Import image + + + MAPPING + Mapping + + HYDROGUI_Module + + DSK_CUT_IMAGES + Cut images + + + DSK_FUSE_IMAGES + Fuse images + DSK_IMPORT_IMAGE Import image + + MEN_CUT_IMAGES + Cut images + + + MEN_FUSE_IMAGES + Fuse images + MEN_DESK_HYDRO HYDRO @@ -28,6 +113,14 @@ MEN_IMPORT_IMAGE Import image + + STB_CUT_IMAGES + Cut images + + + STB_FUSE_IMAGES + Fuse images + STB_IMPORT_IMAGE Import image diff --git a/src/HYDROGUI/resources/icon_arrow_right.png b/src/HYDROGUI/resources/icon_arrow_right.png new file mode 100755 index 00000000..bc7f9273 Binary files /dev/null and b/src/HYDROGUI/resources/icon_arrow_right.png differ diff --git a/src/HYDROGUI/resources/icon_browse.png b/src/HYDROGUI/resources/icon_browse.png new file mode 100755 index 00000000..8ed143eb Binary files /dev/null and b/src/HYDROGUI/resources/icon_browse.png differ