X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2FSalomeApp_Module.cxx;h=bf1ddf57602e000f544e0a7cb63536ce01839a89;hb=08434ce2731f6dc141a870b92a95aca0f8129398;hp=acd4be6d7ce93228820f43bd405b8637ded5ad00;hpb=bb8609caf7881d966fbb88dec0a7822736da93f5;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index acd4be6d7..bf1ddf576 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// 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 @@ -6,7 +6,7 @@ // 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. +// 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 @@ -38,7 +38,6 @@ //#include "OB_Browser.h" #include -#include #include #include @@ -53,8 +52,7 @@ /*!Constructor.*/ SalomeApp_Module::SalomeApp_Module( const QString& name ) - : LightApp_Module( name ), - myIsFirstActivate( true ) + : LightApp_Module( name ) { } @@ -141,22 +139,6 @@ void SalomeApp_Module::storeVisualParameters(int savePoint) { } - -/*!Activate module.*/ -bool SalomeApp_Module::activateModule( SUIT_Study* theStudy ) -{ - bool state = LightApp_Module::activateModule( theStudy ); - - if (!myIsFirstActivate) - return state; - - updateModuleVisibilityState(); - - myIsFirstActivate = false; - - return state; -} - /*! * \brief Virtual public * @@ -166,94 +148,3 @@ bool SalomeApp_Module::activateModule( SUIT_Study* theStudy ) void SalomeApp_Module::restoreVisualParameters(int savePoint) { } - -/*! Redefined to reset internal flags valid for study instance */ -void SalomeApp_Module::studyClosed( SUIT_Study* theStudy ) -{ - LightApp_Module::studyClosed( theStudy ); - - myIsFirstActivate = true; - - LightApp_Application* app = dynamic_cast(application()); - if (!app) - return; - - SUIT_DataBrowser* ob = app->objectBrowser(); - if (ob && ob->model()) - disconnect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ), - this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) ); -} - - -/*! - * \brief Virtual public slot - * - * This method is called after the object inserted into data view to update their visibility state - * This is default implementation - */ -void SalomeApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn ) -{ - if (!isActiveModule()) - return; - // change visibility of object - if (!theObject || theColumn != SUIT_DataObject::VisibilityId ) - return; - - SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); - if( !study ) - return; - - LightApp_DataObject* lo = dynamic_cast(theObject); - if(!lo) - return; - - // detect action index (from LightApp level) - int id = -1; - - if ( study->visibilityState(lo->entry()) == Qtx::ShownState ) - id = myErase; - else if ( study->visibilityState(lo->entry()) == Qtx::HiddenState ) - id = myDisplay; - - if ( id != -1 ) - startOperation( id ); -} - - -/*! - Called then study closed -*/ -void SalomeApp_Application::onStudyClosed( SUIT_Study* theStudy){ - LightApp_Application::onStudyClosed(theStudy); - - disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ), - this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); -} - - -void SalomeApp_Module::updateModuleVisibilityState() { - - // update visibility state of objects - SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); - if (!app) - return; - - SUIT_DataBrowser* ob = app->objectBrowser(); - if (!ob || !ob->model()) - return; - - // connect to click on item - connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ), - this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection ); - - SUIT_DataObject* rootObj = ob->root(); - if( !rootObj ) - return; - - DataObjectList listObj = rootObj->children( true ); - - SUIT_ViewModel* vmod = 0; - if ( SUIT_ViewManager* vman = app->activeViewManager() ) - vmod = vman->getViewModel(); - app->updateVisibilityState( listObj, vmod ); -}