From: ouv Date: Fri, 26 Jul 2013 14:41:06 +0000 (+0000) Subject: 1) Data model draft. X-Git-Tag: BR_hydro_v_0_1~138 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d6aeef5b61d85b44493cd5d93ed9870cc513e68f;p=modules%2Fhydro.git 1) Data model draft. 2) Formatting. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index b6c0cc71..8b446acf 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -3,31 +3,35 @@ include(../../CMake/UseQT4EXT.cmake) set(PROJECT_HEADERS HYDROGUI.h + HYDROGUI_ColorWidget.h + HYDROGUI_DataModel.h + HYDROGUI_DataObject.h + HYDROGUI_ImportImageDlg.h + HYDROGUI_ImportImageOp.h HYDROGUI_InputPanel.h HYDROGUI_Module.h HYDROGUI_ObjSelector.h HYDROGUI_Operation.h HYDROGUI_Operations.h - HYDROGUI_ImportImageOp.h - HYDROGUI_ImportImageDlg.h - HYDROGUI_TwoImagesOp.h HYDROGUI_TwoImagesDlg.h - HYDROGUI_ColorWidget.h + HYDROGUI_TwoImagesOp.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) set(PROJECT_SOURCES + HYDROGUI_ColorWidget.cxx + HYDROGUI_DataModel.cxx + HYDROGUI_DataObject.cxx + HYDROGUI_ImportImageDlg.cxx + HYDROGUI_ImportImageOp.cxx HYDROGUI_InputPanel.cxx HYDROGUI_Module.cxx HYDROGUI_ObjSelector.cxx HYDROGUI_Operation.cxx HYDROGUI_Operations.cxx - HYDROGUI_ImportImageOp.cxx - HYDROGUI_ImportImageDlg.cxx - HYDROGUI_TwoImagesOp.cxx HYDROGUI_TwoImagesDlg.cxx - HYDROGUI_ColorWidget.cxx + HYDROGUI_TwoImagesOp.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI.h b/src/HYDROGUI/HYDROGUI.h index c2d7cec2..5a707069 100644 --- a/src/HYDROGUI/HYDROGUI.h +++ b/src/HYDROGUI/HYDROGUI.h @@ -1,3 +1,24 @@ +// 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_H #define HYDROGUI_H diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx new file mode 100644 index 00000000..c2ed94bd --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -0,0 +1,276 @@ +// 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_DataModel.h" + +#include "HYDROGUI_Module.h" +#include "HYDROGUI_DataObject.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule ) +: LightApp_DataModel( theModule ) +{ + update( module()->application()->activeStudy()->id() ); +} + +HYDROGUI_DataModel::~HYDROGUI_DataModel() +{ +} + +bool HYDROGUI_DataModel::open( const QString& theURL, + CAM_Study* theStudy, + QStringList theFileList ) +{ + LightApp_DataModel::open( theURL, theStudy, theFileList ); + const int aStudyId = theStudy->id(); + + bool res = false; + if( theFileList.count() == 2 ) + { + QString aTmpDir = theFileList[0]; + QString aFileName = theFileList[1]; + + myStudyURL = theURL; + QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName; + + try + { + res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId ); + } + catch(...) + { + res = false; + } + if (!res) + { + module()->application()->putInfo( tr( "LOAD_ERROR" ) ); + return false; + } + } + + // if the document open was successful, the data model update happens + // in the set mode of the module + if( !res ) + update( aStudyId ); + + return true; +} + +bool HYDROGUI_DataModel::save( QStringList& theFileList ) +{ + if (!module()->application()->activeStudy()) + return false; + + const int aStudyId = module()->application()->activeStudy()->id(); + + LightApp_DataModel::save( theFileList ); + + QString aTmpDir; + QString aFileName; + SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr(); + bool isMultiFile = false; + if( resMgr ) + isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); + + // save data to temporary files + LightApp_Study* aStudy = dynamic_cast( module()->application()->activeStudy() ); + aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str(); + aFileName = SUIT_Tools::file (myStudyURL, false ) + "_HYDRO.cbf"; + + QString aFullPath = aTmpDir + aFileName; + bool res = HYDROData_Document::Document( aStudyId )->Save( (char*)aFullPath.toLatin1().constData() ); + if( !res ) + { + module()->application()->putInfo( tr( "SAVE_ERROR" ) ); + return false; + } + + theFileList.append( aTmpDir ); + theFileList.append( aFileName ); + + return true; +} + +bool HYDROGUI_DataModel::saveAs( const QString& theURL, + CAM_Study*, + QStringList& theFileList ) +{ + myStudyURL = theURL; + return save( theFileList ); +} + +bool HYDROGUI_DataModel::close() +{ + return true; +} + +bool HYDROGUI_DataModel::isModified() const +{ + int aStudyID = module()->application()->activeStudy()->id(); + return HYDROData_Document::Document( aStudyID )->IsModified(); +} + +bool HYDROGUI_DataModel::isSaved() const +{ + return true; +} + +void HYDROGUI_DataModel::update( const int theStudyId ) +{ + LightApp_Application* anApp = dynamic_cast( module()->application() ); + if( !anApp ) + return; + + SUIT_DataObject* aStudyRoot = anApp->activeStudy()->root(); + if( !aStudyRoot ) + return; + + if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() ) + anObjectBrowser->setAutoOpenLevel( 3 ); + + // create root object if not exist + CAM_DataObject* aRootObj = root(); + if( !aRootObj ) + aRootObj = createRootModuleObject( aStudyRoot ); + + if( !aRootObj ) + return; + + DataObjectList aList; + aRootObj->children( aList ); + QListIterator anIter( aList ); + while( anIter.hasNext() ) + removeChild( aRootObj, anIter.next() ); + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId ); + if( aDocument.IsNull() ) + return; + + LightApp_DataObject* anImageRootObj = createObject( aRootObj, "IMAGES" ); + + HYDROData_Iterator anIterator( aDocument, KIND_IMAGE ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Image) anImageObj = + Handle(HYDROData_Image)::DownCast( anIterator.Current() ); + if( !anImageObj.IsNull() ) + createObject( anImageRootObj, anImageObj ); + } +} + +HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Object)& theModelObject ) +{ + return NULL; // to do if necessary +} + +HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject ) +{ + return NULL; // to do if necessary +} + +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; +} + +void HYDROGUI_DataModel::update( LightApp_DataObject* theObject, + LightApp_Study* theStudy ) +{ + if( !theStudy ) + theStudy = dynamic_cast( module()->application()->activeStudy()) ; + if( theStudy ) + update( theStudy->id() ); +} + +CAM_DataObject* HYDROGUI_DataModel::createRootModuleObject( SUIT_DataObject* theParent ) +{ + CAM_DataObject* aRootObj = createModuleObject( theParent ); + setRoot( aRootObj ); + return aRootObj; +} + +void HYDROGUI_DataModel::updateModel() +{ + HYDROGUI_Module* aModule = dynamic_cast( module() ); + if( aModule ) + update( aModule->getStudyId() ); +} + +LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent, + Handle(HYDROData_Object) theModelObject ) +{ + return new HYDROGUI_DataObject( theParent, theModelObject ); +} + +LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent, + const QString& theName ) +{ + return new HYDROGUI_NamedObject( theParent, theName ); +} + +void HYDROGUI_DataModel::removeChild( SUIT_DataObject* theParent, + SUIT_DataObject* theChild ) +{ + SUIT_DataObject* aSubChild = theChild->firstChild(); + for( ; aSubChild; aSubChild = aSubChild->nextBrother() ) + removeChild( theChild, aSubChild ); + theParent->removeChild( theChild ); +} + +SUIT_DataObject* HYDROGUI_DataModel::findChildByName( const SUIT_DataObject* theFather, + const QString& theName ) +{ + SUIT_DataObject* aChild = theFather->firstChild(); + while( aChild ) + { + if( aChild->name() == theName ) + return aChild; // found + aChild = aChild->nextBrother(); + } + return NULL; // not found +} diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h new file mode 100644 index 00000000..063d0166 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -0,0 +1,178 @@ +// 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_DATAMODEL_H +#define HYDROGUI_DATAMODEL_H + +#include "HYDROGUI.h" + +#include + +#include +#include + +#include + +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 + */ + 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. + */ + virtual bool open( const QString& theURL, + CAM_Study* theStudy, + QStringList theFileList ); + + /** + * Saves the document. Reimplemented. + * /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. + */ + virtual bool saveAs( const QString& theURL, + CAM_Study* theStudy, + QStringList& theFileList ); + + /** + * Close the model and remove data. Reimplemented. + */ + virtual bool close(); + + /** + * Returns modification status. Reimplemented. + * /return boolean value of modification status + */ + virtual bool isModified() const; + + /** + * Returns saving status. Reimplemented. + * \return true if document has saved files on disc. + */ + virtual bool isSaved() const; + + /** + * Updates the internal structure of data object tree. + * \param theStudyId study identifier + */ + virtual void update( const int theStudyId ); + + /** + * Returns data object corresponding to the model object. + * \param the data model object + * \returns the only one object referenced to the given data model object, or null if not found + */ + virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject ); + + /** + * Returns a data object referenced to the given data object. + * \param the data object + * \returns the object referenced to the given object, or null if not found + */ + virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject ); + + /** + * Finds the object by entry + * \param theEntry an object entry + */ + virtual SUIT_DataObject* findObject( const QString& theEntry ) const; + + /** + * Updates the internal structure of data object tree starting from specified data object \a obj. + * /param theObject start data object + * /param theStudy study object + */ + virtual void update( LightApp_DataObject* theObject = 0, + LightApp_Study* theStudy = 0 ); + + /** + * Creates a module object and set is a root for the model + */ + CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent ); + + /** + * Correct an internal model object according to the current document mode + */ + void updateModel(); + +protected: + /** + * Creates the GUI data object according to the model object. + * \param theParent a created object will be appended as a child of this object + * \param theObject model object + */ + LightApp_DataObject* createObject( SUIT_DataObject* theParent, + Handle(HYDROData_Object) theModelObject ); + + /** + * Creates the GUI data object without corresponding model object: just by name + * \param theParent a created object will be appended as a child of this object + * \param theName name of this object + */ + LightApp_DataObject* createObject( SUIT_DataObject* theParent, + const QString& theName ); + + /** + * Removes data object from the tree. + * \param theParent an object will be removed from this parent. + * \param theChild the removed object. + */ + void removeChild( SUIT_DataObject* theParent, + SUIT_DataObject* theChild ); + + /** + * Returns the first child of the object with the specified name + * \param theFather object that contain the searched object in children + * \param theName name f the searched data object + * \returns NULL if not found + */ + static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather, + const QString& theName ); + +protected: + QString myStudyURL; ///< the saved/opened document URL +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx new file mode 100644 index 00000000..c1ff5a25 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -0,0 +1,92 @@ +// 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_DataObject.h" + +#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; +} + +QString HYDROGUI_DataObject::name() const +{ + if( !myData.IsNull() ) + return myData->GetName(); + return QString(); +} + +HYDROGUI_DataObject* HYDROGUI_DataObject::objectByEntry( const QString& theEntry ) +{ + 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; +} + +HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent, + const QString& theName ) +: CAM_DataObject( theParent ), + LightApp_DataObject( theParent ), + myName( theName ) +{ +} + +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; +} + +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 new file mode 100644 index 00000000..4e92dfff --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataObject.h @@ -0,0 +1,129 @@ +// 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_DATAOBJECT_H +#define HYDROGUI_DATAOBJECT_H + +#include "HYDROGUI.h" + +#include + +#include + +#include +#include +#include + +/** + * \class HYDROGUI_DataObject + * \brief Module data object, used for object browser tree creation. + * + * This is an Object Browser object that contains reference to data structure + * element inside. + * This class inherits CAM_DataObject virtually, so it is necessary to call in the class + * constructor the CAM object constructor manually for the correct initialization + */ +class HYDROGUI_DataObject : public LightApp_DataObject +{ +public: + /** + * Constructor. + * \param theParent parent data object + * \param theData reference to the corresponding object from data structure + */ + HYDROGUI_DataObject( SUIT_DataObject* theParent, + Handle(HYDROData_Object) theData ); + + /** + * Returns the unique object identifier string. + */ + virtual QString entry() const; + + /** + * Returns the name of object. + */ + virtual QString name() const; + + /** + * Returns the model data object. + */ + const Handle(HYDROData_Object)& modelObject() const { return myData; } + + /** + * Redefines the object. + */ + 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 + */ + static HYDROGUI_DataObject* objectByEntry( const QString& theEntry ); + +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 +}; + +/** + * \class HYDROGUI_NamedObject + * \brief Module data object, used for object browser tree creation. + * + * It contains only name inside, without additional data: it is just information + * or grouping object in the Object Browser. + * This class inherits CAM_DataObject virtually, so it is necessary to call in the class + * constructor the CAM object constructor manually for the correct initialization + */ +class HYDROGUI_NamedObject : public virtual LightApp_DataObject +{ +public: + /** + * Constructor. + * \param theParent parent data object + * \param theName displayed name + */ + HYDROGUI_NamedObject( SUIT_DataObject* theParent, + const QString& theName ); + + /** + * Returns the unique object identifier string. + */ + virtual QString entry() const; + + /** + * Returns the name of object. + */ + 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 +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 6e3181f9..fb9144b8 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -1,8 +1,31 @@ +// 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_InputPanel.h" +#include "HYDROGUI_Module.h" -#include -#include #include #include + #include #include diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 33d36217..319086fe 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -1,8 +1,29 @@ +// 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_DIALOG_HEADER -#define HYDROGUI_DIALOG_HEADER +#ifndef HYDROGUI_INPUTPANEL_H +#define HYDROGUI_INPUTPANEL_H -#include +#include "HYDROGUI.h" #include class HYDROGUI_Module; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index bad6da24..5b58847d 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -1,18 +1,46 @@ +// 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_Module.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_InputPanel.h" +#include "HYDROGUI_ObjSelector.h" +#include "HYDROGUI_Operations.h" -#include -#include -#include #include -#include #include #include +#include + +#include #include -#include +#include + #include +#include +#include + #include -#include -#include -#include extern "C" HYDRO_EXPORT CAM_Module* createModule() { @@ -28,6 +56,12 @@ HYDROGUI_Module::~HYDROGUI_Module() { } +int HYDROGUI_Module::getStudyId() const +{ + LightApp_Application* anApp = getApp(); + return anApp ? anApp->activeStudy()->id() : 0; +} + void HYDROGUI_Module::initialize( CAM_Application* theApp ) { printf( "Initialization of the HYDROGUI module\n" ); @@ -62,6 +96,16 @@ void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const theTypesList << GraphicsView_Viewer::Type(); } +HYDROGUI_DataModel* HYDROGUI_Module::getModel() const +{ + return (HYDROGUI_DataModel*)dataModel(); +} + +CAM_DataModel* HYDROGUI_Module::createDataModel() +{ + return new HYDROGUI_DataModel( this ); +} + void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) { LightApp_Module::onViewManagerAdded( theMgr ); diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 7ed7f660..b930a167 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -1,12 +1,36 @@ +// 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_MODULE_HEADER -#define HYDROGUI_MODULE_HEADER +#ifndef HYDROGUI_MODULE_H +#define HYDROGUI_MODULE_H + +#include "HYDROGUI.h" -#include #include class SUIT_ViewWindow; +class HYDROGUI_DataModel; + /**\class HYDROGUI_Module *\brief The class representing the HYDROGUI module */ @@ -18,10 +42,20 @@ public: HYDROGUI_Module(); virtual ~HYDROGUI_Module(); + /** + * Returns the module study identifier + */ + int getStudyId() const; + virtual void initialize( CAM_Application* ); virtual void windows( QMap& ) const; virtual void viewManagers( QStringList& ) const; + HYDROGUI_DataModel* getModel() const; + +protected: + CAM_DataModel* createDataModel(); + public slots: virtual bool activateModule( SUIT_Study* ); diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index 02c737bb..95c4aa60 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -1,13 +1,36 @@ +// 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 +#include "HYDROGUI_ObjSelector.h" +#include "HYDROGUI_Module.h" + +#include #include -#include #include -#include +#include + #include -#include #include +#include HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent ) : QAbstractButton( theParent ), myModule( theModule ) diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.h b/src/HYDROGUI/HYDROGUI_ObjSelector.h index 427ddd93..b3e1019e 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.h +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.h @@ -1,6 +1,27 @@ - -#ifndef HYDROGUI_OBJ_SELECTOR_HEADER -#define HYDROGUI_OBJ_SELECTOR_HEADER +// 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_OBJSELECTOR_H +#define HYDROGUI_OBJSELECTOR_H #include diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 3b74134f..0d7310d6 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -1,11 +1,35 @@ +// 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_Operation.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_InputPanel.h" -#include -#include -#include #include #include + #include #include + #include #include diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 67938e59..57330060 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -1,8 +1,30 @@ +// 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_OPERATION_HEADER -#define HYDROGUI_OPERATION_HEADER +#ifndef HYDROGUI_OPERATION_H +#define HYDROGUI_OPERATION_H + +#include "HYDROGUI.h" -#include #include class HYDROGUI_Module; diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 0a23fe33..568da592 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -1,13 +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 -#include -#include -#include +#include "HYDROGUI_Operations.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_ImportImageOp.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_TwoImagesOp.h" + +#include +#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 ) @@ -34,10 +63,9 @@ void HYDROGUI_Module::CreateActions() void HYDROGUI_Module::CreateMenus() { - int aFileId = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 ); - - createMenu( separator(), aFileId, -1, 1, -1 ); - createMenu( ImportImageId, aFileId, -1, -1 ); + 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 ); } void HYDROGUI_Module::CreatePopups() @@ -54,6 +82,34 @@ 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_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index ad5aab33..8828917f 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -1,6 +1,27 @@ +// 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_OPERATIONS_HEADER -#define HYDROGUI_OPERATIONS_HEADER +#ifndef HYDROGUI_OPERATIONS_H +#define HYDROGUI_OPERATIONS_H enum OperationId { diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx index 98ab08cc..5eb67671 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx @@ -9,7 +9,6 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) { - printf( "two images operation\n" ); myName = new QLineEdit(); myImage1 = new HYDROGUI_ObjSelector( module(), 0 ); myImage2 = new HYDROGUI_ObjSelector( module(), 0 ); diff --git a/src/HYDROGUI/resources/HYDRO.png b/src/HYDROGUI/resources/HYDRO.png index 7eba0d76..ffd66c78 100755 Binary files a/src/HYDROGUI/resources/HYDRO.png and b/src/HYDROGUI/resources/HYDRO.png differ diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index dd0c8589..1344d4a1 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2,9 +2,35 @@ @default + + + HYDROGUI_DataModel + + LOAD_ERROR + Study could not be loaded + + + SAVE_ERROR + Study could not be saved + + + + HYDROGUI_Module + + DSK_IMPORT_IMAGE + Import image + + + MEN_DESK_HYDRO + HYDRO + + + MEN_IMPORT_IMAGE + Import image + - TEST - Test + STB_IMPORT_IMAGE + Import image diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts b/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts index dd0c8589..b3ce4f44 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_fr.ts @@ -2,9 +2,5 @@ @default - - TEST - Test - diff --git a/src/HYDROGUI/resources/LightApp.xml b/src/HYDROGUI/resources/LightApp.xml index d7895ac4..5036239c 100644 --- a/src/HYDROGUI/resources/LightApp.xml +++ b/src/HYDROGUI/resources/LightApp.xml @@ -2,7 +2,7 @@
- +
@@ -15,5 +15,6 @@
+