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 : QAD_Desktop.cxx
25 // Author : Nicolas REJNERI
30 \class QAD_Desktop QAD_Desktop.h
31 \brief Main desktop of QAD-based application.
33 # include "Utils_ORB_INIT.hxx"
34 # include "Utils_SINGLETON.hxx"
36 #define INCLUDE_MENUITEM_DEF
37 #define DEFAULT_BROWSER "mozilla"
42 #include "QAD_Tools.h"
43 #include "QAD_Desktop.h"
44 #include "QAD_LeftFrame.h"
45 #include "QAD_RightFrame.h"
46 #include "QAD_PyEditor.h"
47 #include "QAD_Operation.h"
48 #include "QAD_XmlHandler.h"
49 #include "QAD_MessageBox.h"
50 #include "QAD_Application.h"
51 #include "QAD_Settings.h"
52 #include "QAD_Config.h"
53 #include "QAD_ObjectBrowser.h"
54 #include "QAD_Resource.h"
55 #include "QAD_FileDlg.h"
56 //NRI #include "QAD_HelpWindow.h"
57 #include "QAD_DirListDlg.h"
58 #include "QAD_WaitCursor.h"
59 #include "SALOMEGUI.h"
60 #include "SALOMEGUI_OpenWith.h"
61 #include "SALOMEGUI_StudyPropertiesDlg.h"
62 #include "SALOMEGUI_TrihedronSizeDlg.h"
63 #include "SALOMEGUI_ExternalBrowserDlg.h"
64 #include "SALOMEGUI_LoadStudiesDlg.h"
65 //#include "SALOME_Selection.h"
66 #include "SALOME_InteractiveObject.hxx"
67 #include "SALOME_ListIteratorOfListIO.hxx"
68 #include "SALOMEGUI_AboutDlg.h"
69 #include "SALOMEGUI_ViewChoiceDlg.h"
70 #include "SALOMEGUI_SetValueDlg.h"
71 #include "utilities.h"
73 #include "SALOMEGUI_CloseDlg.h"
74 #include "SALOMEGUI_ActivateComponentDlg.h"
76 #include "SALOME_Event.hxx"
81 #include <qmessagebox.h>
82 #include <qcolordialog.h>
83 #include <qradiobutton.h>
84 #include <qapplication.h>
85 #include <qvbuttongroup.h>
87 #include <qmessagebox.h>
90 #include <qpopupmenu.h>
91 #include <qlistview.h>
95 #include <qfontdialog.h>
96 #include <qlineedit.h>
97 #include <qdatetime.h>
100 #include <qstringlist.h>
103 #include <qlistbox.h>
107 // Open CASCADE Includes
108 #include <OSD_SharedLibrary.hxx>
109 #include <OSD_LoadMode.hxx>
110 #include <OSD_Function.hxx>
111 #include <TCollection_AsciiString.hxx>
114 static const char* SEPARATOR = ":";
121 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
122 QPalette* QAD_Desktop::palette = 0;
124 static QString createString( int theItemId, int thePosId )
126 QString aRetString = QString("item-id=");
128 QString aItemId = aString.setNum(theItemId);
129 QString aPosId = aString.setNum(thePosId);
130 aRetString = aRetString + '"'; aRetString = aRetString + aItemId; aRetString = aRetString + '"';
131 aRetString = aRetString + " pos-id="; aRetString = aRetString + '"';
132 aRetString = aRetString + aPosId;
133 aRetString = aRetString + '"'; aRetString = aRetString + ">";
138 Creates the resource manager [ static ]
140 QAD_ResourceMgr* QAD_Desktop::createResourceManager()
143 resourceMgr = new QAD_ResourceMgr;
148 Returns the resource manager [ static ]
150 QAD_ResourceMgr* QAD_Desktop::getResourceManager()
157 Loads the palette from settings [ static ]
159 QPalette* QAD_Desktop::createPalette()
162 palette = new QPalette();
168 Returns the palette [ static ]
170 QPalette* QAD_Desktop::getPalette()
176 Gets window ratio width/heght [ static ]
178 static double myWindowRatio = 1;
179 static double getWindowRatio()
181 return myWindowRatio;
185 Sets window ratio width/heght [ static ]
187 static void setWindowRatio(double aRatio)
189 myWindowRatio = aRatio;
195 QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) :
196 QMainWindow(0, 0, WType_TopLevel | WDestructiveClose),
202 //NRImyHelpWindow(0),
203 myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
206 /* Force reading of user config file */
207 QAD_CONFIG->readConfigFile();
209 /* menubar and status bar */
210 myStatusBar = statusBar();
211 myMainMenu = menuBar();
213 myNameService = name_service;
215 /* default background icon */
216 QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
217 tr("ICON_DESK_BACKGROUNDICON") ));
218 //myToolBarAction.setAutoDelete( true );
220 /* default icon and title */
221 QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
222 tr("ICON_DESK_DEFAULTICON") ));
223 if ( !icon.isNull() ) {
224 myDefaultIcon = icon;
225 setIcon( myDefaultIcon );
227 setCaption( myDefaultTitle );
229 /* set size as 1/2 of the screen and center it */
230 QWidget* d = QApplication::desktop();
231 resize( 2*d->width()/3, 2*d->height()/3 );
232 QAD_Tools::centerWidget( this, d );
234 /* workspace will manage child frames */
235 QHBox* border = new QHBox ( this );
236 border->setFrameStyle ( QFrame::Panel | QFrame::Sunken );
237 setCentralWidget( border );
238 myWorkspace = new QWorkspaceP( border );
240 QPalette pal = QAD_Application::getPalette();
242 QColorGroup cgA = pal.active();
243 QColorGroup cgI = pal.inactive();
244 QColorGroup cgD = pal.disabled();
245 cgA.setColor( QColorGroup::Background, QColor(192, 192, 192));
246 cgI.setColor( QColorGroup::Background, QColor(192, 192, 192));
247 cgD.setColor( QColorGroup::Background, QColor(192, 192, 192));
248 pal.setActive ( cgA );
249 pal.setInactive( cgI );
250 pal.setDisabled( cgD );
251 myWorkspace->setPalette( pal );
252 if ( !backgroundicon.isNull() ) {
253 MESSAGE("!!!DESKTOP background icon found!!!");
254 myWorkspace->setPaletteBackgroundPixmap(backgroundicon);
257 /* define standard file commands */
260 /* define operator menus for xml */
261 myOperatorMenus = new QAD_OperatorMenus(this);
262 myXmlHandler = new QAD_XmlHandler();
265 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
266 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
268 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
269 myCatalogue->GetComponentIconeList();
272 QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this );
273 tbComponent->setCloseMode( QDockWindow::Undocked );
274 addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE );
275 setDockEnabled( tbComponent, DockLeft, false );
276 setDockEnabled( tbComponent, DockRight, false );
278 myCombo = new QComboBox( FALSE, tbComponent, "comboBox" );
279 myCombo->setFocusPolicy( NoFocus );
281 tbComponent->addSeparator();
283 // PG : add ResourceManager to get function findFile !!
284 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
286 for (unsigned int ind = 0; ind < list_composants->length();ind++) {
289 /* find component icon */
290 QString iconfile = strdup(list_composants[ind].moduleicone) ;
291 QString modulename = strdup(list_composants[ind].modulename) ;
292 QString moduleusername = strdup(list_composants[ind].moduleusername) ;
294 // MESSAGE ( " MODULE = " << modulename )
295 // MESSAGE ( " MODULE icon = " << iconfile )
296 // MESSAGE ( " MODULE username = " << moduleusername )
298 if ( mapComponentName.contains( moduleusername ) ) {
299 QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
302 mapComponentName.insert( moduleusername, modulename );
304 resDir = resMgr->findFile(iconfile,modulename) ;
307 MESSAGE ( "resDir" << resDir )
308 //resDir = QAD_Tools::addSlash(resDir) ;
309 //QPixmap Icone(resDir+iconfile) ;
310 QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
311 QToolButton * toolb =
312 new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this,
313 SLOT( onButtonActiveComponent () ),tbComponent );
314 toolb->setToggleButton( true );
315 myComponentButton.append(toolb);
319 QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) +
321 //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
323 if ( ( resDir || moduleusername == "Salome" ) && !modulename.isEmpty() ) // VSR: Force "Salome" component to appear in the combo box
324 myCombo->insertItem( moduleusername );
327 myCombo->adjustSize();
328 connect( myCombo, SIGNAL(activated(const QString&)),
329 this, SLOT( onComboActiveComponent(const QString&) ) );
331 /* new LifeCycleCORBA client, for Engines */
332 myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service);
334 /* VSR 13/01/03 : installing global event filter for the application */
335 qApp->installEventFilter( this );
337 /* init pseudo random numbers generator */
338 QTime cTime = QTime::currentTime();
339 int secs = cTime.second() + 1;
340 for ( int s = 0; s < secs; s++ ) random();
346 QAD_Desktop::~QAD_Desktop ()
348 qApp->removeEventFilter( this );
352 myObjBrowserPopup.clear();
353 //VRV: T2.5 - add default viewer
354 myDefaultViewer.clear();
355 //VRV: T2.5 - add default viewer
356 myViewerPopup.clear();
358 myNewViewPopup.clear();
360 myHelpContentsModulePopup.clear();
361 myToolsPopup.clear();
363 myStdActions.clear();
365 myToolBarsPopup.clear();
366 myToolBarAction.clear();
369 //NRI if (myHelpWindow)
370 // myHelpWindow->close();
372 QAD_Application::desktop = 0;
375 const int IdCut = 1001;
376 const int IdCopy = 1002;
377 const int IdPaste = 1003;
378 const int IdSelectAll = 1004;
380 #include <qkeysequence.h>
381 #define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
383 #define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
385 #include <qclipboard.h>
387 Global event filter for qapplication (VSR 13/01/03)
389 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
391 if (e->type() == 2000 ) {
392 QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
395 else if (e->type() == 2001 ) {
396 QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
399 else if ( e->type() == QEvent::ContextMenu ) {
400 QContextMenuEvent* ce = (QContextMenuEvent*)e;
401 if ( o->inherits("QRenameEdit") ) {
404 else if ( o->inherits("QLineEdit") ) {
405 QLineEdit* le = (QLineEdit*)o;
406 if ( le->parentWidget() ) {
407 if ( ( le->parentWidget()->inherits("QSpinBox") ||
408 le->parentWidget()->inherits("QSpinWidget") ||
409 le->parentWidget()->inherits("QAD_SpinBoxDbl") ) &&
411 QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" );
412 popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut );
413 popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy );
414 popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste );
415 popup->insertSeparator();
416 #if defined(Q_WS_X11)
417 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll );
419 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll );
421 bool enableCut = !le->isReadOnly() && le->hasSelectedText();
422 popup->setItemEnabled( IdCut, enableCut );
423 popup->setItemEnabled( IdCopy, le->hasSelectedText() );
424 bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty();
425 popup->setItemEnabled( IdPaste, enablePaste );
426 bool allSelected = (le->selectedText() == le->text() );
427 popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected );
429 QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() :
430 le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 );
432 int r = popup->exec( pos );
454 else if ( e->type() == SALOME_EVENT ) {
455 SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data();
457 // Signal the calling thread that the event has been processed
459 ((QCustomEvent*)e)->setData( 0 );
463 return QMainWindow::eventFilter( o, e );
467 Dispatches <theEvent> to the target component GUI
469 void QAD_Desktop::processEvent( SALOME_Event* theEvent )
477 Creates and initializes the standard file operations
478 such as 'New/Open/Save/SaveAs/Close' and 'Help'.
480 void QAD_Desktop::createActions()
483 /* Used for string compare */
484 const QString& aTrueQString = "true" ;
486 /* create 'standard' toolbar */
487 if ( !myStdToolBar ) {
488 myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this );
489 myStdToolBar->setCloseMode( QDockWindow::Undocked );
492 if ( !myMainMenu->count() ) {
493 /* Create main menu bar */
494 myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */
495 myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */
496 myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */
497 myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */
498 myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */
499 myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */
501 /* Applications will insert their items after 'File' 'Edit' and 'View'
502 ( 'Edit' will be inserted later )
507 /* insert logo picture to menu bar */
508 QHBox* aLogoFrm = new QHBox(this);
509 aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
510 QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
511 tr("ICON_DESK_LOGO") ));
512 QLabel* aLogoLab = new QLabel(aLogoFrm);
513 aLogoLab->setPixmap(aLogoPixmap);
514 aLogoLab->setAlignment(AlignCenter);
515 aLogoLab->setScaledContents(false);
516 myMainMenu->insertItem(aLogoFrm);
518 if ( myStdActions.isEmpty() ) {
519 /* Define standard actions. They should be inserted
520 into the list in order of their IDs.
525 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
526 QActionP* fileNewAction = new QActionP ( tr("TOT_DESK_FILE_NEW"),
527 rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) ,
528 tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this );
529 fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") );
530 fileNewAction->setEnabled ( true );
531 QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() )));
532 fileNewAction->addTo( myStdToolBar );
533 fileNewAction->addTo( &myFilePopup );
534 myStdActions.insert ( FileNewId, fileNewAction );
537 QActionP* fileOpenAction = new QActionP( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ),
538 tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this );
539 fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") );
540 fileOpenAction->setEnabled ( true );
541 QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() )));
542 fileOpenAction->addTo( myStdToolBar );
543 fileOpenAction->addTo( &myFilePopup );
544 myStdActions.insert ( FileOpenId, fileOpenAction );
547 QActionP* fileLoadAction = new QActionP( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ),
548 tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this );
549 fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") );
550 fileLoadAction->setEnabled ( true );
551 QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() )));
552 fileLoadAction->addTo( &myFilePopup );
553 myStdActions.insert ( FileLoadId, fileLoadAction );
556 QActionP* fileCloseAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ),
557 tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this );
558 fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") );
559 QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() )));
560 fileCloseAction->addTo( &myFilePopup );
561 myStdActions.insert ( FileCloseId, fileCloseAction );
564 myFilePopup.insertSeparator();
567 QActionP* fileSaveAction = new QActionP( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ),
568 tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this );
569 fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") );
570 QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() )));
571 fileSaveAction->addTo( myStdToolBar );
572 fileSaveAction->addTo( &myFilePopup );
573 myStdActions.insert ( FileSaveId, fileSaveAction );
576 QActionP* fileSaveAsAction = new QActionP( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this );
577 fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") );
578 QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ),
579 this, SLOT( onSaveAsStudy() )));
580 fileSaveAsAction->addTo( &myFilePopup );
581 myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
585 myFilePopup.insertSeparator();
588 QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
589 filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
590 filePropsAction->setEnabled(false);
591 QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() )));
592 filePropsAction->addTo( &myFilePopup );
593 myStdActions.insert ( FilePropsId, filePropsAction );
596 int id = myFilePopup.insertSeparator();
597 /* keep the position from which an application will insert its items
598 to menu 'File' at the time of customization of the desktop */
600 myFilePos = myFilePopup.indexOf( id ) + 1;
602 /* exit application */
603 QActionP* exitAction = new QActionP( "", tr("MEN_DESK_FILE_EXIT"),
605 exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") );
606 QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ),
607 this, SLOT( onExit() )));
608 exitAction->addTo( &myFilePopup );
609 myStdActions.insert ( FileExitId, exitAction );
611 QAD_ASSERT( connect( &myFilePopup, SIGNAL(highlighted( int )),
612 this, SLOT(onFilePopupStatusText( int )) ));
615 /* 'Edit' actions : provided by application only */
618 QAD_ASSERT( connect( &myEditPopup, SIGNAL(highlighted( int )),
619 this, SLOT(onEditPopupStatusText( int )) ));
622 /* toolbars popup menu */
623 myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
624 QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()),
625 this, SLOT(onToolBarPopupAboutToShow()) ));
628 QActionP* viewStatusBarAction = new QActionP( "",
629 tr("MEN_DESK_VIEW_STATUSBAR"),
631 viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") );
632 viewStatusBarAction->setOn( true );
633 QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() )));
634 viewStatusBarAction->addTo( &myViewPopup );
635 myStdActions.insert( ViewStatusBarId, viewStatusBarAction );
637 // myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup );
639 QActionP* SelectionPointAction = new QActionP( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true );
640 QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
641 SelectionPointAction->addTo( &mySelectionModePopup );
642 myStdActions.insert( SelectionPointId, SelectionPointAction );
644 QActionP* SelectionEdgeAction = new QActionP( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true );
645 QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
646 SelectionEdgeAction->addTo( &mySelectionModePopup );
647 myStdActions.insert( SelectionEdgeId, SelectionEdgeAction );
649 QActionP* SelectionCellAction = new QActionP( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true );
650 QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
651 SelectionCellAction->addTo( &mySelectionModePopup );
652 myStdActions.insert( SelectionCellId, SelectionCellAction );
654 QActionP* SelectionActorAction = new QActionP( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true );
655 QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
656 SelectionActorAction->addTo( &mySelectionModePopup );
657 myStdActions.insert( SelectionActorId, SelectionActorAction );
658 SelectionActorAction->setOn(true);
660 myViewPos = myViewPopup.count();
662 QAD_ASSERT( connect( &myViewPopup, SIGNAL(highlighted( int )),
663 this, SLOT(onViewPopupStatusText( int )) ));
666 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
669 if(!resMgr->loadResources( "ToolsGUI", msg ))
671 //NRI QCString errMsg;
672 // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" );
673 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
677 myOperatorMenus = new QAD_OperatorMenus(this);
678 myXmlHandler = new QAD_XmlHandler();
679 ASSERT(myXmlHandler) ;
680 myXmlHandler->setMainWindow(this);
681 if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) {
682 QString language = resMgr->language( "ToolsGUI" );
683 QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" );
685 //ToolsXml = resMgr->resources("ToolsGUI") ;
686 //ToolsXml = QAD_Tools::addSlash(ToolsXml) ;
687 //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ;
688 ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml;
690 QFile file( QAD_Tools::unix2win( ToolsXml ) );
691 if ( file.exists() && file.open( IO_ReadOnly ) ) {
693 QXmlInputSource source( file );
694 QXmlSimpleReader reader;
695 reader.setContentHandler( myXmlHandler );
696 reader.setErrorHandler( myXmlHandler );
697 bool ok = reader.parse( source );
700 QMessageBox::critical( 0,
701 tr( "INF_PARSE_ERROR" ),
702 tr( myXmlHandler->errorProtocol() ) );
704 myMenusList=myXmlHandler->myMenusList;
705 myActiveMenus=myMenusList.at(0);
706 myOperatorMenus->showMenuBar(0);
707 myActiveMenus->showAllToolBars();
713 if ( myToolsPopup.count() == 0 ) {
714 myMainMenu->removeItem(5);
718 /* Viewer BackgroundColor */
719 myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup );
721 QActionP* viewerOCCAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
722 QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() )));
723 viewerOCCAction->addTo( &myViewerPopup );
724 myStdActions.insert( PrefViewerOCCId, viewerOCCAction );
726 QActionP* viewerVTKAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
727 QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() )));
728 viewerVTKAction->addTo( &myViewerPopup );
729 myStdActions.insert( PrefViewerVTKId, viewerVTKAction );
731 QActionP* graphSupervisorAction = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
732 QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() )));
733 graphSupervisorAction->addTo( &myViewerPopup );
734 myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction );
736 QActionP* viewerPlot2dAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
737 QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() )));
738 viewerPlot2dAction->addTo( &myViewerPopup );
739 myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction );
741 //VRV: T2.5 - add default viewer
742 QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" );
744 int aViewerValue = viewerValue.toInt( &ok, 10 );
745 if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX)
746 aViewerValue = VIEW_VTK;
748 myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer );
749 QActionPGroup* myQAG = new QActionPGroup ( this);
750 QActionP* viewerOCCAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
751 viewerOCCAction1->setToggleAction ( true);
752 viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC );
753 myQAG->insert( viewerOCCAction1 );
754 myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 );
756 QActionP* viewerVTKAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
757 viewerVTKAction1->setToggleAction ( true);
758 viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK );
759 myQAG->insert( viewerVTKAction1 );
760 myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 );
762 /* Remove Supervisor viewer from setting the background */
763 // QActionP* graphSupervisorAction1 = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
764 // graphSupervisorAction1->setToggleAction ( true);
765 // graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV );
766 // myQAG->insert( graphSupervisorAction1 );
767 // myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 );
769 QActionP* viewerPlot2dAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
770 viewerPlot2dAction1->setToggleAction ( true);
771 viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D );
772 myQAG->insert( viewerPlot2dAction1 );
773 myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 );
775 myQAG->addTo( &myDefaultViewer );
776 QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) )));
777 //VRV: T2.5 - add default viewer
779 myPrefPopup.insertSeparator();
781 QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this );
782 QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() )));
783 viewerTrihedronAction->addTo( &myPrefPopup );
784 myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction );
786 QActionP* consoleFontAction = new QActionP( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this );
787 QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() )));
788 consoleFontAction->addTo( &myPrefPopup );
789 myStdActions.insert( PrefConsoleFontId, consoleFontAction );
792 QActionP* multiFileSaveAction = new QActionP( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true );
793 QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() )));
794 multiFileSaveAction->setToggleAction( true );
795 QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave");
796 multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 );
797 multiFileSaveAction->addTo( &myPrefPopup );
798 myStdActions.insert( PrefMultiFileSave, multiFileSaveAction );
801 QActionP* ASCIISaveAction = new QActionP( "", tr("MEN_DESK_PREF_ASCII_SAVE"), 0, this, 0, true );
802 QAD_ASSERT(connect( ASCIISaveAction, SIGNAL(activated()), this, SLOT(onASCIISave() )));
803 ASCIISaveAction->setToggleAction( true );
804 QString ASCIISave = QAD_CONFIG->getSetting("Desktop:ASCIISave");
805 ASCIISaveAction->setOn( ASCIISave.compare( aTrueQString ) == 0 );
806 ASCIISaveAction->addTo( &myPrefPopup );
807 myStdActions.insert( PrefASCIISave, ASCIISaveAction );
810 QActionP* UndoLevelAction = new QActionP( "", tr("MEN_DESK_PREF_UNDO_LEVEL"), 0, this );
811 QAD_ASSERT(connect( UndoLevelAction, SIGNAL(activated()), this, SLOT(onUndoLevel() )));
812 UndoLevelAction->addTo( &myPrefPopup );
813 myStdActions.insert( PrefUndoLevelId, UndoLevelAction );
815 myPrefPopup.insertSeparator();
817 /* External Browser */
818 QActionP* externalBrowserAction = new QActionP( "", tr("MEN_DESK_PREF_EXTERNAL_BROWSER"), 0, this );
819 QAD_ASSERT(connect( externalBrowserAction, SIGNAL(activated()), this, SLOT(onExternalBrowser() )));
820 externalBrowserAction->addTo( &myPrefPopup );
821 myStdActions.insert( PrefExternalBrowserId, externalBrowserAction );
823 myPrefPopup.insertSeparator();
825 myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
827 QActionP* objectBrowserEntryAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true );
828 QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
829 objectBrowserEntryAction->setToggleAction(true);
830 QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn");
832 if ( AddColumn.compare( aTrueQString ) == 0 )
833 objectBrowserEntryAction->setOn(true);
835 objectBrowserEntryAction->setOn(false);
837 objectBrowserEntryAction->addTo( &myObjBrowserPopup );
838 myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction );
840 QActionP* objectBrowserValueAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true );
841 QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
842 objectBrowserValueAction->setToggleAction(true);
843 QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn");
845 if ( ValueColumn.compare( aTrueQString ) == 0 )
846 objectBrowserValueAction->setOn(true);
848 objectBrowserValueAction->setOn(false);
850 objectBrowserValueAction->addTo( &myObjBrowserPopup );
851 myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction );
853 QActionP* objectBrowserIAPPAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true );
854 QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
855 objectBrowserIAPPAction->setToggleAction(true);
856 QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP");
858 if ( showIAPP.compare( aTrueQString ) == 0 )
859 objectBrowserIAPPAction->setOn(true);
861 objectBrowserIAPPAction->setOn(false);
863 objectBrowserIAPPAction->addTo( &myObjBrowserPopup );
864 myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction );
866 /* Chronological sorting of shapes on the entry creation */
867 QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true );
868 QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
869 objectBrowserCHRONO_SORTAction->setToggleAction(true);
870 QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:ChronologicalSort");
872 if ( showSORT.compare( aTrueQString ) == 0 )
873 objectBrowserCHRONO_SORTAction->setOn(true) ;
875 objectBrowserCHRONO_SORTAction->setOn(false) ;
877 objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup );
878 myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ;
880 /* Show or don't Show UseCase browser */
881 QActionP* objectBrowserShowUseCaseAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_SHOW_USECASE"), 0, this, 0, true );
882 QAD_ASSERT(connect( objectBrowserShowUseCaseAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
883 objectBrowserShowUseCaseAction->setToggleAction(true);
884 QString showUseCase = QAD_CONFIG->getSetting("ObjectBrowser:ShowUseCaseBrowser");
886 if ( showUseCase.compare( aTrueQString ) == 0 )
887 objectBrowserShowUseCaseAction->setOn(true) ;
889 objectBrowserShowUseCaseAction->setOn(false) ;
891 objectBrowserShowUseCaseAction->addTo( &myObjBrowserPopup );
892 myStdActions.insert( PrefObjectBrowserShowUseCaseId, objectBrowserShowUseCaseAction ) ;
894 /* Resize or don't resize columns automatically */
895 QActionP* objectBrowserNoAutoSizeAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_NO_AUTOSIZE"), 0, this, 0, true );
896 QAD_ASSERT(connect( objectBrowserNoAutoSizeAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
897 objectBrowserNoAutoSizeAction->setToggleAction(true);
898 QString noAutoSize = QAD_CONFIG->getSetting("ObjectBrowser:NoAutoSizeColumns");
900 if ( noAutoSize.compare( aTrueQString ) == 0 )
901 objectBrowserNoAutoSizeAction->setOn(true) ;
903 objectBrowserNoAutoSizeAction->setOn(false) ;
905 objectBrowserNoAutoSizeAction->addTo( &myObjBrowserPopup );
906 myStdActions.insert( PrefObjectBrowserNoAutoSizeColumnsId, objectBrowserNoAutoSizeAction ) ;
908 myPrefPopup.insertSeparator();
910 QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this );
911 QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() )));
912 dirAction->addTo( &myPrefPopup );
913 myStdActions.insert( PrefDirsId, dirAction );
915 myPrefPopup.insertSeparator();
917 QActionP* saveAction = new QActionP( "", tr("MEN_DESK_PREF_SAVE"), 0, this );
918 QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() )));
919 saveAction->addTo( &myPrefPopup );
920 myStdActions.insert( PrefSaveId, saveAction );
922 /* 'Window' actions */
925 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
927 QActionP* viewOCCAction = new QActionP( "", tr("MEN_DESK_VIEW_OCC"), ALT+Key_O, this );
928 QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
929 viewOCCAction->addTo( &myNewViewPopup );
930 myStdActions.insert( ViewOCCId, viewOCCAction );
932 QActionP* viewVTKAction = new QActionP( "", tr("MEN_DESK_VIEW_VTK"), ALT+Key_K, this );
933 QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
934 viewVTKAction->addTo( &myNewViewPopup );
935 myStdActions.insert( ViewVTKId, viewVTKAction );
937 QActionP* viewPlot2dAction = new QActionP( "", tr("MEN_DESK_VIEW_PLOT2D"), ALT+Key_P, this );
938 QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
939 viewPlot2dAction->addTo( &myNewViewPopup );
940 myStdActions.insert( ViewPlot2dId, viewPlot2dAction );
942 // QActionP* windowNew3dAction = new QActionP( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */
943 /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this );
944 windowNew3dAction->addTo( &myWindowPopup );
945 QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this ,
946 SLOT( onNewWindow3d() )));
947 myStdActions.insert( WindowNew3dId, windowNew3dAction );
953 QActionP* windowCascadeAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ),
954 tr("MEN_DESK_WINDOW_CASCADE"), 0, this );
955 windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") );
956 QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this,
957 SLOT( onCascade() )));
958 myStdActions.insert( WindowCascadeId, windowCascadeAction );
961 QActionP* windowTileAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ),
962 tr("MEN_DESK_WINDOW_TILE"), 0, this );
963 windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") );
964 QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() )));
965 myStdActions.insert( WindowTileId, windowTileAction );
967 QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()),
968 this, SLOT(onWindowPopupAboutToShow()) ));
973 // QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
974 // helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
975 // QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
976 // this, SLOT( onHelpContents() )));
977 // helpContentsAction->addTo( &myHelpPopup );
978 // myStdActions.insert( HelpContentsId , helpContentsAction );
980 // id = myHelpPopup.insertSeparator();
983 myHelpPopup.insertItem( tr("MEN_DESK_HELP_MODULECONTENTS"), &myHelpContentsModulePopup, HelpContentsModuleId);
984 bool toEnable = false;
986 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
987 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
989 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
990 myCatalogue->GetComponentIconeList();
992 for (unsigned int ind = 0; ind < list_composants->length(); ind++) {
993 QString aModuleName = strdup(list_composants[ind].modulename) ;
995 if (dir = getenv( aModuleName + "_ROOT_DIR")) {
996 dir = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc/salome/" );
997 QString aFileName = aModuleName + "_index.html";
998 if ( QFileInfo( dir + aFileName ).exists() ) {
999 QString aModuleUserName = strdup(list_composants[ind].moduleusername) ;
1000 if ( aModuleUserName == "Salome" ) aModuleUserName = "Kernel" ;
1001 QActionP* moduleHelpAction = new QActionP( "", aModuleUserName + " Help" , 0, this, aModuleName);
1002 QAD_ASSERT(connect( moduleHelpAction, SIGNAL(activated()), this, SLOT(onHelpContentsModule() )));
1003 moduleHelpAction->addTo( &myHelpContentsModulePopup );
1004 if (!toEnable) toEnable = true;
1009 myHelpContentsModulePopup.setEnabled(toEnable);
1011 // NRI : Temporary commented
1013 // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
1014 // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
1015 // QAD_ASSERT(connect( helpContentsActionGUI, SIGNAL(activated()),
1016 // this, SLOT( onHelpContentsGUI() )));
1017 // helpContentsActionGUI->addTo( &myHelpPopup );
1018 // myStdActions.insert( HelpContentsId , helpContentsActionGUI );
1023 QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
1024 helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
1025 QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
1026 this, SLOT( onHelpContentsTUI() )));
1027 helpContentsActionTUI->addTo( &myHelpPopup );
1028 myStdActions.insert( HelpContentsId , helpContentsActionTUI );
1032 // Provide status tip for Module help menu item
1033 QAD_ASSERT( connect( &myHelpPopup, SIGNAL(highlighted( int )), this,
1034 SLOT(onHelpModulePopupStatusText( int )) ));
1038 // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
1039 // helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") );
1040 // QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() )));
1041 // helpSearchAction->addTo( &myHelpPopup );
1042 // myStdActions.insert( HelpSearchId, helpSearchAction );
1045 // QActionP* helpWhatsThisAction = new QActionP( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this );
1046 // helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" ));
1047 // QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() )));
1048 // helpWhatsThisAction->addTo( &myHelpPopup );
1049 // myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction );
1050 // (void)QWhatsThis::whatsThisButton( myStdToolBar );
1052 id = myHelpPopup.insertSeparator();
1053 myHelpPos = myHelpPopup.indexOf( id );
1056 QActionP* helpAboutAction = new QActionP( "", tr("MEN_DESK_HELP_ABOUT"), 0, this );
1057 helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") );
1058 QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
1059 helpAboutAction->addTo( &myHelpPopup );
1060 myStdActions.insert(HelpAboutId, helpAboutAction );
1066 Adds the given application into the list of supported applications
1068 void QAD_Desktop::addApplication(QAD_Application* app)
1070 /* add only if is not already in the list */
1071 if ( myApps.findRef( app ) == -1 )
1073 myApps.append( app );
1075 /* set activation/deactivation listener */
1076 QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)),
1077 this, SLOT(onActivateApp(QAD_Application*))) );
1079 QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)),
1080 this, SLOT(onDeactivateApp(QAD_Application*))) );
1085 Displays the control panel of the application.
1086 This function is called when the desktop is shown first time.
1088 void QAD_Desktop::showDesktop()
1094 Closes Desktop. If <forceClose> is true query for exit will be skipped.
1096 void QAD_Desktop::closeDesktop( bool forceClose )
1099 myQueryClose = false;
1104 Puts the message to the status bar
1106 void QAD_Desktop::putInfo ( const QString& msg )
1109 //NRI : bug 1209. message is now displayed during 3000 ms
1110 myStatusBar->message ( msg, 3000 );
1114 Puts the message to the status bar for ms milli-seconds
1116 void QAD_Desktop::putInfo ( const QString& msg, int ms )
1119 myStatusBar->message ( msg, ms );
1123 Returns the standard toolbar
1125 QMenuBar* QAD_Desktop::getMainMenuBar() const
1131 Returns the standard toolbar
1133 QToolBar* QAD_Desktop::getStdToolBar() const
1135 return myStdToolBar;
1139 Updates desktop panel (menu, toolbar and status bar) according to current state of
1140 the application. Calls update() for the active application.
1141 The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components
1142 will be changed according to new active application.
1143 This function is called after activating new study, closing current study etc.
1145 void QAD_Desktop::updateDesktop( UpdateCommand cmd )
1148 updateToolBars( cmd );
1149 updateStatusBar( cmd );
1154 Updates the desktop caption
1156 void QAD_Desktop::updateCaption( UpdateCommand cmd )
1158 if ( cmd == ActivateApp )
1159 { /* application's icon and title */
1160 setIcon( myActiveApp->getApplicationIcon() );
1161 setCaption( myActiveApp->getApplicationName() );
1164 { /* default icon and title */
1165 setIcon( myDefaultIcon );
1166 qApp->processEvents();
1167 setCaption( myDefaultTitle );
1172 Updates status bar when a new application becomes current
1174 void QAD_Desktop::updateStatusBar( UpdateCommand cmd )
1178 bool activate = ( cmd == ActivateApp );
1179 myActiveApp->updateStatusBar ( myStatusBar, activate );
1184 Updates toolbars according to current active application.
1185 This function is called from updateDesktop().
1187 void QAD_Desktop::updateToolBars( UpdateCommand cmd )
1191 bool activate = ( cmd == ActivateApp );
1192 myActiveApp->updateToolBars ( activate );
1197 Updates main menu bar of the application when application is activated
1199 This function is called by updateDesktop()
1201 void QAD_Desktop::updateMenu( UpdateCommand cmd )
1205 bool activate = ( cmd == ActivateApp );
1206 myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos );
1207 myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos );
1208 myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos );
1209 myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos );
1210 myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos );
1213 Since 'Edit' popup is completely customized by applications
1214 desktop doesn't show it in main menubar without the active
1215 application and we insert/remove this popup from the menubar
1216 when activating/deactivating applications.
1218 We can't have 'Edit' popup be customized by an application
1219 via UpdateMainMenu() method because applications may insert
1220 its items to the menubar only AFTER 'View' item ( this fact
1221 is respected by myMainMenuPos ) and the possibility of an
1222 application to add its items into any arbitrary positions of
1223 the main menubar requires a bit sophisticated implementation,
1224 so we decided to avoid it, sorry :-(.
1226 #if defined( DEBUG )
1228 /* applications MUST clear 'Edit' after themselves */
1229 QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() );
1232 if ( activate ) /* insert after 'File' item */
1233 myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 );
1235 myMainMenu->removeItem( 3 );
1240 Returns icon file name used by the application
1242 const QPixmap& QAD_Desktop::getDefaultIcon() const
1244 static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD",
1245 tr("ICON_DESK_DEFAULTICON") ));
1246 return defaultPixmap;
1250 Returns name of the application used as the title of desktop panel
1252 const QString& QAD_Desktop::getDefaultTitle() const
1254 static QString defaultTitle ( tr("DESK_DEFAULTTITLE") );
1255 return defaultTitle;
1259 Returns default name of new studies
1261 const QString& QAD_Desktop::getDefaultStudyName() const
1263 static QString defaultStudyName( tr("DESK_DEFAULTDOC") );
1264 return defaultStudyName;
1268 Returns next name for new study
1270 QString QAD_Desktop::getNewStudyName()
1273 number.sprintf( "%d", ++myCntUntitled );
1274 return ( getDefaultStudyName() + number );
1278 Searches QAD_Study corresponding to <study>, returns NULL if fails
1280 QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy )
1282 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1283 QList<QAD_Study> studies;
1284 studies.setAutoDelete( false );
1285 studies = app->getStudies();
1286 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
1287 if ( study->getStudyDocument()->_is_equivalent( theStudy ) )
1295 Gets value of max undo level for SALOMEDS::Study's from preferences
1297 int QAD_Desktop::getUndoLevel()
1299 static int MAX_UNDO = 10;
1300 int anUndoLevel = MAX_UNDO;
1301 QString aLevel = QAD_CONFIG->getSetting("Desktop:UndoLevel");
1302 if(!aLevel.isEmpty()) anUndoLevel = aLevel.toInt();
1307 Returns current active application
1309 QAD_Application* QAD_Desktop::getActiveApp() const
1315 Returns current active study
1317 QAD_Study* QAD_Desktop::getActiveStudy() const
1319 return myActiveStudy;
1325 QWorkspaceP* QAD_Desktop::getMainFrame() const
1331 Find or load Engine, given a container name and an engine name
1333 Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
1334 const char *componentName)
1336 Engines::Component_var eng =
1337 myEnginesLifeCycle->FindOrLoad_Component(containerName,
1342 QString QAD_Desktop::getComponentName(const char *componentUserName)
1344 if ( mapComponentName.contains(componentUserName) )
1345 return mapComponentName[ componentUserName ] ;
1350 QString QAD_Desktop::getComponentUserName(const char *componentName)
1352 QMap<QString,QString>::Iterator it;
1353 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
1354 if (it.data() == componentName )
1360 // gets application Help Window (and creates if necessary)
1362 // QAD_HelpWindow* QAD_Desktop::getHelpWindow()
1364 // if (!myHelpWindow) {
1365 // myHelpWindow = new QAD_HelpWindow();
1367 // QMap<QString,QString>::Iterator it;
1368 // for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
1372 // // look for index.html and set homeDir
1373 // // 1. $(MODULE_ROOT_DIR)/doc/index.html
1374 // // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
1375 // // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
1377 // if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
1378 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
1379 // if ( QFileInfo( root + "index.html" ).exists() ) {
1380 // helpContext( root + "index.html", "" );
1383 // root = QAD_Tools::addSlash( root + "html" );
1384 // if ( QFileInfo( root + "index.html" ).exists() ) {
1385 // helpContext( root + "index.html", "" );
1388 // root = QAD_Tools::addSlash( root + "html" );
1389 // if ( QFileInfo( root + "index.html" ).exists() ) {
1390 // helpContext( root + "index.html", "" );
1397 // connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
1399 // return myHelpWindow;
1403 Called when desktop is closing
1405 void QAD_Desktop::closeEvent ( QCloseEvent* e )
1407 bool doClose = true;
1408 if ( myQueryClose ) {
1409 doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"),
1410 tr("QUE_DESK_EXIT"), tr ("BUT_OK"),
1411 tr ("BUT_CANCEL"), QAD_YES,
1412 QAD_NO, QAD_NO ) == QAD_YES;
1416 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1417 QList<QAD_Study>& studies = app->getStudies();
1418 for(QAD_Study* study = studies.first(); study != 0; study = studies.next()) {
1419 if(myQueryClose && study->getStudyDocument()->IsModified()) {
1420 SALOMEGUI_CloseDlg aDlg( this );
1421 switch ( aDlg.exec() ) {
1423 if ( !onSaveStudy( study ) ) {
1424 putInfo( tr("INF_CANCELLED") );
1435 putInfo( tr("INF_CANCELLED") );
1443 myQueryClose = true;
1444 doClose ? e->accept() : e->ignore();
1448 Called when desktop is resized
1450 void QAD_Desktop::resizeEvent( QResizeEvent* e )
1452 QMainWindow::resizeEvent( e );
1453 myWorkspace->setGeometry( 1,1, centralWidget()->width()-2,
1454 centralWidget()->height()-2 );
1459 Terminates the application.
1461 void QAD_Desktop::onExit()
1466 /************************************************************************
1468 *************************************************************************/
1472 If several application are supported it displays dialog window
1473 to choose type of study.
1475 void QAD_Desktop::createStudy(){
1478 void QAD_Desktop::onNewStudy()
1480 unsigned numApps = myApps.count();
1483 onNewStudy ( myApps.at(0) );
1484 else { /* select the type of application for new study */
1485 Desktop_AppSelectionDlg selDlg( this, myApps );
1486 if ( selDlg.exec() == QDialog::Accepted ) {
1487 onNewStudy ( selDlg.selectedApp() );
1490 } else { /* no applications available in desktop */
1491 QAD_MessageBox::error1( this,
1493 tr("ERR_APP_NOAPP"),
1499 Creates new study for the given application.
1500 Calls the respective function of the application class.
1502 void QAD_Desktop::onNewStudy( QAD_Application* app )
1506 /* create new study of the specific app */
1507 putInfo ( tr ("INF_DOC_CREATING") );
1508 QAD_Study* newStudy = app->newStudy();
1511 /* can't create new study */
1512 QAD_MessageBox::error1( this, tr("ERR_ERROR"),
1513 tr("ERR_DOC_CANTCREATE"),
1516 putInfo ( tr("INF_READY") );
1520 Loads the existing study.
1522 void QAD_Desktop::onLoadStudy()
1524 QString name, studyname, ext;
1526 SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE);
1528 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1529 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1530 ASSERT(! CORBA::is_nil(myStudyMgr));
1531 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1532 for (unsigned int ind = 0; ind < List->length();ind++) {
1533 studyname = List[ind];
1534 aDlg->ListComponent->insertItem( studyname );
1537 int retVal = aDlg->exec();
1538 studyname = aDlg->ListComponent->currentText();
1540 if (retVal == QDialog::Rejected)
1543 if ( studyname.isNull() || studyname.isEmpty() )
1547 name.replace( QRegExp(":"), "/" );
1550 Try to associate an application to the opened study.
1551 Assumed that the association study<->application is unique.
1553 bool appFound = false;
1554 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1555 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1557 /* application found */
1558 if ( app->isStudyOpened( name ) )
1560 /* already opened: prompt for reopen */
1561 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1562 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1563 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1564 QAD_NO ) == QAD_NO )
1566 putInfo ( tr("INF_READY") );
1569 /* now the study is closed to be re-opened */
1570 //don't ask user to remove study permanently
1571 if (app->getStudyByName ( name ) != NULL)
1572 onCloseStudy ( app->getStudyByName ( name ), false );
1573 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1574 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1578 /* open the study */
1579 QAD_Study* openStudy = app->loadStudy( studyname );
1581 QAD_MessageBox::error1( this,
1583 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1590 QAD_MessageBox::error1( this,
1592 tr("ERR_DOC_UNKNOWNTYPE"),
1595 putInfo ( tr("INF_READY") );
1600 QAD_Study* QAD_Desktop::loadStudy(QString theStudyName) {
1601 QString studyname("");
1603 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1604 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1605 ASSERT(! CORBA::is_nil(myStudyMgr));
1607 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1608 for (unsigned int ind = 0; ind < List->length();ind++) {
1609 if (theStudyName == QString(List[ind])) {
1610 studyname = theStudyName;
1614 if (studyname == "") {
1617 bool appFound = false;
1618 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1620 QAD_Study* openStudy = app->loadStudy( studyname );
1622 // if (myActiveApp == 0)
1623 //myActiveApp = app;
1633 Opens the existing study.
1634 Displays select file dialog and calls corresponding function of
1636 (application is defined according to extension of selected file).
1638 void QAD_Desktop::onOpenStudy()
1642 /* Select a file to open */
1643 name = selectFileName ( true );
1644 if ( name.isNull() || name.isEmpty() )
1647 // Workaround for non-existent files
1649 if (!fi.exists() || !fi.isFile()) {
1650 QAD_MessageBox::error1 ( this, tr("ERR_ERROR"),
1651 tr("ERR_DOC_CANTOPEN") +": " + name,
1656 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1657 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1658 ASSERT(! CORBA::is_nil(myStudyMgr));
1659 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1660 for (unsigned int ind = 0; ind < List->length();ind++) {
1661 QString NameExistingStudy(List[ind]);
1662 QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, true );
1663 if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) {
1664 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1665 tr("QUE_DOC_ALREADYEXIST").arg( name ),
1666 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1667 QAD_NO ) == QAD_NO )
1669 putInfo ( tr("INF_READY") );
1681 Try to associate an application to the opened study.
1682 Assumed that the association study<->application is unique.
1684 bool appFound = false;
1685 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1686 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1688 QString ext = QAD_Tools::getFileExtensionFromPath ( name );
1689 if ( app->getStudyExtension() == ext )
1691 /* application found */
1692 if ( app->isStudyOpened( name ) )
1694 /* already opened: prompt for reopen */
1695 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1696 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1697 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1698 QAD_NO ) == QAD_NO )
1700 putInfo ( tr("INF_READY") );
1703 /* now the study is closed to be re-opened */
1704 //don't ask user to remove study permanently
1705 if (app->getStudyByName ( name ) != NULL)
1706 onCloseStudy ( app->getStudyByName ( name ), false );
1707 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1708 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1712 /* open the study */
1713 QAD_Study* openStudy = app->openStudy( name );
1715 QAD_MessageBox::error1( this,
1717 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1719 } else if (myActiveComp != "") {
1720 QApplication::setOverrideCursor( Qt::waitCursor );
1721 loadComponentData(mapComponentName[myActiveComp]);
1722 openStudy->updateObjBrowser(true);
1723 QApplication::restoreOverrideCursor();
1731 QAD_MessageBox::error1( this,
1733 tr("ERR_DOC_UNKNOWNTYPE"),
1736 putInfo ( tr("INF_READY") );
1739 bool QAD_Desktop::loadComponentData( const QString& compName )
1741 // Open component's data in active study if any
1742 MESSAGE("loadComponentData(): Opening " << compName << " component data ")
1743 if (!myActiveStudy) {
1744 MESSAGE("loadComponentData(): No active study exists")
1748 Engines::Component_var comp ;
1749 if ( compName.compare("SUPERV") == 0 ) {
1750 comp = getEngine( "SuperVisionContainer", compName) ;
1753 /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) :
1754 getEngine( "FactoryServerPy", compName);
1756 comp = getEngine( "FactoryServer", compName);
1757 if ( comp->_is_nil() )
1758 comp = getEngine( "FactoryServerPy", compName);
1761 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1762 SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
1764 if (!SCO->_is_nil()) {
1765 if (!CORBA::is_nil(comp)) {
1766 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
1767 if (!CORBA::is_nil(driver)) {
1768 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
1769 if (!CORBA::is_nil(B)) {
1770 // QAD_Operation* op = new QAD_Operation( myActiveStudy );
1772 B->LoadWith(SCO,driver);
1778 MESSAGE("loadComponentData(): Driver is null");
1782 MESSAGE("loadComponentData(): Engine is null");
1786 MESSAGE("loadComponentData(): SComponent is null");
1794 Saves the active study
1796 bool QAD_Desktop::onSaveStudy()
1798 return onSaveStudy ( myActiveStudy );
1802 Saves the given study
1804 bool QAD_Desktop::onSaveStudy( QAD_Study* study )
1806 if ( !study ) return true;
1808 if ( !study->isSaved() )
1809 return onSaveAsStudy ( study );
1811 /* saving study... */
1812 QAD_Application* app = study->getApp();
1813 QAD_ASSERT_DEBUG_ONLY ( app );
1814 putInfo ( tr("INF_DOC_SAVING") + study->getTitle() );
1815 if ( !app->saveStudy( study ) )
1817 putInfo( tr("INF_CANCELLED") );
1822 putInfo ( tr("INF_DOC_SAVED").arg( "" ) );
1827 Saves the active study under a new name
1829 bool QAD_Desktop::onSaveAsStudy()
1831 return onSaveAsStudy( myActiveStudy );
1835 Saves the given study under a new name
1837 bool QAD_Desktop::onSaveAsStudy( QAD_Study* study )
1839 if ( !study ) return true;
1841 /* Save study in a format supported by its application
1843 QAD_Application* app = study->getApp();
1844 QAD_ASSERT_DEBUG_ONLY ( app );
1846 /* Select a file where to save
1848 QString name = selectFileName ( false );
1849 if ( name.isNull() || name.isEmpty() )
1851 putInfo( tr("INF_CANCELLED") );
1857 putInfo ( tr("INF_DOC_SAVING") + name );
1858 if ( !app->saveAsStudy( study, name ) ) {
1859 /* can't save the file */
1860 QAD_MessageBox::error1( this,
1862 tr("ERR_DOC_CANTWRITE") + "\n" + name,
1865 return false; /* cannot save */
1867 putInfo ( tr("INF_DOC_SAVED").arg( name ) );
1868 return true; /* saved ok */
1872 Closes the active study
1874 bool QAD_Desktop::onCloseStudy()
1876 bool close = this->onCloseStudy ( getActiveStudy(), true );
1881 Closes the given study and ask user to remove study
1882 from the study manager permanently
1884 bool QAD_Desktop::onCloseStudy( QAD_Study* study )
1886 return onCloseStudy( study, true );
1890 Closes the given study and ask user to remove study
1891 from the study manager permanently if ask is equal true
1893 bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask )
1895 bool removePerm = false;
1899 SALOMEGUI_CloseDlg aDlg( this );
1900 int res = aDlg.exec();
1905 //if ( study->isModified() )
1906 if ( !onSaveStudy( study ) ) {
1907 putInfo( tr("INF_CANCELLED") );
1920 putInfo( tr("INF_CANCELLED") );
1924 /* close active component */
1925 if (!myXmlHandler->myIdList.IsEmpty())
1927 deactivateComponent();
1930 myCombo->setCurrentItem (0);
1931 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() )
1932 aButton->setOn(false);
1933 qApp->processEvents();
1935 /* close the study */
1936 return study->getApp()->closeStudy( study, removePerm );
1939 // Displays study properties dialog box
1940 void QAD_Desktop::onStudyProperties()
1942 if (myActiveStudy) {
1944 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1947 SALOMEGUI_StudyPropertiesDlg aDlg(this);
1948 int res = aDlg.exec();
1950 if ( res == QDialog::Accepted && aDlg.isChanged() )
1955 // T2.12 - add the word "locked" to study frame captions if <myActiveStudy> study is locked
1956 myActiveStudy->updateCaptions();
1962 locate all windows in cascade mode
1965 void QAD_Desktop::onCascade()
1967 myWorkspace->cascade();
1968 int w = myWorkspace->width();
1969 int h = myWorkspace->height();
1970 QWidgetList wList = myWorkspace->windowList();
1971 QWidgetListIt it(wList);
1973 for(;it.current(); ++it)
1974 it.current()->resize((int)(0.8*w), (int)(0.8*h));
1978 // called when help window closed
1980 // void QAD_Desktop::onHelpWindowClosed()
1982 // myHelpWindow = 0;
1986 Called when 'view status bar' option
1989 void QAD_Desktop::onViewStatusBar()
1991 bool show = myStdActions.at( ViewStatusBarId )->isOn();
1992 if ( show == myStatusBar->isVisible() )
1995 myStatusBar->show();
1997 myStatusBar->hide();
2001 Called when View/Toolbars popup menu is about to show
2003 void QAD_Desktop::onToolBarPopupAboutToShow()
2005 myToolBarAction.clear();
2006 myToolBarsPopup.clear();
2007 QPtrList<QDockWindow> wlist = dockWindows();
2008 for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) {
2009 if ( w->inherits( "QToolBar" ) ) {
2010 QToolBar* tb = ( QToolBar* )w;
2011 if ( appropriate( tb ) ) {
2012 ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true );
2013 a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") );
2014 a->setOn( tb->isVisible() );
2015 QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) );
2016 QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) );
2017 a->addTo( &myToolBarsPopup );
2018 myToolBarAction.append( a );
2025 Called on 'View\Selection Mode'
2027 void QAD_Desktop::onSelectionMode()
2029 const QActionP* obj = (QActionP*) sender();
2031 Selection_Mode SelectionMode = ActorSelection;
2033 if ( obj == myStdActions.at(SelectionActorId) ) {
2034 SelectionMode = ActorSelection;
2035 if ( obj->isOn() ) {
2036 myStdActions.at(SelectionCellId)->setOn(false);
2037 myStdActions.at(SelectionEdgeId)->setOn(false);
2038 myStdActions.at(SelectionPointId)->setOn(false);
2040 myStdActions.at(SelectionActorId)->setOn(true);
2042 } else if ( obj == myStdActions.at(SelectionCellId) ) {
2043 SelectionMode = CellSelection;
2044 if ( obj->isOn() ) {
2045 myStdActions.at(SelectionActorId)->setOn(false);
2046 myStdActions.at(SelectionEdgeId)->setOn(false);
2047 myStdActions.at(SelectionPointId)->setOn(false);
2049 myStdActions.at(SelectionActorId)->setOn(true);
2051 } else if ( obj == myStdActions.at(SelectionEdgeId) ) {
2052 SelectionMode = EdgeOfCellSelection;
2053 if ( obj->isOn() ) {
2054 myStdActions.at(SelectionActorId)->setOn(false);
2055 myStdActions.at(SelectionCellId)->setOn(false);
2056 myStdActions.at(SelectionPointId)->setOn(false);
2058 myStdActions.at(SelectionActorId)->setOn(true);
2060 } else if ( obj == myStdActions.at(SelectionPointId) ) {
2061 SelectionMode = NodeSelection;
2062 if ( obj->isOn() ) {
2063 myStdActions.at(SelectionEdgeId)->setOn(false);
2064 myStdActions.at(SelectionCellId)->setOn(false);
2065 myStdActions.at(SelectionActorId)->setOn(false);
2067 myStdActions.at(SelectionActorId)->setOn(true);
2070 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2071 sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode );
2073 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2074 Sel->SetSelectionMode( SelectionMode );
2078 Called on 'View\Selection Mode'
2080 void QAD_Desktop::SetSelectionMode(Selection_Mode mode, bool activeCompOnly)
2085 myStdActions.at(SelectionEdgeId)->setOn(false);
2086 myStdActions.at(SelectionCellId)->setOn(false);
2087 myStdActions.at(SelectionActorId)->setOn(false);
2088 myStdActions.at(SelectionPointId)->setOn(true);
2091 case EdgeOfCellSelection:
2093 myStdActions.at(SelectionActorId)->setOn(false);
2094 myStdActions.at(SelectionCellId)->setOn(false);
2095 myStdActions.at(SelectionPointId)->setOn(false);
2096 myStdActions.at(SelectionEdgeId)->setOn(true);
2102 case VolumeSelection:
2104 myStdActions.at(SelectionActorId)->setOn(false);
2105 myStdActions.at(SelectionEdgeId)->setOn(false);
2106 myStdActions.at(SelectionPointId)->setOn(false);
2107 myStdActions.at(SelectionCellId)->setOn(true);
2110 case ActorSelection:
2112 myStdActions.at(SelectionCellId)->setOn(false);
2113 myStdActions.at(SelectionEdgeId)->setOn(false);
2114 myStdActions.at(SelectionPointId)->setOn(false);
2115 myStdActions.at(SelectionActorId)->setOn(true);
2120 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2121 if ( sf->getTypeView() == VIEW_VTK ) {
2122 sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode );
2123 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2124 Sel->SetSelectionMode( mode, activeCompOnly );
2130 Called on 'Window\NewWindow3d'
2132 void QAD_Desktop::onNewWindow3d()
2136 //VRV: T2.5 - add default viewer
2137 QApplication::restoreOverrideCursor();
2138 SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE);
2139 int r = choice->exec();
2142 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer()));
2144 //VRV: T2.5 - add default viewer
2146 const QActionP* obj = (QActionP*) sender();
2147 if ( obj == myStdActions.at(ViewOCCId) ) {
2148 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0));
2149 } else if ( obj == myStdActions.at(ViewVTKId) ) {
2150 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1));
2151 } else if ( obj == myStdActions.at(ViewPlot2dId) ) {
2152 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3));
2157 // Helps to execute command
2158 class RunBrowser: public QThread {
2161 RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
2162 myApp(theApp), myParams(theParams), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {};
2168 if ( !myApp.isEmpty())
2170 aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
2171 myStatus = system(aCommand);
2174 QCustomEvent* ce2000 = new QCustomEvent (2000);
2175 postEvent (qApp, ce2000);
2179 if( myStatus != 0 || myApp.isEmpty())
2182 aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
2183 myStatus = system(aCommand);
2186 QCustomEvent* ce2001 = new QCustomEvent (2001);
2187 postEvent (qApp, ce2001);
2200 // Provide status tip for GUI help menu item
2202 void QAD_Desktop::onHelpModulePopupStatusText(int id)
2204 int Id = myHelpPopup.idAt( 0 ); // HelpContentsModuleId
2205 // MESSAGE ( "myHelpContentsModulePopup : " << id << "-" << Id)
2207 putInfo("Shows the help contents of each module");
2211 Called on 'help\contents'
2213 void QAD_Desktop::onHelpContents()
2214 { if (myActiveComp == "")
2215 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2220 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2221 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2222 if ( QFileInfo( root + "index.html" ).exists() ) {
2225 QMessageBox::warning( this, tr("WRN_WARNING"),
2226 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2231 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2232 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2233 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2235 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2240 Called on 'Module Help Reference'
2242 void QAD_Desktop::onHelpContentsModule()
2244 const QActionP* obj = (QActionP*) sender();
2246 QString aComponentName = obj->name();
2247 QString aFileName = aComponentName + "_index.html";
2252 if (dir = getenv( aComponentName + "_ROOT_DIR")) {
2253 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + QAD_Tools::addSlash("salome") );
2254 if ( QFileInfo( root + aFileName ).exists() ) {
2257 QMessageBox::warning( this, tr("WRN_WARNING"),
2258 QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") );
2263 QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
2264 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2265 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2267 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2272 Called on 'help\TUI Reference'
2276 void QAD_Desktop::onHelpContentsTUI()
2278 if (myActiveComp == "")
2279 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2284 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2285 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + "html" );
2286 if ( QFileInfo( root + "index.html" ).exists() ) {
2288 } else if (QFileInfo( root + "html/index.html" ).exists())
2289 homeDir = root + QAD_Tools::addSlash("html");
2291 QMessageBox::warning( this, tr("WRN_WARNING"),
2292 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2297 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2299 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2300 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2302 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2309 // Called on 'help\search'
2311 // void QAD_Desktop::onHelpSearch()
2314 // myActiveApp->helpSearch();
2320 Called on 'help\about'
2322 void QAD_Desktop::onHelpAbout()
2325 myActiveApp->helpAbout();
2332 Activates the application and its active study
2334 void QAD_Desktop::onActivateApp( QAD_Application* activeApp )
2336 bool appChanged = ( activeApp != myActiveApp );
2339 updateDesktop( DeactivateApp );
2343 myActiveApp = activeApp;
2344 myActiveStudy = myActiveApp->getActiveStudy();
2354 updateDesktop( ActivateApp );
2355 updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp );
2361 Called when the last study is removed from
2362 the application 'app'.
2364 void QAD_Desktop::onDeactivateApp(QAD_Application* app)
2366 if ( app && app == myActiveApp )
2371 Enables/disables standard actions
2373 void QAD_Desktop::updateActions()
2375 myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
2376 myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
2377 myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
2378 myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
2379 // myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
2380 // myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
2381 // myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL );
2382 // myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL );
2384 // myToolsPopup.setEnabled ( myActiveStudy != NULL );
2385 // myPrefPopup.setEnabled ( myActiveStudy != NULL );
2387 mySelectionModePopup.setEnabled ( myActiveStudy != NULL );
2390 myStdActions.at( ViewOCCId )->setEnabled( myActiveStudy != NULL );
2391 myStdActions.at( ViewVTKId )->setEnabled( myActiveStudy != NULL );
2392 myStdActions.at( ViewPlot2dId )->setEnabled( myActiveStudy != NULL );
2397 Called when 'Window' popup is about to show
2399 void QAD_Desktop::onWindowPopupAboutToShow()
2401 /* add cascade/tile items */
2402 myWindowPopup.clear();
2405 //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup );
2406 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
2407 //myStdActions.at( WindowNew3dId )->setEnabled( true );
2408 myWindowPopup.setItemEnabled( WindowNew3dId, true );
2410 myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup );
2411 myStdActions.at( WindowCascadeId )->setEnabled( true );
2412 myStdActions.at( WindowTileId )->addTo( &myWindowPopup );
2413 myStdActions.at( WindowTileId )->setEnabled( true );
2415 /* add names of opened studies */
2416 QWidgetList windows = myWorkspace->windowList();
2417 if ( windows.isEmpty() )
2419 //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false );
2420 myWindowPopup.setItemEnabled( WindowNew3dId, false );
2422 myStdActions.at( WindowCascadeId )->setEnabled( false );
2423 myStdActions.at( WindowTileId )->setEnabled( false );
2427 myWindowPopup.insertSeparator();
2428 for ( int i = 0; i < int(windows.count()); ++i )
2430 int id = myWindowPopup.insertItem( windows.at(i)->caption(),
2431 this, SLOT( onWindowsPopupActivated( int ) ) );
2432 myWindowPopup.setItemParameter( id, i );
2433 myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) );
2435 QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this,
2436 SLOT(onWindowsPopupStatusText( int )) ));
2441 Called when the item with 'id' of 'Windows' popup
2444 void QAD_Desktop::onWindowsPopupStatusText( int id )
2446 int cascadeId = myWindowPopup.idAt( 1 );
2447 int tileId = myWindowPopup.idAt( 2 );
2448 if ( id == cascadeId || id == tileId )
2450 putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
2454 Called when user wants to activate a child window with 'wid'
2457 void QAD_Desktop::onWindowsPopupActivated( int wid )
2459 QWidget* w = myWorkspace->windowList().at( wid );
2460 if ( w ) w->setFocus();
2464 Selects a file name when opening or saving files.
2465 The basic implementation just uses the standard
2467 Please redefine if another behaviour is required.
2469 QString QAD_Desktop::selectFileName ( bool open )
2471 QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true );
2475 QStringList filters;
2478 // All the file types of the supported applications
2480 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
2482 filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2483 "(*." + app->getStudyExtension() + ")";
2487 QAD_ASSERT_DEBUG_ONLY ( myActiveStudy );
2488 if (myActiveStudy) {
2489 // get file name of active study
2490 name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() );
2491 // get path to the active study file
2492 dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
2494 QAD_ASSERT_DEBUG_ONLY ( !name.isNull() );
2495 // the file types supported by the active application
2496 filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2497 "(*." + myActiveApp->getStudyExtension() + ")" ;
2499 if (!dir.isEmpty()) {
2500 // when saving document ("Save As" command) - to get dir from active study filename
2501 // for new documents - to use last opened directory
2504 fd->setSelection( name );
2505 fd->setFilters( filters );
2508 QString filename = fd->selectedFile();
2510 qApp->processEvents();
2515 Closes all the studies of 'app'. Returns
2516 'true' if thay are closed OK, 'false' at least
2517 one can't be closed or user cancel the closure.
2519 bool QAD_Desktop::closeAllStudies( QAD_Application* app )
2521 QList<QAD_Study>& studies = app->getStudies();
2522 while ( !studies.isEmpty() )
2524 //don't ask user to remove study permanently
2525 if ( !onCloseStudy( studies.at(0), false ) )
2526 return false; /* user cancelled closing */
2532 Called on Popup item when SComponent representation in Object Browser is selected.
2534 void QAD_Desktop::onOpenWith()
2536 Engines::Component_var comp;
2537 QString ComponentSelected;
2539 SALOMEDS::SObject_var SO;
2540 SALOMEDS::SComponent_var SCO;
2541 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2542 SALOMEDS::GenericAttribute_var anAttr;
2543 SALOMEDS::AttributeName_var aName;
2545 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2546 if ( Sel->IObjectCount() == 1 ) {
2547 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
2548 SO = aStudy->FindObjectID( IO->getEntry() );
2549 SCO = SO->GetFatherComponent();
2551 if (SCO->FindAttribute(anAttr, "AttributeName")) {
2552 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2553 name = aName->Value();
2554 SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( mapComponentName[name] );
2555 if ( !Comp->_is_nil() ) {
2557 SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
2558 myCatalogue->GetTypedComponentList( Comp->component_type() );
2560 if ( list_type_composants->length() == 1 ) {
2561 ComponentSelected = name;
2562 } else if ( list_type_composants->length() > 1 ) {
2563 SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
2564 for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
2565 QString compusername = getComponentUserName( strdup(list_type_composants[ind]) );
2566 if ( !compusername.isEmpty() )
2567 aDlg->addComponent( compusername );
2570 int retVal = aDlg->exec();
2571 ComponentSelected = aDlg->getComponent();
2573 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2577 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2582 MESSAGE( "This component not exists in the catalog" );
2586 QApplication::setOverrideCursor( Qt::waitCursor );
2587 Sel->ClearIObjects();
2589 // if (loadComponentData(ComponentSelected)) {
2590 onComboActiveComponent(ComponentSelected);
2591 // int nbItem = myCombo->count();
2593 // for (int i = 0; i < nbItem; i++) {
2594 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2599 // myCombo->setCurrentItem(Index);
2600 // myActiveStudy->updateObjBrowser(true);
2604 QApplication::restoreOverrideCursor();
2609 Called to define settings of component.
2611 void QAD_Desktop::setSettings()
2613 SALOMEGUI* anActiveGUI = getActiveGUI();
2614 if ( anActiveGUI ) {
2615 QString Component = mapComponentName[myActiveComp];
2616 anActiveGUI->SetSettings( this, (char*)Component.latin1() );
2621 Called to load Component : xml resources and GUI librairy.
2623 bool QAD_Desktop::loadComponent(QString Component)
2626 QString resDir("/"); //NRI : Pb under Windows
2628 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2631 if (!resMgr->loadResources( Component, msg ))
2633 //NRI QCString errMsg;
2634 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2635 // Component.latin1() );
2637 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2642 /* Parse xml file */
2643 myXmlHandler = new QAD_XmlHandler();
2644 myXmlHandler->setMainWindow(this);
2645 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2647 QString language = resMgr->language( Component );
2649 QString ComponentXml = Component + "_" + language + ".xml";
2650 //ComponentXml = resMgr->resources(Component + "GUI") ;
2651 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2652 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2653 QFile file( ComponentXml );
2655 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2657 errMsg.sprintf( "Cannot open xml file: %s\n.",
2658 (file.name()).latin1() );
2660 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2665 QXmlInputSource source( file );
2666 QXmlSimpleReader reader;
2667 reader.setContentHandler( myXmlHandler );
2668 reader.setErrorHandler( myXmlHandler );
2670 bool IsMaxActStudy = myActiveStudy->getActiveStudyFrame()->isMaximized();
2671 if (IsMaxActStudy) {
2672 QString aSourceData = source.data();
2673 aSourceData = changeXmlInputSourceData( aSourceData, Component );
2674 source.setData(aSourceData);
2677 bool ok = reader.parse( source );
2681 QMessageBox::critical( this,
2682 tr( "INF_PARSE_ERROR" ),
2683 tr( myXmlHandler->errorProtocol() ) );
2687 myMenusList=myXmlHandler->myMenusList;
2688 myActiveMenus=myMenusList.at(0);
2689 myOperatorMenus->showMenuBar(0);
2690 myActiveMenus->showAllToolBars();
2692 /* Components toolbars */
2695 nbToolbars = myActiveMenus->getToolBarList().count();
2697 // san - avoid loading component GUI library multiple times
2698 QString aUserName( getComponentUserName( Component ) );
2700 SALOMEGUI* anActiveGUI = getComponentGUI(aUserName);
2705 anActiveGUI->SetSettings( this, (char*)Component.latin1() );
2707 /* COMPONENT INTERFACE */
2708 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2709 myCatalogue->GetComponent(Component.latin1());
2711 if (CORBA::is_nil (aComponent)) {
2712 MESSAGE( "Catalog Error : Component not found in the catalog" )
2716 myActiveStudy->setMessage(QString("Component : ") +
2717 aComponent->componentusername() + " created " );
2718 myActiveStudy->setMessage(QString("Type : ") +
2719 QString::number(aComponent->component_type()));
2720 myActiveStudy->setMessage(QString("Constraint : ") +
2721 aComponent->constraint() );
2723 /* obtain interfaces list of the component */
2724 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2725 new SALOME_ModuleCatalog::ListOfInterfaces;
2726 _list = aComponent->GetInterfaceList();
2728 if (_list->length() != 0 ) {
2730 for (unsigned int ind = 0; ind < _list->length();ind++)
2731 myActiveStudy->setMessage( QString("Interface name : ") +
2735 /* obtain services list of the component */
2736 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2737 new SALOME_ModuleCatalog::ListOfServices;
2738 list_services_component = aComponent->GetServiceList(_list[0]);
2740 if (list_services_component->length() != 0 ) {
2742 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2743 myActiveStudy->setMessage( QString("Service name : ") +
2744 list_services_component[ind] );
2746 // Get a service of the component
2747 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2748 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2749 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2750 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2751 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2752 (const char *) service->ServiceinParameter[ind1].Parametertype);
2753 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2754 (const char *) service->ServiceinParameter[ind1].Parametername);
2756 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2757 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2758 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2759 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2760 (const char *) service->ServiceoutParameter[ind1].Parametername);
2767 QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent)
2769 // MESSAGE ( " changeXmlInputSourceData : " << theComponent.latin1() )
2770 if ( theComponent=="SUPERV" ) {
2771 //Supervision main menu item
2774 QString aStrOld = createString( aItemId, aPosId );
2775 QString aStrNew = createString( aItemId, aPosId+1 );
2776 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2779 if ( theComponent == "VISU" ) {
2780 //Visualization main menu item
2783 QString aStrOld = createString( aItemId, aPosId );
2784 QString aStrNew = createString( aItemId, aPosId+1 );
2785 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2787 //Selection main menu item
2790 aStrOld = createString( aItemId, aPosId );
2791 aStrNew = createString( aItemId, aPosId+1 );
2792 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2794 //Representation main menu item
2797 aStrOld = createString( aItemId, aPosId );
2798 aStrNew = createString( aItemId, aPosId+1 );
2799 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2802 if ( theComponent == "SMESH" ) {
2803 //Hypotheses main menu item
2806 QString aStrOld = createString( aItemId, aPosId );
2807 QString aStrNew = createString( aItemId, aPosId+1 );
2808 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2810 //Mesh main menu item
2813 aStrOld = createString( aItemId, aPosId );
2814 aStrNew = createString( aItemId, aPosId+1 );
2815 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2817 //Controls main menu item
2820 aStrOld = createString( aItemId, aPosId );
2821 aStrNew = createString( aItemId, aPosId+1 );
2822 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2824 //Modification main menu item
2827 aStrOld = createString( aItemId, aPosId );
2828 aStrNew = createString( aItemId, aPosId+1 );
2829 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2831 //Numbering main menu item
2834 // aStrOld = createString( aItemId, aPosId );
2835 // aStrNew = createString( aItemId, aPosId+1 );
2836 // theData = theData.replace( QRegExp(aStrOld), aStrNew );
2839 if ( theComponent == "GEOM" ) {
2840 //New Entity main menu item
2843 QString aStrOld = createString( aItemId, aPosId );
2844 QString aStrNew = createString( aItemId, aPosId+1 );
2845 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2847 //Operations main menu item
2850 aStrOld = createString( aItemId, aPosId );
2851 aStrNew = createString( aItemId, aPosId+1 );
2852 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2854 //Repair main menu item
2857 aStrOld = createString( aItemId, aPosId );
2858 aStrNew = createString( aItemId, aPosId+1 );
2859 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2861 //Measures main menu item
2864 aStrOld = createString( aItemId, aPosId );
2865 aStrNew = createString( aItemId, aPosId+1 );
2866 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2869 if ( theComponent == "MED" ) {
2870 //MED main menu item
2873 QString aStrOld = createString( aItemId, aPosId );
2874 QString aStrNew = createString( aItemId, aPosId+1 );
2875 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2881 typedef bool OneDim(int, QAD_Desktop*);
2882 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2886 void QAD_Desktop::onDispatch()
2888 const QObject* obj = sender();
2890 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2891 QAD_ListMenuIdAction* aMenu;
2893 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2894 if (aMenu->getAction()==obj) {
2895 id = aMenu->getId();
2904 void QAD_Desktop::onDispatchTools(int id)
2906 /* Open Shared Library */
2907 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2911 QFileInfo fileInfo ;
2915 bool libToolsGUI = true;
2916 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2918 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2919 dir = QAD_Tools::addSlash(dir) ;
2921 dir = QAD_Tools::addSlash(dir) ;
2922 dir = dir + "salome" ;
2923 dir = QAD_Tools::addSlash(dir) ;
2925 dir = dir + "libToolsGUI.dll" ;
2927 dir = dir + "libToolsGUI.so" ;
2929 MESSAGE ( " GUI library = " << dir );
2930 fileInfo.setFile(dir) ;
2931 if (fileInfo.exists()) {
2932 ToolsLib = fileInfo.fileName() ;
2938 libToolsGUI = false;
2939 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
2940 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2941 dir = QAD_Tools::addSlash(dir) ;
2943 dir = QAD_Tools::addSlash(dir) ;
2944 dir = dir + "salome" ;
2945 dir = QAD_Tools::addSlash(dir) ;
2946 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2947 MESSAGE ( " GUI library = " << dir );
2948 fileInfo.setFile(dir) ;
2949 if (fileInfo.exists()) {
2950 ToolsLib = fileInfo.fileName() ;
2956 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
2957 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
2959 if ( libToolsGUI ) {
2960 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2961 OneDim (*f1) = NULL;
2962 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2965 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
2966 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
2967 CORBA::ORB_var &orb = init(0 , 0 ) ;
2968 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2969 PTR_FACTORY_FUNCTION f1 = NULL;
2970 f1 = (PTR_FACTORY_FUNCTION) osdF;
2971 f1(orb,0,"Registry");
2974 QMessageBox::critical( this,
2976 tr( ToolsLibrary.DlError() ) );
2982 void QAD_Desktop::onDispatch(int id)
2984 SALOMEGUI* anActiveGUI = getActiveGUI();
2986 anActiveGUI->OnGUIEvent(id,this);
2990 Returns the component's catalogue
2992 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
2999 void QAD_Desktop::onComboActiveComponent( const QString & component ){
3000 onComboActiveComponent(component,true);
3002 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
3004 if (myActiveStudy != 0) {
3005 if (myActiveComp.compare(component)!=0) {
3006 // deactivate previous component
3007 deactivateComponent();
3009 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3010 if ( myCombo->currentText() != component )
3011 myCombo->setCurrentText( component );
3012 //NRI if (component.compare(QString("Salome"))!= 0) {
3013 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
3014 // QApplication::setOverrideCursor( Qt::waitCursor );
3015 myActiveComp = component;
3017 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3019 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3020 if ( aButton->textLabel().compare(component)==0)
3021 aButton->setOn(true);
3023 aButton->setOn(false);
3026 myActiveStudy->Selection( component );
3027 if ( !loadComponent(mapComponentName[component]) ) {
3028 myCombo->setCurrentItem (0);
3029 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3030 aButton->setOn(false);
3035 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3036 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
3037 for(;It.More();It.Next()) {
3038 int res = Sel->AddIObject( It.Value() );
3041 myActiveStudy->highlight( It.Value(), false );
3043 myActiveStudy->highlight( It.Value(), true );
3047 // Open new component's data in active study if any
3048 if(isLoadData) loadComponentData(mapComponentName[component]);
3051 myActiveStudy->updateObjBrowser(true);
3053 // QApplication::restoreOverrideCursor();
3055 } else { // component == "Salome"
3057 //NRI myActiveStudy->Selection( "Salome" );
3058 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
3059 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3060 Sel->ClearIObjects();
3061 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3062 aButton->setOn(false);
3066 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3067 if ( aButton->textLabel().compare(component)==0)
3068 aButton->setOn(true);
3071 } else if (component.compare(QString("Salome"))!= 0) {
3074 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3075 if ( aButton->textLabel().compare( component ) == 0 )
3076 pm = aButton->iconSet().pixmap();
3078 SALOMEGUI_ActivateComponentDlg aDlg( this, component, pm );
3079 int res = aDlg.exec();
3085 onComboActiveComponent(component,true);
3089 onComboActiveComponent(component,true);
3093 onComboActiveComponent(component,true);;
3097 putInfo( tr("INF_CANCELLED") );
3098 myCombo->setCurrentItem (0);
3099 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3100 aButton->setOn(false);
3109 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
3111 int nbItem = myCombo->count();
3114 for (int i = 0; i < nbItem; i++) {
3115 if (myCombo->text(i).compare(theName)==0) {
3120 myCombo->setCurrentItem (Index);
3121 onComboActiveComponent(theName,isLoadData);
3124 void QAD_Desktop::onButtonActiveComponent( )
3126 QToolButton* obj = (QToolButton*)sender();
3127 activateComponent(obj->textLabel());
3131 Clears All Resources of current component
3133 void QAD_Desktop::clearMenus()
3135 onActiveStudyChanged();
3138 myMenusList.clear();
3140 int length = myXmlHandler->myIdList.Length();
3141 for (int k=length; k>0; k--) {
3143 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
3144 parent->removeItem( myXmlHandler->myIdList.Value(k) );
3149 if (myActiveMenus) {
3150 int nbtoolbars = myActiveMenus->getToolBarList().count();
3151 for (int k=0; k<nbtoolbars; k++) {
3152 myActiveMenus->getToolBarList().at(k)->hide();
3153 myActiveMenus->getToolBarList().at(k)->clear();
3155 myActiveMenus->clearToolBar();
3158 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
3159 QAD_ListPopupMenu* aPopup;
3160 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
3161 aPopup->getPopup()->clear();
3164 myActiveMenus->clearPopupMenu();
3170 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3172 Exports Key Events in active component ( GUI Librairy )
3174 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
3176 // MESSAGE ( "QAD_Desktop::onKeyPress" )
3177 SALOMEGUI* anActiveGUI = getActiveGUI();
3179 anActiveGUI->OnKeyPress(pe,this,myActiveStudy->getActiveStudyFrame());
3182 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3184 Exports Mouse Press Events in active component ( GUI Librairy )
3186 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
3188 // MESSAGE ( "QAD_Desktop::onMousePress" )
3189 SALOMEGUI* anActiveGUI = getActiveGUI();
3191 return anActiveGUI->OnMousePress(pe,this,myActiveStudy->getActiveStudyFrame());
3196 Exports Mouse Move Events in active component ( GUI Librairy )
3198 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
3200 SALOMEGUI* anActiveGUI = getActiveGUI();
3202 anActiveGUI->OnMouseMove(pe,this,myActiveStudy->getActiveStudyFrame());
3206 Returns name of active component
3208 const QString& QAD_Desktop::getActiveComponent() const
3210 return myActiveComp;
3213 SALOMEGUI* QAD_Desktop::getActiveGUI()
3215 SALOMEGUI* anActiveGUI = 0;
3216 if ( myComponents.find( myActiveComp ) != myComponents.end() )
3217 anActiveGUI = myComponents[myActiveComp];
3221 typedef SALOMEGUI* (*ComponentGUI)();
3223 SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component )
3225 SALOMEGUI* aCompGUI = 0;
3227 // Load component GUI if requested for the first time
3228 if ( myComponents.find( component ) == myComponents.end() ) {
3229 OSD_SharedLibrary aSharedLibrary;
3230 QString ComponentLib;
3232 QFileInfo fileInfo ;
3233 QString fileString ;
3240 if ( libs = getenv("LD_LIBRARY_PATH")) {
3241 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
3242 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
3243 for ( int i = dirList.count()-1; i >= 0; i-- ) {
3246 fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.dll" ;
3248 fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.so" ;
3251 fileInfo.setFile(fileString) ;
3252 if (fileInfo.exists()) {
3253 // MESSAGE( " GUI library = " << fileString.latin1() );
3254 ComponentLib = fileInfo.fileName() ;
3261 if (!_islibso) // component GUI could be in PyQt, use generic library
3263 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
3265 if (dir = getenv("KERNEL_ROOT_DIR"))
3267 dir = QAD_Tools::addSlash(dir) ;
3269 dir = QAD_Tools::addSlash(dir) ;
3270 dir = dir + "salome" ;
3271 dir = QAD_Tools::addSlash(dir) ;
3273 dir = dir + "libSalomePyQtcmodule.dll" ;
3275 dir = dir + "libSalomePyQtcmodule.so" ;
3277 MESSAGE ( " GUI library = " << dir );
3278 fileInfo.setFile(dir) ;
3279 if (fileInfo.exists())
3281 ComponentLib = fileInfo.fileName() ;
3287 QMessageBox::critical( this,
3289 tr("ERR_LIBGUI" ).arg(component) );
3294 aSharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
3295 bool ok = aSharedLibrary.DlOpen(OSD_RTLD_LAZY);
3298 QMessageBox::critical( this,
3300 tr( aSharedLibrary.DlError() ) );
3304 OSD_Function osdF = aSharedLibrary.DlSymb("GetComponentGUI");
3305 if ( osdF != NULL ) {
3306 ComponentGUI f1 = (SALOMEGUI* (*) ()) osdF;
3307 SALOMEGUI* aCompGUI = (*f1)();
3309 myComponents.insert( component, aCompGUI );
3312 QMessageBox::critical( this,
3314 tr("ERR_GET_GUI_FAILED" ).arg(component) );
3320 QMessageBox::critical( this,
3322 tr("ERR_GET_GUI_NOT_FOUND" ).arg(ComponentLib) );
3326 aCompGUI = myComponents[component];
3331 void QAD_Desktop::definePopup(QString & theContext,
3332 QString & theParent,
3333 QString & theObject )
3335 SALOMEGUI* anActiveGUI = getActiveGUI();
3337 anActiveGUI->DefinePopup(theContext, theParent, theObject);
3342 Copy popup menu [ static ]
3344 static void makePopup( QPopupMenu* popup, QPopupMenu* fromPopup, QAD_Desktop* receiver )
3347 if ( !popup || !fromPopup )
3349 // iterator through all popup items
3350 for ( int i = fromPopup->count()-1; i >= 0; i-- ) {
3351 int cmdId = fromPopup->idAt( i );
3352 QMenuItem* item = fromPopup->findItem( cmdId );
3354 // if item is a separator
3355 if ( item->isSeparator() ) {
3356 popup->insertSeparator( 0 );
3359 QIconSet* iconSet = item->iconSet();
3360 QKeySequence accel = fromPopup->accel( cmdId );
3362 QPopupMenu* popupChild = item->popup();
3363 // if item is a popup
3364 if ( popupChild && popupChild != fromPopup ) {
3365 QPopupMenu* newPopup = new QPopupMenu( popup );
3367 popup->insertItem( *iconSet, item->text(), newPopup, cmdId, 0 );
3369 popup->insertItem( item->text(), newPopup, cmdId, 0 );
3370 makePopup( newPopup, popupChild, receiver );
3372 // if item is a command
3375 popup->insertItem( *iconSet, item->text(), cmdId, 0 );
3377 popup->insertItem( item->text(), cmdId, 0 );
3378 popup->connectItem( cmdId, receiver, SLOT( onDispatch( int ) ) );
3380 popup->setAccel( accel, cmdId );
3389 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
3390 const QString & theParent, const QString & theObject )
3392 if ( !myActiveComp.isEmpty() &&
3393 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
3394 makePopup( popup, getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(), this );
3397 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3398 if ( myActiveComp.isEmpty() ) {
3399 popup->removeItem(QAD_Display_Popup_ID);
3400 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3401 popup->removeItem(QAD_Erase_Popup_ID);
3402 int id = popup->idAt(popup->count()-1); // last item
3403 if (id < 0 && id != -1) popup->removeItem(id); // separator
3405 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3406 if ( popup->count()>0 ) {
3407 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3408 popup->insertSeparator (3);
3411 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3418 void QAD_Desktop::onActiveStudyChanged()
3420 SALOMEGUI* anActiveGUI = getActiveGUI();
3422 anActiveGUI->ActiveStudyChanged(this);
3425 void QAD_Desktop::deactivateComponent()
3427 SALOMEGUI* anActiveGUI = getActiveGUI();
3429 anActiveGUI->Deactivate();
3433 Custom popup ( GUI Library )
3435 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3436 const QString & theParent, const QString & theObject)
3438 SALOMEGUI* anActiveGUI = getActiveGUI();
3440 anActiveGUI->CustomPopup(this, popup, theContext, theParent, theObject);
3443 void QAD_Desktop::onObjectBrowser()
3445 bool checkDiff = false;
3447 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3449 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3453 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3455 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3458 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3462 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3464 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3467 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3471 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3473 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3476 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3479 /* To sort created object in chrono order or reverse chrono order */
3480 bool showCHRONO_SORT ;
3481 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3482 showCHRONO_SORT = true;
3483 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "true");
3485 showCHRONO_SORT = false;
3486 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "false");
3489 /* To show or not to show UseCase browser */
3491 if ( myStdActions.at( PrefObjectBrowserShowUseCaseId )->isOn() ) {
3493 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "true");
3495 showUseCase = false;
3496 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "false");
3499 /* Resize or don't resize columns automatically */
3501 if ( myStdActions.at( PrefObjectBrowserNoAutoSizeColumnsId )->isOn() ) {
3503 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "true");
3506 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "false");
3509 if ( myActiveApp ) {
3510 QList<QAD_Study>& studies = myActiveApp->getStudies();
3511 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3512 int nbSf = study->getStudyFramesCount();
3513 for ( int i = 0; i < nbSf; i++ ) {
3514 QAD_StudyFrame* sf = study->getStudyFrame(i);
3515 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3516 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3517 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3518 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3519 sf->getLeftFrame()->getObjectBrowser()->showUseCaseBrowser( showUseCase );
3520 sf->getLeftFrame()->getObjectBrowser()->autoSizeColumns( autoSize );
3522 study->updateObjBrowser(true);
3527 void QAD_Desktop::onViewerTrihedron()
3529 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3532 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3533 if (!Size.isEmpty())
3534 Dlg->setTrihedronSize(Size.toInt());
3535 int r = Dlg->exec();
3536 dim = Dlg->getTrihedronSize();
3539 if (r == QDialog::Accepted) {
3540 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3543 QList<QAD_Study>& studies = myActiveApp->getStudies();
3544 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3545 int nbSf = study->getStudyFramesCount();
3546 for ( int i = 0; i < nbSf; i++ ) {
3547 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->onAdjustTrihedron();
3554 void QAD_Desktop::onExternalBrowser()
3557 QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3558 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3560 SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
3562 if (!theApp.isEmpty())
3564 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3565 Dlg->setSettings(theApp, theParams);
3567 int r = Dlg->exec();
3568 QString theAppFromDialog = Dlg->getApp();
3569 QString theParamsFromDialog = Dlg->getParams();
3572 if (r == QDialog::Accepted)
3574 QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
3575 QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
3581 void QAD_Desktop::onDirList()
3583 // getting dir list from settings
3584 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3585 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3586 dlg->setPathList(dirList);
3587 if ( dlg->exec() == QDialog::Accepted) {
3588 dlg->getPathList(dirList);
3589 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3594 void QAD_Desktop::onConsoleFontAction()
3596 // getting font from settings
3597 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3598 QFont font = QAD_Tools::stringToFont( fntSet );
3600 font = QFontDialog::getFont( &bOk, font, this );
3602 fntSet = QAD_Tools::fontToString( font );
3603 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3606 QList<QAD_Study>& studies = myActiveApp->getStudies();
3607 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3608 int nbSf = study->getStudyFramesCount();
3609 for ( int i = 0; i < nbSf; i++ ) {
3610 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3611 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3618 void QAD_Desktop::onSavePref()
3620 QAD_CONFIG->createConfigFile(true);
3623 //VRV: T2.5 - add default viewer
3624 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3626 int type = VIEW_TYPE_MAX;
3629 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3631 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3633 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3634 type = VIEW_GRAPHSUPERV;
3635 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3637 if ( type != VIEW_TYPE_MAX )
3638 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3640 //VRV: T2.5 - add default viewer
3642 void QAD_Desktop::onViewerOCC()
3644 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3645 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3646 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3649 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3650 color = QColor(BackgroundColorRed.toInt(),
3651 BackgroundColorGreen.toInt(),
3652 BackgroundColorBlue.toInt());
3654 color = QColor(35, 136, 145);
3656 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3659 /* VSR : PAL5420 ---------------------------------------------------
3660 if ( myActiveApp ) {
3661 QList<QAD_Study>& studies = myActiveApp->getStudies();
3662 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3663 int nbSf = study->getStudyFramesCount();
3664 for ( int i = 0; i < nbSf; i++ ) {
3665 QAD_StudyFrame* sf = study->getStudyFrame(i);
3666 if ( sf->getTypeView() == VIEW_OCC ) {
3667 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3672 VSR : PAL5420 --------------------------------------------------- */
3673 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3674 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3675 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3679 void QAD_Desktop::onGraphSupervisor()
3681 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3682 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3683 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3686 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3687 color = QColor(BackgroundColorRed.toInt(),
3688 BackgroundColorGreen.toInt(),
3689 BackgroundColorBlue.toInt());
3691 color = QColor(35, 136, 145);
3693 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3696 /* VSR : PAL5420 ---------------------------------------------------
3697 if ( myActiveApp ) {
3698 QList<QAD_Study>& studies = myActiveApp->getStudies();
3699 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3700 int nbSf = study->getStudyFramesCount();
3701 for ( int i = 0; i < nbSf; i++ ) {
3702 QAD_StudyFrame* sf = study->getStudyFrame(i);
3703 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3704 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3709 VSR : PAL5420 --------------------------------------------------- */
3710 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3711 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3712 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3716 void QAD_Desktop::onViewerVTK()
3718 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3719 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3720 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3723 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3724 color = QColor(BackgroundColorRed.toInt(),
3725 BackgroundColorGreen.toInt(),
3726 BackgroundColorBlue.toInt());
3728 color = QColor(0, 0, 0);
3730 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3733 /* VSR : PAL5420 ---------------------------------------------------
3734 if ( myActiveApp ) {
3735 QList<QAD_Study>& studies = myActiveApp->getStudies();
3736 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3737 int nbSf = study->getStudyFramesCount();
3738 for ( int i = 0; i < nbSf; i++ ) {
3739 QAD_StudyFrame* sf = study->getStudyFrame(i);
3740 if ( sf->getTypeView() == VIEW_VTK ) {
3741 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3746 VSR : PAL5420 --------------------------------------------------- */
3747 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3748 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3749 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3753 void QAD_Desktop::onPlot2d()
3756 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3757 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3758 QStringList bgData = QStringList::split( ":", bgString, true );
3759 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3760 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3761 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3762 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3763 color = QColor( bgRed, bgGreen, bgBlue );
3766 color = QColor(255, 255, 255);
3769 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3771 if ( color.isValid() ) {
3772 /* VSR : PAL5420 ---------------------------------------------------
3773 if ( myActiveApp ) {
3774 QList<QAD_Study>& studies = myActiveApp->getStudies();
3775 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3776 int nbSf = study->getStudyFramesCount();
3777 for ( int i = 0; i < nbSf; i++ ) {
3778 QAD_StudyFrame* sf = study->getStudyFrame(i);
3779 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3780 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3785 VSR : PAL5420 --------------------------------------------------- */
3787 bgData.append( QString::number( color.red() ) );
3788 bgData.append( QString::number( color.green() ) );
3789 bgData.append( QString::number( color.blue() ) );
3790 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3795 void QAD_Desktop::helpAbout()
3797 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3802 // /* Help Search */
3803 // void QAD_Desktop::helpSearch()
3807 // /* Help Contents */
3808 // void QAD_Desktop::helpContents()
3810 // if (myActiveComp == "")
3811 // myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3815 // if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3816 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3817 // if ( QFileInfo( root + "index.html" ).exists() ) {
3818 // helpContext( root + "index.html", "" );
3821 // root = QAD_Tools::addSlash( root + "html" );
3822 // if ( QFileInfo( root + "index.html" ).exists() ) {
3823 // helpContext( root + "index.html", "" );
3826 // root = QAD_Tools::addSlash( root + "html" );
3827 // if ( QFileInfo( root + "index.html" ).exists() ) {
3828 // helpContext( root + "index.html", "" );
3834 // // //NRI getHelpWindow()->contents();
3835 // // getHelpWindow()->show();
3836 // // getHelpWindow()->raise();
3837 // // getHelpWindow()->setActiveWindow();
3841 //void QAD_Desktop::helpContext(const QString& source, const QString& context)
3843 // //getHelpWindow()->context(source, context); //implemented in QAD_HelpWindow::context( const QString& _source, const QString& _context)
3844 // //getHelpWindow()->show(); //from QMainWindow class
3845 // //getHelpWindow()->raise(); //from QMainWindow class
3846 // //getHelpWindow()->setActiveWindow(); //from QMainWindow class
3848 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3849 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3851 // RunBrowser* rs = new RunBrowser(anApp, aParams, source, context);
3855 /* Preferences/MultiFile Save */
3856 void QAD_Desktop::onMultiFileSave()
3858 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3859 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3861 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3864 /* Preferences/ASCII Save */
3865 void QAD_Desktop::onASCIISave()
3867 if ( myStdActions.at( PrefASCIISave )->isOn() )
3868 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3870 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3873 /* Preferences / Undo Level */
3874 void QAD_Desktop::onUndoLevel()
3876 static int MAX_UNDO_LEVEL = 1000;
3877 bool isAccepted = false;
3878 static QString aLabel = QString("Level value (%1 ... %2) : ").
3879 arg(1).arg(MAX_UNDO_LEVEL);
3881 SALOMEGUI_SetValueDlg::getInteger("Undo Level",aLabel,
3882 1,MAX_UNDO_LEVEL,getUndoLevel(),
3884 if(!isAccepted) return;
3885 QAD_CONFIG->addSetting("Desktop:UndoLevel", anUndoLevel);
3886 if(!myActiveApp) return;
3887 QList<QAD_Study>& studies = myActiveApp->getStudies();
3888 int aWasWarning = 0;
3889 for(QAD_Study* study = studies.first(); study; study = studies.next()){
3890 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
3891 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDoc->NewBuilder();
3892 if (!aStudyDoc->GetProperties()->IsLocked()) {
3893 aStudyBuilder->UndoLimit(anUndoLevel);
3896 QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
3897 QObject::tr("WRN_WARNING"),
3898 QObject::tr("WRN_STUDY_LOCKED"),
3899 QObject::tr("BUT_OK"));
3906 /* Update status bar for File menu items */
3907 void QAD_Desktop::onFilePopupStatusText( int id )
3909 QString component = getActiveComponent();
3911 if (component != "") {
3912 //one of the modules is active now
3913 int importId = myFilePopup.idAt(8);
3914 int exportId = myFilePopup.idAt(9);
3915 int importTableId = myFilePopup.idAt(10);
3917 if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM")) {
3919 putInfo( tr("PRP_DESK_FILE_IMPORT") );
3921 putInfo( tr("PRP_DESK_FILE_EXPORT") );
3923 if (component == getComponentUserName("VISU")) {
3925 putInfo( tr("PRP_DESK_FILE_IMPORTMED") );
3926 if (id == importTableId)
3927 putInfo( tr("PRP_DESK_FILE_IMPORTTABLE") );
3929 putInfo( tr("PRP_DESK_FILE_EXPLOREMEDFILE") );
3931 if (component == getComponentUserName("SUPERV")) {
3933 putInfo( tr("PRP_DESK_FILE_IMPORTDF") );
3935 putInfo( tr("PRP_DESK_FILE_EXPORTDF") );
3940 /* Update status bar for Edit menu items */
3941 void QAD_Desktop::onEditPopupStatusText( int id )
3943 QString component = getActiveComponent();
3945 if (component != "") {
3946 //one of the modules is active now
3948 if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM") ) {
3949 int deleteId = myEditPopup.idAt(5);
3951 putInfo( tr("PRP_DESK_EDIT_DELETE") );
3953 if (component == getComponentUserName("SUPERV") ) {
3954 int newDFId = myEditPopup.idAt(5);
3955 int modifyDFId = myEditPopup.idAt(6);
3957 putInfo( tr("PRP_DESK_EDIT_NEWDF") );
3958 if (id == modifyDFId)
3959 putInfo( tr("PRP_DESK_EDIT_MODIFYDF") );
3964 /* Update status bar for View menu items */
3965 void QAD_Desktop::onViewPopupStatusText( int id )
3967 QString component = getActiveComponent();
3969 if (component != "") {
3970 //one of the modules is active now
3971 int DispModeId = myViewPopup.idAt(2);
3973 if (component == getComponentUserName("GEOM")) {
3974 if (id == DispModeId)
3975 putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") );
3977 if (component == getComponentUserName("SMESH")) {
3978 int updateId = myViewPopup.idAt(3);
3980 if (id == DispModeId)
3981 putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") );
3983 putInfo( tr("PRP_DESK_VIEW_UPDATE") );
3988 /*********************************************************************
3989 ** Class: AppSelectionDlg
3990 ** Descr: Dialog for the selection of the application when several
3991 ** applications exist in the desktop and new study creation
3992 ** is activated by user.
3994 **********************************************************************/
3996 \class Desktop_AppSelectionDlg QAD_Desktop.h
3997 \brief Dialog for the selection of the application when several
3998 applications exist in the desktop and new study creation
3999 is activated by user.
4004 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
4005 QList<QAD_Application>& apps ) :
4006 QDialog( desktop, 0, true ),
4010 QAD_ASSERT_DEBUG_ONLY ( desktop );
4011 setCaption( tr("INF_DESK_DOC_CREATE") );
4012 if ( desktop->icon() )
4013 setIcon( *desktop->icon() );
4015 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
4017 /* Create selection buttons */
4018 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
4019 buttonGrp->setExclusive ( true );
4020 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
4021 vLayout->addWidget ( buttonGrp );
4023 /* Create selection button for available app */
4025 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
4027 /* add radio button for application */
4028 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
4029 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
4032 /* make the first application selected */
4033 buttonGrp->setButton( 0 );
4035 /* listen to the selection */
4036 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
4038 /* Create OK/Cancel buttons
4040 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
4041 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
4042 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
4043 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
4044 buttonOK->setDefault( true );
4046 hLayout->addStretch();
4047 hLayout->addWidget( buttonOK );
4048 hLayout->addWidget( buttonCancel );
4049 hLayout->addWidget( buttonHelp );
4051 /* connect buttons */
4052 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
4053 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
4054 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
4056 /* disable resizing */
4057 setFixedSize( 0, 0 );
4058 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
4061 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
4065 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
4067 return myApps.at( myAppId );
4070 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
4072 QAD_Tools::centerWidget( this, parentWidget() );
4078 void Desktop_AppSelectionDlg::onAppSelected( int id )
4083 void Desktop_AppSelectionDlg::onHelp()