2) Formatting.
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(
+// 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
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_DataModel.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_DataObject.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
+#include <HYDROData_Iterator.h>
+
+#include <CAM_Application.h>
+#include <CAM_DataObject.h>
+#include <CAM_Module.h>
+#include <CAM_Study.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_DataObject.h>
+#include <LightApp_Study.h>
+
+#include <SUIT_DataObject.h>
+#include <SUIT_DataBrowser.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Study.h>
+#include <SUIT_Tools.h>
+
+#include <HYDROData_Document.h>
+
+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<LightApp_Study*>( module()->application()->activeStudy() );
+ aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
+ aFileName = SUIT_Tools::file (myStudyURL, false ) + "_HYDRO.cbf";
+
+ QString aFullPath = aTmpDir + aFileName;
+ 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<LightApp_Application*>( 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<SUIT_DataObject*> 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<LightApp_Application*>( 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<LightApp_Study*>( 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<HYDROGUI_Module*>( 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
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_DATAMODEL_H
+#define HYDROGUI_DATAMODEL_H
+
+#include "HYDROGUI.h"
+
+#include <HYDROData_Object.h>
+
+#include <QMap>
+#include <LightApp_DataModel.h>
+
+#include <SUIT_TreeModel.h>
+
+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
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_DataObject.h"
+
+#include <SUIT_DataObject.h>
+
+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 );
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_DATAOBJECT_H
+#define HYDROGUI_DATAOBJECT_H
+
+#include "HYDROGUI.h"
+
+#include <HYDROData_Object.h>
+
+#include <LightApp_DataObject.h>
+
+#include <QString>
+#include <QMap>
+#include <QPixmap>
+
+/**
+ * \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
+// 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 <HYDROGUI_InputPanel.h>
-#include <HYDROGUI_Module.h>
#include <CAM_Application.h>
#include <SUIT_Desktop.h>
+
#include <QLayout>
#include <QPushButton>
+// 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 <HYDROGUI.h>
+#include "HYDROGUI.h"
#include <QDockWidget>
class HYDROGUI_Module;
+// 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 <HYDROGUI_Module.h>
-#include <LightApp_Application.h>
-#include <LightApp_SelectionMgr.h>
#include <GraphicsView_PrsImage.h>
-#include <GraphicsView_Viewer.h>
#include <GraphicsView_ViewFrame.h>
#include <GraphicsView_ViewPort.h>
+#include <GraphicsView_Viewer.h>
+
+#include <LightApp_Application.h>
#include <LightApp_GVSelector.h>
-#include <SUIT_ViewManager.h>
+#include <LightApp_SelectionMgr.h>
+
#include <SUIT_Desktop.h>
+#include <SUIT_Study.h>
+#include <SUIT_ViewManager.h>
+
#include <QApplication>
-#include <HYDROGUI_InputPanel.h>
-#include <HYDROGUI_ObjSelector.h>
-#include <HYDROGUI_Operations.h>
extern "C" HYDRO_EXPORT CAM_Module* createModule()
{
{
}
+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" );
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 );
+// 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 <HYDROGUI.h>
#include <LightApp_Module.h>
class SUIT_ViewWindow;
+class HYDROGUI_DataModel;
+
/**\class HYDROGUI_Module
*\brief The class representing the HYDROGUI module
*/
HYDROGUI_Module();
virtual ~HYDROGUI_Module();
+ /**
+ * Returns the module study identifier
+ */
+ int getStudyId() const;
+
virtual void initialize( CAM_Application* );
virtual void windows( QMap<int, int>& ) const;
virtual void viewManagers( QStringList& ) const;
+ HYDROGUI_DataModel* getModel() const;
+
+protected:
+ CAM_DataModel* createDataModel();
+
public slots:
virtual bool activateModule( SUIT_Study* );
+// 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_ObjSelector.h>
-#include <HYDROGUI_Module.h>
+#include "HYDROGUI_ObjSelector.h"
+#include "HYDROGUI_Module.h"
+
+#include <GraphicsView_Object.h>
#include <LightApp_Application.h>
-#include <LightApp_SelectionMgr.h>
#include <LightApp_GVSelector.h>
-#include <GraphicsView_Object.h>
+#include <LightApp_SelectionMgr.h>
+
#include <QLayout>
-#include <QToolButton>
#include <QLineEdit>
+#include <QToolButton>
HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent )
: QAbstractButton( theParent ), myModule( theModule )
-
-#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 <QAbstractButton>
+// 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 <HYDROGUI_Operation.h>
-#include <HYDROGUI_Module.h>
-#include <HYDROGUI_InputPanel.h>
#include <HYDROData_Document.h>
#include <HYDROData_Iterator.h>
+
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
+
#include <SUIT_Desktop.h>
#include <SUIT_Study.h>
+// 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 <HYDROGUI.h>
#include <LightApp_Operation.h>
class HYDROGUI_Module;
+// 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_Operations.h>
-#include <HYDROGUI_ImportImageOp.h>
-#include <HYDROGUI_TwoImagesOp.h>
+#include "HYDROGUI_Operations.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_ImportImageOp.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_TwoImagesOp.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Image.h>
#include <CAM_Application.h>
-#include <SUIT_ResourceMgr.h>
+
#include <SUIT_Desktop.h>
+#include <SUIT_ResourceMgr.h>
+
#include <QAction>
+#include <QFileDialog>
QAction* HYDROGUI_Module::CreateAction( const int theId, const QString& theSuffix, const QString& theImg,
const int theKey, const bool isToggle, const QString& theSlot )
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()
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
+// 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
{
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 );
<TS version="1.1" >
<context>
<name>@default</name>
+ </context>
+ <context>
+ <name>HYDROGUI_DataModel</name>
+ <message>
+ <source>LOAD_ERROR</source>
+ <translation>Study could not be loaded</translation>
+ </message>
+ <message>
+ <source>SAVE_ERROR</source>
+ <translation>Study could not be saved</translation>
+ </message>
+ </context>
+ <context>
+ <name>HYDROGUI_Module</name>
+ <message>
+ <source>DSK_IMPORT_IMAGE</source>
+ <translation>Import image</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_HYDRO</source>
+ <translation>HYDRO</translation>
+ </message>
+ <message>
+ <source>MEN_IMPORT_IMAGE</source>
+ <translation>Import image</translation>
+ </message>
<message>
- <source>TEST</source>
- <translation>Test</translation>
+ <source>STB_IMPORT_IMAGE</source>
+ <translation>Import image</translation>
</message>
</context>
</TS>
<TS version="1.1" >
<context>
<name>@default</name>
- <message>
- <source>TEST</source>
- <translation>Test</translation>
- </message>
</context>
</TS>
<document>
<section name="HYDRO" >
<parameter value="HYDRO.png" name="icon" />
- <parameter value="HYDRO GUI" name="name" />
+ <parameter value="HYDRO" name="name" />
<parameter value="HYDROGUI" name="library" />
<parameter value="0" name="parameter_test" />
</section>
</section>
<section name="resources" >
<parameter value="${HYDRORes}" name="HYDRO" />
+ <parameter value="${HYDRORes}" name="HYDROGUI" />
</section>
</document>