1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEGUI_Desktop.cxx
25 // Author : Nicolas REJNERI
29 #include "SALOMEGUI_Desktop.h"
30 #include "SALOME_Selection.h"
31 #include "SALOME_ListIteratorOfListIO.hxx"
33 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
39 SALOMEGUI_Desktop::SALOMEGUI_Desktop(SALOME_NamingService* name_service) :
40 QAD_Desktop( name_service )
42 QAD_ASSERT_DEBUG_ONLY( !myStdActions.isEmpty() );
43 //myStdActions.at( FileOpenId )->setEnabled( true );
44 //myStdActions.at( FileSaveId )->setEnabled( true );
45 //myStdActions.at( FileSaveAsId )->setEnabled( true );
49 Disable file actions for DEMO
51 void SALOMEGUI_Desktop::updateDesktop( UpdateCommand cmd )
53 QAD_Desktop::updateDesktop( cmd );
55 QAD_ASSERT_DEBUG_ONLY( !myStdActions.isEmpty() );
56 //myStdActions.at( FileOpenId )->setEnabled( true );
57 //myStdActions.at( FileSaveId )->setEnabled( true );
58 //myStdActions.at( FileSaveAsId )->setEnabled( true );
61 QString SALOMEGUI_Desktop::getComponentFromSelection()
63 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
66 SALOME_ListIteratorOfListIO Itinit( Sel->StoredIObjects() );
67 for (; Itinit.More(); Itinit.Next()) {
68 List.Append(Itinit.Value());
71 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
73 SALOME_ListIteratorOfListIO It( List );
76 for (; It.More(); It.Next()) {
77 Handle(SALOME_InteractiveObject) IObject = It.Value();
79 if (!IObject->hasEntry()) continue;
81 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
83 if ( !obj->_is_nil() ) {
84 SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
85 if ( !comp->_is_nil() ) {
86 SALOMEDS::GenericAttribute_var anAttr;
87 SALOMEDS::AttributeName_var aName;
88 if (comp->FindAttribute(anAttr, "AttributeName")) {
89 aName = SALOMEDS::AttributeName::_narrow(anAttr);
90 QString compName(aName->Value());
91 if (parentComp.isNull())
92 parentComp = compName;
93 else if (parentComp.compare(compName) != 0) { // objects belonging to different components are selected
94 parentComp = QString::null;