+// 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_DataModel.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
+#include "SalomeApp_DataObject.h"
+
+#include "LightApp_Selection.h"
-#include <OB_Browser.h>
+#include "CAM_DataModel.h"
-#include <CAM_Study.h>
+// temporary commented
+//#include "OB_Browser.h"
+#include <SALOME_ListIO.hxx>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <LightApp_DataObject.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_DataBrowser.h>
+#include <SUIT_ViewManager.h>
#include <SUIT_MessageBox.h>
-#include <SUIT_ResourceMgr.h>
+#include <SUIT_Desktop.h>
-#include <QtxPopupMgr.h>
+#include <QString>
+/*!Constructor.*/
SalomeApp_Module::SalomeApp_Module( const QString& name )
-: CAM_Module( name ),
-myPopupMgr( 0 )
+ : LightApp_Module( name )
{
}
+/*!Destructor.*/
SalomeApp_Module::~SalomeApp_Module()
{
}
-void SalomeApp_Module::initialize( CAM_Application* app )
-{
- CAM_Module::initialize( app );
-
- SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
- if ( resMgr )
- resMgr->raiseTranslators( name() );
-}
-
-void SalomeApp_Module::activateModule( SUIT_Study* study )
-{
- CAM_Module::activateModule( study );
-
- if ( application() && application()->resourceMgr() )
- application()->resourceMgr()->raiseTranslators( name() );
-}
-
-void SalomeApp_Module::deactivateModule( SUIT_Study* )
-{
-}
-
-void SalomeApp_Module::selectionChanged()
-{
-}
-
-void SalomeApp_Module::MenuItem()
-{
-}
-
-void SalomeApp_Module::windows( QMap<int, int>& ) const
-{
-}
-
-void SalomeApp_Module::viewManagers( QStringList& ) const
-{
-}
-
-QString SalomeApp_Module::engineIOR() const
-{
- // Return an empty string by default, to avoid any "default behavior".
- // It means that SALOMEDS persistence is not used by a module by default.
- // Each module can override this method to return either its actual engine's IOR,
- // or simple the result returned by SalomeApp_Application::defaultEngineIOR()
- return QString( "" );
-}
-
+/*!Gets application.*/
SalomeApp_Application* SalomeApp_Module::getApp() const
{
return (SalomeApp_Application*)application();
}
-void SalomeApp_Module::onModelOpened()
-{
-}
-
-void SalomeApp_Module::onModelSaved()
-{
-}
-
-void SalomeApp_Module::onModelClosed()
-{
-}
-
-QtxPopupMgr* SalomeApp_Module::popupMgr()
-{
- if ( !myPopupMgr )
- myPopupMgr = new QtxPopupMgr( 0, this );
- return myPopupMgr;
-}
-
+/*!Create new instance of data model and return it.*/
CAM_DataModel* SalomeApp_Module::createDataModel()
{
return new SalomeApp_DataModel(this);
}
-void SalomeApp_Module::updateObjBrowser( bool updateDataModel, SUIT_DataObject* root )
-{
- if( updateDataModel )
- if( CAM_DataModel* aDataModel = dataModel() )
- if( SalomeApp_DataModel* aModel = dynamic_cast<SalomeApp_DataModel*>( aDataModel ) )
- aModel->update( 0, dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
- getApp()->objectBrowser()->updateTree( root );
-}
-
-void SalomeApp_Module::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
-{
- SalomeApp_Selection* sel = createSelection();
- sel->init( client, getApp()->selectionMgr() );
- popupMgr()->updatePopup( menu, sel );
- delete sel;
-}
-
-SalomeApp_Selection* SalomeApp_Module::createSelection() const
+/*!Create and return instance of LightApp_Selection.*/
+LightApp_Selection* SalomeApp_Module::createSelection() const
+{
+ return LightApp_Module::createSelection();
+}
+
+/*!
+ 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::extractContainers( const SALOME_ListIO& source, SALOME_ListIO& dest ) const
+{
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if( !study )
+ {
+ dest = source;
+ return;
+ }
+
+ SALOME_ListIteratorOfListIO anIt( source );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ Handle( SALOME_InteractiveObject ) obj = anIt.Value();
+ if( obj->hasEntry() )
+ {
+ _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 );
+ }
+}
+
+/*!
+ * \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 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)
{
- return new SalomeApp_Selection();
}