X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FSalomeApp%2FSalomeApp_Module.cxx;h=bf1ddf57602e000f544e0a7cb63536ce01839a89;hb=1c6902702083f5f05f7cad582c59445c089b9086;hp=9123d76f7084fc236ec2a537d46b4fadfa58db4d;hpb=d1fdf04f4ad9507921eed78ec03edb7b5e52a6a0;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 9123d76f7..bf1ddf576 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -1,46 +1,64 @@ +// Copyright (C) 2007-2016 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, or (at your option) any later version. +// +// 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 +// + // File: SalomeApp_Module.cxx // Created: 10/25/2004 11:39:56 AM // Author: Sergey LITONIN -// Copyright (C) CEA 2004 #include "SalomeApp_Module.h" - -#include "SalomeApp_Study.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" +#include "SalomeApp_DataObject.h" -#include "LightApp_Preferences.h" -#include "SalomeApp_UpdateFlags.h" -#include "SalomeApp_Operation.h" -#include "SalomeApp_SwitchOp.h" +#include "LightApp_Selection.h" -#include "SUIT_Operation.h" #include "CAM_DataModel.h" -#include "OB_Browser.h" +// temporary commented +//#include "OB_Browser.h" + +#include +#include + +#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include /*!Constructor.*/ SalomeApp_Module::SalomeApp_Module( const QString& name ) -: LightApp_Module( name ), -mySwitchOp( 0 ) + : LightApp_Module( name ) { } /*!Destructor.*/ SalomeApp_Module::~SalomeApp_Module() { - if ( mySwitchOp ) - delete mySwitchOp; } /*!Gets application.*/ @@ -49,159 +67,84 @@ SalomeApp_Application* SalomeApp_Module::getApp() const return (SalomeApp_Application*)application(); } -/*!Activate module.*/ -bool SalomeApp_Module::activateModule( SUIT_Study* study ) -{ - bool res = LightApp_Module::activateModule( study ); - - if ( mySwitchOp == 0 ) - mySwitchOp = new SalomeApp_SwitchOp( this ); - - return res; -} - -/*!Deactivate module.*/ -bool SalomeApp_Module::deactivateModule( SUIT_Study* study ) -{ - bool res = LightApp_Module::deactivateModule( study ); - - delete mySwitchOp; - mySwitchOp = 0; - - return res; -} - /*!Create new instance of data model and return it.*/ CAM_DataModel* SalomeApp_Module::createDataModel() { return new SalomeApp_DataModel(this); } -/*! - * \brief Update something in accordance with update flags - * \param theFlags - update flags -* -* Update viewer or/and object browser etc. in accordance with update flags ( see -* SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method for their -* own purposes -*/ -void SalomeApp_Module::update( const int theFlags ) +/*!Create and return instance of LightApp_Selection.*/ +LightApp_Selection* SalomeApp_Module::createSelection() const { - if ( theFlags & UF_Model ) - { - if( CAM_DataModel* aDataModel = dataModel() ) - if( SalomeApp_DataModel* aModel = dynamic_cast( aDataModel ) ) { - SalomeApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); - if (aStudy) - aModel->update( 0, aStudy ); - } - } - if ( theFlags & UF_ObjBrowser ) - getApp()->objectBrowser()->updateTree( 0 ); - if ( theFlags & UF_Controls ) - updateControls(); - if ( theFlags & UF_Viewer ) - { - if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() ) - if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() ) - { - if ( viewWnd->inherits( "SVTK_ViewWindow" ) ) - ( (SVTK_ViewWindow*)viewWnd )->Repaint(); - else if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) ) - ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate(); - else if ( viewWnd->inherits( "Plot2d_ViewWindow" ) ) - ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint(); - else if ( viewWnd->inherits( "GLViewer_ViewFrame" ) ) - ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate(); - } - } + return LightApp_Module::createSelection(); } /*! - * \brief Updates controls -* -* Updates (i.e. disable/enable) controls states (menus, tool bars etc.). This method is -* called from update( UF_Controls ). You may redefine it in concrete module. + Converts objects-containers to list of objects, those are contained + Other objects must be added without conversion + \param source - source list of objects + \param dest - list of converted objects */ -void SalomeApp_Module::updateControls() +void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_ListIO& dest ) const { -} + SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if( !study ) + { + dest = source; + return; + } -/*! - * \brief Starts operation with given identifier - * \param id - identifier of operation to be started -* -* Module stores operations in map. This method starts operation by id. -* If operation isn't in map, then it will be created by createOperation method -* and will be inserted to map -*/ -void SalomeApp_Module::startOperation( const int id ) -{ - SalomeApp_Operation* op = 0; - if( myOperations.contains( id ) ) - op = myOperations[ id ]; - else + SALOME_ListIteratorOfListIO anIt( source ); + for( ; anIt.More(); anIt.Next() ) { - op = createOperation( id ); - if( op ) + Handle( SALOME_InteractiveObject ) obj = anIt.Value(); + if( obj->hasEntry() ) { - myOperations.insert( id, op ); - op->setModule( this ); - connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) ); - connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) ); + _PTR(SObject) SO = study->studyDS()->FindObjectID( obj->getEntry() ); + if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() ) + { //component is selected + _PTR(SComponent) SC( SO->GetFatherComponent() ); + _PTR(ChildIterator) anIter ( study->studyDS()->NewChildIterator( SC ) ); + anIter->InitEx( true ); + while( anIter->More() ) + { + _PTR(SObject) valSO ( anIter->Value() ); + _PTR(SObject) refSO; + if( !valSO->ReferencedObject( refSO ) ) + { + QString id = valSO->GetID().c_str(), + comp = SC->ComponentDataType().c_str(), + val = valSO->GetName().c_str(); + + Handle( SALOME_InteractiveObject ) new_obj = + new SALOME_InteractiveObject( id.toLatin1(), comp.toLatin1(), val.toLatin1() ); + dest.Append( new_obj ); + } + anIter->Next(); + } + continue; + } } + dest.Append( obj ); } - - if( op ) - op->start(); } /*! - * \brief Creates operation with given identifier - * \param id - identifier of operation to be started - * \return Pointer on created operation or NULL if operation is not created -* -* Creates operation with given id. You should not call this method, it will be called -* automatically from startOperation. You may redefine this method in concrete module to -* create operations. -*/ -SalomeApp_Operation* SalomeApp_Module::createOperation( const int /*id*/ ) const -{ - return 0; -} - -/*! - * \brief Virtual protected slot called when operation stopped - * \param theOp - stopped operation -* -* Virtual protected slot called when operation stopped. Redefine this slot if you want to -* perform actions after stopping operation -*/ -void SalomeApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ ) + * \brief Virtual public + * + * This method is called just before the study document is saved, so the module has a possibility + * to store visual parameters in AttributeParameter attribut + */ +void SalomeApp_Module::storeVisualParameters(int savePoint) { } /*! - * \brief Virtual protected slot called when operation destroyed - * \param theOp - destroyed operation -* -* Virtual protected slot called when operation destroyed. Redefine this slot if you want to -* perform actions after destroying operation. Base implementation removes pointer on -* destroyed operation from the map of operations -*/ -void SalomeApp_Module::onOperationDestroyed() + * \brief Virtual public + * + * This method is called after the study document is opened, so the module has a possibility to restore + * visual parameters + */ +void SalomeApp_Module::restoreVisualParameters(int savePoint) { - const QObject* s = sender(); - if( s && s->inherits( "SalomeApp_Operation" ) ) - { - const SalomeApp_Operation* op = ( SalomeApp_Operation* )s; - MapOfOperation::const_iterator anIt = myOperations.begin(), - aLast = myOperations.end(); - for( ; anIt!=aLast; anIt++ ) - if( anIt.data()==op ) - { - myOperations.remove( anIt.key() ); - break; - } - } }