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_Operation.h"
47 #include "QAD_XmlHandler.h"
48 #include "QAD_MessageBox.h"
49 #include "QAD_Application.h"
50 #include "QAD_Settings.h"
51 #include "QAD_Config.h"
52 #include "QAD_ObjectBrowser.h"
53 #include "QAD_Resource.h"
54 #include "QAD_FileDlg.h"
55 //NRI #include "QAD_HelpWindow.h"
56 #include "QAD_DirListDlg.h"
57 #include "QAD_WaitCursor.h"
58 #include "SALOMEGUI_OpenWith.h"
59 #include "SALOMEGUI_StudyPropertiesDlg.h"
60 #include "SALOMEGUI_TrihedronSizeDlg.h"
61 #include "SALOMEGUI_ExternalBrowserDlg.h"
62 #include "SALOMEGUI_LoadStudiesDlg.h"
63 #include "SALOME_Selection.h"
64 #include "SALOME_InteractiveObject.hxx"
65 #include "SALOME_ListIteratorOfListIO.hxx"
66 #include "SALOMEGUI_AboutDlg.h"
67 #include "SALOMEGUI_ViewChoiceDlg.h"
68 #include "SALOMEGUI_SetValueDlg.h"
69 #include "utilities.h"
71 #include "SALOMEGUI_CloseDlg.h"
72 #include "SALOMEGUI_ActivateComponentDlg.h"
77 #include <qmessagebox.h>
78 #include <qcolordialog.h>
79 #include <qradiobutton.h>
80 #include <qapplication.h>
81 #include <qvbuttongroup.h>
83 #include <qmessagebox.h>
86 #include <qpopupmenu.h>
87 #include <qlistview.h>
91 #include <qfontdialog.h>
92 #include <qlineedit.h>
93 #include <qdatetime.h>
101 // Open CASCADE Includes
102 #include <OSD_LoadMode.hxx>
103 #include <OSD_Function.hxx>
104 #include <TCollection_AsciiString.hxx>
107 static const char* SEPARATOR = ":";
114 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
115 QPalette* QAD_Desktop::palette = 0;
117 static QString createString( int theItemId, int thePosId )
119 QString aRetString = QString("item-id=");
121 QString aItemId = aString.setNum(theItemId);
122 QString aPosId = aString.setNum(thePosId);
123 aRetString = aRetString + '"'; aRetString = aRetString + aItemId; aRetString = aRetString + '"';
124 aRetString = aRetString + " pos-id="; aRetString = aRetString + '"';
125 aRetString = aRetString + aPosId;
126 aRetString = aRetString + '"'; aRetString = aRetString + ">";
131 Creates the resource manager [ static ]
133 QAD_ResourceMgr* QAD_Desktop::createResourceManager()
136 resourceMgr = new QAD_ResourceMgr;
141 Returns the resource manager [ static ]
143 QAD_ResourceMgr* QAD_Desktop::getResourceManager()
150 Loads the palette from settings [ static ]
152 QPalette* QAD_Desktop::createPalette()
155 palette = new QPalette();
161 Returns the palette [ static ]
163 QPalette* QAD_Desktop::getPalette()
169 Gets window ratio width/heght [ static ]
171 static double myWindowRatio = 1;
172 static double getWindowRatio()
174 return myWindowRatio;
178 Sets window ratio width/heght [ static ]
180 static void setWindowRatio(double aRatio)
182 myWindowRatio = aRatio;
188 QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) :
189 QMainWindow(0, 0, WType_TopLevel | WDestructiveClose),
195 //NRImyHelpWindow(0),
196 myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
199 /* Force reading of user config file */
200 QAD_CONFIG->readConfigFile();
202 /* menubar and status bar */
203 myStatusBar = statusBar();
204 myMainMenu = menuBar();
206 myNameService = name_service;
208 /* default background icon */
209 QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
210 tr("ICON_DESK_BACKGROUNDICON") ));
211 //myToolBarAction.setAutoDelete( true );
213 /* default icon and title */
214 QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
215 tr("ICON_DESK_DEFAULTICON") ));
216 if ( !icon.isNull() ) {
217 myDefaultIcon = icon;
218 setIcon( myDefaultIcon );
220 setCaption( myDefaultTitle );
222 /* set size as 1/2 of the screen and center it */
223 QWidget* d = QApplication::desktop();
224 resize( 2*d->width()/3, 2*d->height()/3 );
225 QAD_Tools::centerWidget( this, d );
227 /* workspace will manage child frames */
228 QHBox* border = new QHBox ( this );
229 border->setFrameStyle ( QFrame::Panel | QFrame::Sunken );
230 setCentralWidget( border );
231 myWorkspace = new QWorkspaceP( border );
233 QPalette pal = QAD_Application::getPalette();
235 QColorGroup cgA = pal.active();
236 QColorGroup cgI = pal.inactive();
237 QColorGroup cgD = pal.disabled();
238 cgA.setColor( QColorGroup::Background, QColor(192, 192, 192));
239 cgI.setColor( QColorGroup::Background, QColor(192, 192, 192));
240 cgD.setColor( QColorGroup::Background, QColor(192, 192, 192));
241 pal.setActive ( cgA );
242 pal.setInactive( cgI );
243 pal.setDisabled( cgD );
244 myWorkspace->setPalette( pal );
245 if ( !backgroundicon.isNull() ) {
246 MESSAGE("!!!DESKTOP background icon found!!!");
247 myWorkspace->setPaletteBackgroundPixmap(backgroundicon);
250 /* define standard file commands */
253 /* define operator menus for xml */
254 myOperatorMenus = new QAD_OperatorMenus(this);
255 myXmlHandler = new QAD_XmlHandler();
258 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
259 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
261 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
262 myCatalogue->GetComponentIconeList();
265 QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this );
266 tbComponent->setCloseMode( QDockWindow::Undocked );
267 addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE );
268 setDockEnabled( tbComponent, DockLeft, false );
269 setDockEnabled( tbComponent, DockRight, false );
271 myCombo = new QComboBox( FALSE, tbComponent, "comboBox" );
272 myCombo->setFocusPolicy( NoFocus );
274 tbComponent->addSeparator();
276 // PG : add ResourceManager to get function findFile !!
277 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
279 for (unsigned int ind = 0; ind < list_composants->length();ind++) {
282 /* find component icon */
283 QString iconfile = strdup(list_composants[ind].moduleicone) ;
284 QString modulename = strdup(list_composants[ind].modulename) ;
285 QString moduleusername = strdup(list_composants[ind].moduleusername) ;
287 // MESSAGE ( " MODULE = " << modulename )
288 // MESSAGE ( " MODULE icon = " << iconfile )
289 // MESSAGE ( " MODULE username = " << moduleusername )
291 if ( mapComponentName.contains( moduleusername ) ) {
292 QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
295 mapComponentName.insert( moduleusername, modulename );
297 resDir = resMgr->findFile(iconfile,modulename) ;
300 MESSAGE ( "resDir" << resDir )
301 //resDir = QAD_Tools::addSlash(resDir) ;
302 //QPixmap Icone(resDir+iconfile) ;
303 QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
304 QToolButton * toolb =
305 new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this,
306 SLOT( onButtonActiveComponent () ),tbComponent );
307 toolb->setToggleButton( true );
308 myComponentButton.append(toolb);
312 QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) +
314 //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
317 if ( !QString(list_composants[ind].modulename).isEmpty() )
318 myCombo->insertItem( strdup(list_composants[ind].moduleusername) );
322 myCombo->adjustSize();
323 connect( myCombo, SIGNAL(activated(const QString&)),
324 this, SLOT( onComboActiveComponent(const QString&) ) );
326 /* new LifeCycleCORBA client, for Engines */
327 myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service);
329 /* VSR 13/01/03 : installing global event filter for the application */
330 qApp->installEventFilter( this );
332 /* init pseudo random numbers generator */
333 QTime cTime = QTime::currentTime();
334 int secs = cTime.second() + 1;
335 for ( int s = 0; s < secs; s++ ) random();
341 QAD_Desktop::~QAD_Desktop ()
343 qApp->removeEventFilter( this );
347 myObjBrowserPopup.clear();
348 //VRV: T2.5 - add default viewer
349 myDefaultViewer.clear();
350 //VRV: T2.5 - add default viewer
351 myViewerPopup.clear();
353 myNewViewPopup.clear();
355 myToolsPopup.clear();
357 myStdActions.clear();
359 myToolBarsPopup.clear();
360 myToolBarAction.clear();
363 //NRI if (myHelpWindow)
364 // myHelpWindow->close();
366 QAD_Application::desktop = 0;
369 const int IdCut = 1001;
370 const int IdCopy = 1002;
371 const int IdPaste = 1003;
372 const int IdSelectAll = 1004;
374 #include <qkeysequence.h>
375 #define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
377 #define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
379 #include <qclipboard.h>
381 Global event filter for qapplication (VSR 13/01/03)
383 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
385 if (e->type() == 2000 ) {
386 QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
389 else if (e->type() == 2001 ) {
390 QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
393 else if ( e->type() == QEvent::ContextMenu ) {
394 QContextMenuEvent* ce = (QContextMenuEvent*)e;
395 if ( o->inherits("QRenameEdit") ) {
398 else if ( o->inherits("QLineEdit") ) {
399 QLineEdit* le = (QLineEdit*)o;
400 if ( le->parentWidget() ) {
401 if ( ( le->parentWidget()->inherits("QSpinBox") ||
402 le->parentWidget()->inherits("QSpinWidget") ||
403 le->parentWidget()->inherits("QAD_SpinBoxDbl") ) &&
405 QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" );
406 popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut );
407 popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy );
408 popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste );
409 popup->insertSeparator();
410 #if defined(Q_WS_X11)
411 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll );
413 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll );
415 bool enableCut = !le->isReadOnly() && le->hasSelectedText();
416 popup->setItemEnabled( IdCut, enableCut );
417 popup->setItemEnabled( IdCopy, le->hasSelectedText() );
418 bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty();
419 popup->setItemEnabled( IdPaste, enablePaste );
420 bool allSelected = (le->selectedText() == le->text() );
421 popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected );
423 QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() :
424 le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 );
426 int r = popup->exec( pos );
448 return QMainWindow::eventFilter( o, e );
452 Creates and initializes the standard file operations
453 such as 'New/Open/Save/SaveAs/Close' and 'Help'.
455 void QAD_Desktop::createActions()
458 /* Used for string compare */
459 const QString& aTrueQString = "true" ;
461 /* create 'standard' toolbar */
462 if ( !myStdToolBar ) {
463 myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this );
464 myStdToolBar->setCloseMode( QDockWindow::Undocked );
467 if ( !myMainMenu->count() ) {
468 /* Create main menu bar */
469 myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */
470 myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */
471 myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */
472 myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */
473 myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */
474 myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */
476 /* Applications will insert their items after 'File' 'Edit' and 'View'
477 ( 'Edit' will be inserted later )
482 /* insert logo picture to menu bar */
483 QHBox* aLogoFrm = new QHBox(this);
484 aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
485 QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
486 tr("ICON_DESK_LOGO") ));
487 QLabel* aLogoLab = new QLabel(aLogoFrm);
488 aLogoLab->setPixmap(aLogoPixmap);
489 aLogoLab->setAlignment(AlignCenter);
490 aLogoLab->setScaledContents(false);
491 myMainMenu->insertItem(aLogoFrm);
493 if ( myStdActions.isEmpty() ) {
494 /* Define standard actions. They should be inserted
495 into the list in order of their IDs.
500 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
501 QActionP* fileNewAction = new QActionP ( tr("TOT_DESK_FILE_NEW"),
502 rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) ,
503 tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this );
504 fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") );
505 fileNewAction->setEnabled ( true );
506 QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() )));
507 fileNewAction->addTo( myStdToolBar );
508 fileNewAction->addTo( &myFilePopup );
509 myStdActions.insert ( FileNewId, fileNewAction );
512 QActionP* fileOpenAction = new QActionP( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ),
513 tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this );
514 fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") );
515 fileOpenAction->setEnabled ( true );
516 QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() )));
517 fileOpenAction->addTo( myStdToolBar );
518 fileOpenAction->addTo( &myFilePopup );
519 myStdActions.insert ( FileOpenId, fileOpenAction );
522 QActionP* fileLoadAction = new QActionP( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ),
523 tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this );
524 fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") );
525 fileLoadAction->setEnabled ( true );
526 QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() )));
527 fileLoadAction->addTo( &myFilePopup );
528 myStdActions.insert ( FileLoadId, fileLoadAction );
531 QActionP* fileCloseAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ),
532 tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this );
533 fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") );
534 QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() )));
535 fileCloseAction->addTo( &myFilePopup );
536 myStdActions.insert ( FileCloseId, fileCloseAction );
539 myFilePopup.insertSeparator();
542 QActionP* fileSaveAction = new QActionP( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ),
543 tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this );
544 fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") );
545 QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() )));
546 fileSaveAction->addTo( myStdToolBar );
547 fileSaveAction->addTo( &myFilePopup );
548 myStdActions.insert ( FileSaveId, fileSaveAction );
551 QActionP* fileSaveAsAction = new QActionP( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this );
552 fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") );
553 QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ),
554 this, SLOT( onSaveAsStudy() )));
555 fileSaveAsAction->addTo( &myFilePopup );
556 myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
560 myFilePopup.insertSeparator();
563 QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
564 filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
565 filePropsAction->setEnabled(false);
566 QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() )));
567 filePropsAction->addTo( &myFilePopup );
568 myStdActions.insert ( FilePropsId, filePropsAction );
571 int id = myFilePopup.insertSeparator();
572 /* keep the position from which an application will insert its items
573 to menu 'File' at the time of customization of the desktop */
575 myFilePos = myFilePopup.indexOf( id ) + 1;
577 /* exit application */
578 QActionP* exitAction = new QActionP( "", tr("MEN_DESK_FILE_EXIT"),
580 exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") );
581 QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ),
582 this, SLOT( onExit() )));
583 exitAction->addTo( &myFilePopup );
584 myStdActions.insert ( FileExitId, exitAction );
586 /* 'Edit' actions : provided by application only */
590 /* toolbars popup menu */
591 myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
592 QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()),
593 this, SLOT(onToolBarPopupAboutToShow()) ));
596 QActionP* viewStatusBarAction = new QActionP( "",
597 tr("MEN_DESK_VIEW_STATUSBAR"),
599 viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") );
600 viewStatusBarAction->setOn( true );
601 QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() )));
602 viewStatusBarAction->addTo( &myViewPopup );
603 myStdActions.insert( ViewStatusBarId, viewStatusBarAction );
605 // myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup );
607 QActionP* SelectionPointAction = new QActionP( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true );
608 QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
609 SelectionPointAction->addTo( &mySelectionModePopup );
610 myStdActions.insert( SelectionPointId, SelectionPointAction );
612 QActionP* SelectionEdgeAction = new QActionP( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true );
613 QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
614 SelectionEdgeAction->addTo( &mySelectionModePopup );
615 myStdActions.insert( SelectionEdgeId, SelectionEdgeAction );
617 QActionP* SelectionCellAction = new QActionP( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true );
618 QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
619 SelectionCellAction->addTo( &mySelectionModePopup );
620 myStdActions.insert( SelectionCellId, SelectionCellAction );
622 QActionP* SelectionActorAction = new QActionP( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true );
623 QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
624 SelectionActorAction->addTo( &mySelectionModePopup );
625 myStdActions.insert( SelectionActorId, SelectionActorAction );
626 SelectionActorAction->setOn(true);
628 myViewPos = myViewPopup.count();
631 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
634 if(!resMgr->loadResources( "ToolsGUI", msg ))
636 //NRI QCString errMsg;
637 // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" );
638 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
642 myOperatorMenus = new QAD_OperatorMenus(this);
643 myXmlHandler = new QAD_XmlHandler();
644 ASSERT(myXmlHandler) ;
645 myXmlHandler->setMainWindow(this);
646 if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) {
647 QString language = resMgr->language( "ToolsGUI" );
648 QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" );
650 //ToolsXml = resMgr->resources("ToolsGUI") ;
651 //ToolsXml = QAD_Tools::addSlash(ToolsXml) ;
652 //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ;
653 ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml;
655 QFile file( QAD_Tools::unix2win( ToolsXml ) );
656 if ( file.exists() && file.open( IO_ReadOnly ) ) {
658 QXmlInputSource source( file );
659 QXmlSimpleReader reader;
660 reader.setContentHandler( myXmlHandler );
661 reader.setErrorHandler( myXmlHandler );
662 bool ok = reader.parse( source );
665 QMessageBox::critical( 0,
666 tr( "INF_PARSE_ERROR" ),
667 tr( myXmlHandler->errorProtocol() ) );
669 myMenusList=myXmlHandler->myMenusList;
670 myActiveMenus=myMenusList.at(0);
671 myOperatorMenus->showMenuBar(0);
672 myActiveMenus->showAllToolBars();
678 if ( myToolsPopup.count() == 0 ) {
679 myMainMenu->removeItem(5);
683 /* Viewer BackgroundColor */
684 myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup );
686 QActionP* viewerOCCAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
687 QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() )));
688 viewerOCCAction->addTo( &myViewerPopup );
689 myStdActions.insert( PrefViewerOCCId, viewerOCCAction );
691 QActionP* viewerVTKAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
692 QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() )));
693 viewerVTKAction->addTo( &myViewerPopup );
694 myStdActions.insert( PrefViewerVTKId, viewerVTKAction );
696 QActionP* graphSupervisorAction = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
697 QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() )));
698 graphSupervisorAction->addTo( &myViewerPopup );
699 myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction );
701 QActionP* viewerPlot2dAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
702 QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() )));
703 viewerPlot2dAction->addTo( &myViewerPopup );
704 myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction );
706 //VRV: T2.5 - add default viewer
707 QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" );
709 int aViewerValue = viewerValue.toInt( &ok, 10 );
710 if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX)
711 aViewerValue = VIEW_VTK;
713 myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer );
714 QActionPGroup* myQAG = new QActionPGroup ( this);
715 QActionP* viewerOCCAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
716 viewerOCCAction1->setToggleAction ( true);
717 viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC );
718 myQAG->insert( viewerOCCAction1 );
719 myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 );
721 QActionP* viewerVTKAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
722 viewerVTKAction1->setToggleAction ( true);
723 viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK );
724 myQAG->insert( viewerVTKAction1 );
725 myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 );
727 /* Remove Supervisor viewer from setting the background */
728 // QActionP* graphSupervisorAction1 = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
729 // graphSupervisorAction1->setToggleAction ( true);
730 // graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV );
731 // myQAG->insert( graphSupervisorAction1 );
732 // myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 );
734 QActionP* viewerPlot2dAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
735 viewerPlot2dAction1->setToggleAction ( true);
736 viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D );
737 myQAG->insert( viewerPlot2dAction1 );
738 myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 );
740 myQAG->addTo( &myDefaultViewer );
741 QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) )));
742 //VRV: T2.5 - add default viewer
744 myPrefPopup.insertSeparator();
746 QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this );
747 QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() )));
748 viewerTrihedronAction->addTo( &myPrefPopup );
749 myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction );
751 QActionP* consoleFontAction = new QActionP( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this );
752 QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() )));
753 consoleFontAction->addTo( &myPrefPopup );
754 myStdActions.insert( PrefConsoleFontId, consoleFontAction );
757 QActionP* multiFileSaveAction = new QActionP( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true );
758 QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() )));
759 multiFileSaveAction->setToggleAction( true );
760 QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave");
761 multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 );
762 multiFileSaveAction->addTo( &myPrefPopup );
763 myStdActions.insert( PrefMultiFileSave, multiFileSaveAction );
766 QActionP* ASCIISaveAction = new QActionP( "", tr("MEN_DESK_PREF_ASCII_SAVE"), 0, this, 0, true );
767 QAD_ASSERT(connect( ASCIISaveAction, SIGNAL(activated()), this, SLOT(onASCIISave() )));
768 ASCIISaveAction->setToggleAction( true );
769 QString ASCIISave = QAD_CONFIG->getSetting("Desktop:ASCIISave");
770 ASCIISaveAction->setOn( ASCIISave.compare( aTrueQString ) == 0 );
771 ASCIISaveAction->addTo( &myPrefPopup );
772 myStdActions.insert( PrefASCIISave, ASCIISaveAction );
775 QActionP* UndoLevelAction = new QActionP( "", tr("MEN_DESK_PREF_UNDO_LEVEL"), 0, this );
776 QAD_ASSERT(connect( UndoLevelAction, SIGNAL(activated()), this, SLOT(onUndoLevel() )));
777 UndoLevelAction->addTo( &myPrefPopup );
778 myStdActions.insert( PrefUndoLevelId, UndoLevelAction );
780 myPrefPopup.insertSeparator();
782 /* External Browser */
783 QActionP* externalBrowserAction = new QActionP( "", tr("MEN_DESK_PREF_EXTERNAL_BROWSER"), 0, this );
784 QAD_ASSERT(connect( externalBrowserAction, SIGNAL(activated()), this, SLOT(onExternalBrowser() )));
785 externalBrowserAction->addTo( &myPrefPopup );
786 myStdActions.insert( PrefExternalBrowserId, externalBrowserAction );
788 myPrefPopup.insertSeparator();
790 myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
792 QActionP* objectBrowserEntryAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true );
793 QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
794 objectBrowserEntryAction->setToggleAction(true);
795 QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn");
797 if ( AddColumn.compare( aTrueQString ) == 0 )
798 objectBrowserEntryAction->setOn(true);
800 objectBrowserEntryAction->setOn(false);
802 objectBrowserEntryAction->addTo( &myObjBrowserPopup );
803 myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction );
805 QActionP* objectBrowserValueAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true );
806 QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
807 objectBrowserValueAction->setToggleAction(true);
808 QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn");
810 if ( ValueColumn.compare( aTrueQString ) == 0 )
811 objectBrowserValueAction->setOn(true);
813 objectBrowserValueAction->setOn(false);
815 objectBrowserValueAction->addTo( &myObjBrowserPopup );
816 myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction );
818 QActionP* objectBrowserIAPPAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true );
819 QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
820 objectBrowserIAPPAction->setToggleAction(true);
821 QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP");
823 if ( showIAPP.compare( aTrueQString ) == 0 )
824 objectBrowserIAPPAction->setOn(true);
826 objectBrowserIAPPAction->setOn(false);
828 objectBrowserIAPPAction->addTo( &myObjBrowserPopup );
829 myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction );
831 /* Chronological sorting of shapes on the entry creation */
832 QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true );
833 QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
834 objectBrowserCHRONO_SORTAction->setToggleAction(true);
835 QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:ChronologicalSort");
837 if ( showSORT.compare( aTrueQString ) == 0 )
838 objectBrowserCHRONO_SORTAction->setOn(true) ;
840 objectBrowserCHRONO_SORTAction->setOn(false) ;
842 objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup );
843 myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ;
845 /* Show or don't Show UseCase browser */
846 QActionP* objectBrowserShowUseCaseAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_SHOW_USECASE"), 0, this, 0, true );
847 QAD_ASSERT(connect( objectBrowserShowUseCaseAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
848 objectBrowserShowUseCaseAction->setToggleAction(true);
849 QString showUseCase = QAD_CONFIG->getSetting("ObjectBrowser:ShowUseCaseBrowser");
851 if ( showUseCase.compare( aTrueQString ) == 0 )
852 objectBrowserShowUseCaseAction->setOn(true) ;
854 objectBrowserShowUseCaseAction->setOn(false) ;
856 objectBrowserShowUseCaseAction->addTo( &myObjBrowserPopup );
857 myStdActions.insert( PrefObjectBrowserShowUseCaseId, objectBrowserShowUseCaseAction ) ;
859 /* Resize or don't resize columns automatically */
860 QActionP* objectBrowserNoAutoSizeAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_NO_AUTOSIZE"), 0, this, 0, true );
861 QAD_ASSERT(connect( objectBrowserNoAutoSizeAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
862 objectBrowserNoAutoSizeAction->setToggleAction(true);
863 QString noAutoSize = QAD_CONFIG->getSetting("ObjectBrowser:NoAutoSizeColumns");
865 if ( noAutoSize.compare( aTrueQString ) == 0 )
866 objectBrowserNoAutoSizeAction->setOn(true) ;
868 objectBrowserNoAutoSizeAction->setOn(false) ;
870 objectBrowserNoAutoSizeAction->addTo( &myObjBrowserPopup );
871 myStdActions.insert( PrefObjectBrowserNoAutoSizeColumnsId, objectBrowserNoAutoSizeAction ) ;
873 myPrefPopup.insertSeparator();
875 QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this );
876 QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() )));
877 dirAction->addTo( &myPrefPopup );
878 myStdActions.insert( PrefDirsId, dirAction );
880 myPrefPopup.insertSeparator();
882 QActionP* saveAction = new QActionP( "", tr("MEN_DESK_PREF_SAVE"), 0, this );
883 QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() )));
884 saveAction->addTo( &myPrefPopup );
885 myStdActions.insert( PrefSaveId, saveAction );
887 /* 'Window' actions */
890 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
892 QActionP* viewOCCAction = new QActionP( "", tr("MEN_DESK_VIEW_OCC"), ALT+Key_O, this );
893 QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
894 viewOCCAction->addTo( &myNewViewPopup );
895 myStdActions.insert( ViewOCCId, viewOCCAction );
897 QActionP* viewVTKAction = new QActionP( "", tr("MEN_DESK_VIEW_VTK"), ALT+Key_K, this );
898 QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
899 viewVTKAction->addTo( &myNewViewPopup );
900 myStdActions.insert( ViewVTKId, viewVTKAction );
902 QActionP* viewPlot2dAction = new QActionP( "", tr("MEN_DESK_VIEW_PLOT2D"), ALT+Key_P, this );
903 QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
904 viewPlot2dAction->addTo( &myNewViewPopup );
905 myStdActions.insert( ViewPlot2dId, viewPlot2dAction );
907 // QActionP* windowNew3dAction = new QActionP( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */
908 /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this );
909 windowNew3dAction->addTo( &myWindowPopup );
910 QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this ,
911 SLOT( onNewWindow3d() )));
912 myStdActions.insert( WindowNew3dId, windowNew3dAction );
918 QActionP* windowCascadeAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ),
919 tr("MEN_DESK_WINDOW_CASCADE"), 0, this );
920 windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") );
921 QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this,
922 SLOT( onCascade() )));
923 myStdActions.insert( WindowCascadeId, windowCascadeAction );
926 QActionP* windowTileAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ),
927 tr("MEN_DESK_WINDOW_TILE"), 0, this );
928 windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") );
929 QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() )));
930 myStdActions.insert( WindowTileId, windowTileAction );
932 QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()),
933 this, SLOT(onWindowPopupAboutToShow()) ));
937 QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
938 helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
939 QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
940 this, SLOT( onHelpContents() )));
941 helpContentsAction->addTo( &myHelpPopup );
942 myStdActions.insert( HelpContentsId , helpContentsAction );
944 id = myHelpPopup.insertSeparator();
947 // NRI : Temporary commented
949 // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
950 // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
951 // QAD_ASSERT(connect( helpContentsActionGUI, SIGNAL(activated()),
952 // this, SLOT( onHelpContentsGUI() )));
953 // helpContentsActionGUI->addTo( &myHelpPopup );
954 // myStdActions.insert( HelpContentsId , helpContentsActionGUI );
957 QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
958 helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
959 QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
960 this, SLOT( onHelpContentsTUI() )));
961 helpContentsActionTUI->addTo( &myHelpPopup );
962 myStdActions.insert( HelpContentsId , helpContentsActionTUI );
965 // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
966 // helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") );
967 // QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() )));
968 // helpSearchAction->addTo( &myHelpPopup );
969 // myStdActions.insert( HelpSearchId, helpSearchAction );
972 // QActionP* helpWhatsThisAction = new QActionP( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this );
973 // helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" ));
974 // QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() )));
975 // helpWhatsThisAction->addTo( &myHelpPopup );
976 // myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction );
977 // (void)QWhatsThis::whatsThisButton( myStdToolBar );
979 id = myHelpPopup.insertSeparator();
980 myHelpPos = myHelpPopup.indexOf( id );
983 QActionP* helpAboutAction = new QActionP( "", tr("MEN_DESK_HELP_ABOUT"), 0, this );
984 helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") );
985 QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
986 helpAboutAction->addTo( &myHelpPopup );
987 myStdActions.insert(HelpAboutId, helpAboutAction );
993 Adds the given application into the list of supported applications
995 void QAD_Desktop::addApplication(QAD_Application* app)
997 /* add only if is not already in the list */
998 if ( myApps.findRef( app ) == -1 )
1000 myApps.append( app );
1002 /* set activation/deactivation listener */
1003 QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)),
1004 this, SLOT(onActivateApp(QAD_Application*))) );
1006 QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)),
1007 this, SLOT(onDeactivateApp(QAD_Application*))) );
1012 Displays the control panel of the application.
1013 This function is called when the desktop is shown first time.
1015 void QAD_Desktop::showDesktop()
1021 Closes Desktop. If <forceClose> is true query for exit will be skipped.
1023 void QAD_Desktop::closeDesktop( bool forceClose )
1026 myQueryClose = false;
1031 Puts the message to the status bar
1033 void QAD_Desktop::putInfo ( const QString& msg )
1036 //NRI : bug 1209. message is now displayed during 3000 ms
1037 myStatusBar->message ( msg, 3000 );
1041 Puts the message to the status bar for ms milli-seconds
1043 void QAD_Desktop::putInfo ( const QString& msg, int ms )
1046 myStatusBar->message ( msg, ms );
1050 Returns the standard toolbar
1052 QMenuBar* QAD_Desktop::getMainMenuBar() const
1058 Returns the standard toolbar
1060 QToolBar* QAD_Desktop::getStdToolBar() const
1062 return myStdToolBar;
1066 Updates desktop panel (menu, toolbar and status bar) according to current state of
1067 the application. Calls update() for the active application.
1068 The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components
1069 will be changed according to new active application.
1070 This function is called after activating new study, closing current study etc.
1072 void QAD_Desktop::updateDesktop( UpdateCommand cmd )
1075 updateToolBars( cmd );
1076 updateStatusBar( cmd );
1081 Updates the desktop caption
1083 void QAD_Desktop::updateCaption( UpdateCommand cmd )
1085 if ( cmd == ActivateApp )
1086 { /* application's icon and title */
1087 setIcon( myActiveApp->getApplicationIcon() );
1088 setCaption( myActiveApp->getApplicationName() );
1091 { /* default icon and title */
1092 setIcon( myDefaultIcon );
1093 qApp->processEvents();
1094 setCaption( myDefaultTitle );
1099 Updates status bar when a new application becomes current
1101 void QAD_Desktop::updateStatusBar( UpdateCommand cmd )
1105 bool activate = ( cmd == ActivateApp );
1106 myActiveApp->updateStatusBar ( myStatusBar, activate );
1111 Updates toolbars according to current active application.
1112 This function is called from updateDesktop().
1114 void QAD_Desktop::updateToolBars( UpdateCommand cmd )
1118 bool activate = ( cmd == ActivateApp );
1119 myActiveApp->updateToolBars ( activate );
1124 Updates main menu bar of the application when application is activated
1126 This function is called by updateDesktop()
1128 void QAD_Desktop::updateMenu( UpdateCommand cmd )
1132 bool activate = ( cmd == ActivateApp );
1133 myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos );
1134 myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos );
1135 myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos );
1136 myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos );
1137 myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos );
1140 Since 'Edit' popup is completely customized by applications
1141 desktop doesn't show it in main menubar without the active
1142 application and we insert/remove this popup from the menubar
1143 when activating/deactivating applications.
1145 We can't have 'Edit' popup be customized by an application
1146 via UpdateMainMenu() method because applications may insert
1147 its items to the menubar only AFTER 'View' item ( this fact
1148 is respected by myMainMenuPos ) and the possibility of an
1149 application to add its items into any arbitrary positions of
1150 the main menubar requires a bit sophisticated implementation,
1151 so we decided to avoid it, sorry :-(.
1153 #if defined( DEBUG )
1155 /* applications MUST clear 'Edit' after themselves */
1156 QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() );
1159 if ( activate ) /* insert after 'File' item */
1160 myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 );
1162 myMainMenu->removeItem( 3 );
1167 Returns icon file name used by the application
1169 const QPixmap& QAD_Desktop::getDefaultIcon() const
1171 static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD",
1172 tr("ICON_DESK_DEFAULTICON") ));
1173 return defaultPixmap;
1177 Returns name of the application used as the title of desktop panel
1179 const QString& QAD_Desktop::getDefaultTitle() const
1181 static QString defaultTitle ( tr("DESK_DEFAULTTITLE") );
1182 return defaultTitle;
1186 Returns default name of new studies
1188 const QString& QAD_Desktop::getDefaultStudyName() const
1190 static QString defaultStudyName( tr("DESK_DEFAULTDOC") );
1191 return defaultStudyName;
1195 Returns next name for new study
1197 QString QAD_Desktop::getNewStudyName()
1200 number.sprintf( "%d", ++myCntUntitled );
1201 return ( getDefaultStudyName() + number );
1205 Searches QAD_Study corresponding to <study>, returns NULL if fails
1207 QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy )
1209 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1210 QList<QAD_Study> studies;
1211 studies.setAutoDelete( false );
1212 studies = app->getStudies();
1213 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
1214 if ( study->getStudyDocument()->_is_equivalent( theStudy ) )
1222 Gets value of max undo level for SALOMEDS::Study's from preferences
1224 int QAD_Desktop::getUndoLevel()
1226 static int MAX_UNDO = 10;
1227 int anUndoLevel = MAX_UNDO;
1228 QString aLevel = QAD_CONFIG->getSetting("Desktop:UndoLevel");
1229 if(!aLevel.isEmpty()) anUndoLevel = aLevel.toInt();
1234 Returns current active application
1236 QAD_Application* QAD_Desktop::getActiveApp() const
1242 Returns current active study
1244 QAD_Study* QAD_Desktop::getActiveStudy() const
1246 return myActiveStudy;
1252 QWorkspaceP* QAD_Desktop::getMainFrame() const
1258 Find or load Engine, given a container name and an engine name
1260 Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
1261 const char *componentName)
1263 Engines::Component_var eng =
1264 myEnginesLifeCycle->FindOrLoad_Component(containerName,
1269 QString QAD_Desktop::getComponentName(const char *componentUserName)
1271 if ( mapComponentName.contains(componentUserName) )
1272 return mapComponentName[ componentUserName ] ;
1277 QString QAD_Desktop::getComponentUserName(const char *componentName)
1279 QMap<QString,QString>::Iterator it;
1280 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
1281 if (it.data() == componentName )
1287 // gets application Help Window (and creates if necessary)
1289 // QAD_HelpWindow* QAD_Desktop::getHelpWindow()
1291 // if (!myHelpWindow) {
1292 // myHelpWindow = new QAD_HelpWindow();
1294 // QMap<QString,QString>::Iterator it;
1295 // for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
1299 // // look for index.html and set homeDir
1300 // // 1. $(MODULE_ROOT_DIR)/doc/index.html
1301 // // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
1302 // // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
1304 // if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
1305 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
1306 // if ( QFileInfo( root + "index.html" ).exists() ) {
1307 // helpContext( root + "index.html", "" );
1310 // root = QAD_Tools::addSlash( root + "html" );
1311 // if ( QFileInfo( root + "index.html" ).exists() ) {
1312 // helpContext( root + "index.html", "" );
1315 // root = QAD_Tools::addSlash( root + "html" );
1316 // if ( QFileInfo( root + "index.html" ).exists() ) {
1317 // helpContext( root + "index.html", "" );
1324 // connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
1326 // return myHelpWindow;
1330 Called when desktop is closing
1332 void QAD_Desktop::closeEvent ( QCloseEvent* e )
1334 bool doClose = true;
1335 if ( myQueryClose ) {
1336 doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"),
1337 tr("QUE_DESK_EXIT"), tr ("BUT_OK"),
1338 tr ("BUT_CANCEL"), QAD_YES,
1339 QAD_NO, QAD_NO ) == QAD_YES;
1343 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1344 QList<QAD_Study>& studies = app->getStudies();
1345 for(QAD_Study* study = studies.first(); study != 0; study = studies.next()) {
1346 if(myQueryClose && study->getStudyDocument()->IsModified()) {
1347 SALOMEGUI_CloseDlg aDlg( this );
1348 switch ( aDlg.exec() ) {
1350 if ( !onSaveStudy( study ) ) {
1351 putInfo( tr("INF_CANCELLED") );
1362 putInfo( tr("INF_CANCELLED") );
1370 myQueryClose = true;
1371 doClose ? e->accept() : e->ignore();
1375 Called when desktop is resized
1377 void QAD_Desktop::resizeEvent( QResizeEvent* e )
1379 QMainWindow::resizeEvent( e );
1380 myWorkspace->setGeometry( 1,1, centralWidget()->width()-2,
1381 centralWidget()->height()-2 );
1386 Terminates the application.
1388 void QAD_Desktop::onExit()
1393 /************************************************************************
1395 *************************************************************************/
1399 If several application are supported it displays dialog window
1400 to choose type of study.
1402 void QAD_Desktop::createStudy(){
1405 void QAD_Desktop::onNewStudy()
1407 unsigned numApps = myApps.count();
1410 onNewStudy ( myApps.at(0) );
1411 else { /* select the type of application for new study */
1412 Desktop_AppSelectionDlg selDlg( this, myApps );
1413 if ( selDlg.exec() == QDialog::Accepted ) {
1414 onNewStudy ( selDlg.selectedApp() );
1417 } else { /* no applications available in desktop */
1418 QAD_MessageBox::error1( this,
1420 tr("ERR_APP_NOAPP"),
1426 Creates new study for the given application.
1427 Calls the respective function of the application class.
1429 void QAD_Desktop::onNewStudy( QAD_Application* app )
1433 /* create new study of the specific app */
1434 putInfo ( tr ("INF_DOC_CREATING") );
1435 QAD_Study* newStudy = app->newStudy();
1438 /* can't create new study */
1439 QAD_MessageBox::error1( this, tr("ERR_ERROR"),
1440 tr("ERR_DOC_CANTCREATE"),
1443 putInfo ( tr("INF_READY") );
1447 Loads the existing study.
1449 void QAD_Desktop::onLoadStudy()
1451 QString name, studyname, ext;
1453 SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE);
1455 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1456 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1457 ASSERT(! CORBA::is_nil(myStudyMgr));
1458 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1459 for (unsigned int ind = 0; ind < List->length();ind++) {
1460 studyname = List[ind];
1461 aDlg->ListComponent->insertItem( studyname );
1464 int retVal = aDlg->exec();
1465 studyname = aDlg->ListComponent->currentText();
1467 if (retVal == QDialog::Rejected)
1470 if ( studyname.isNull() || studyname.isEmpty() )
1474 name.replace( QRegExp(":"), "/" );
1477 Try to associate an application to the opened study.
1478 Assumed that the association study<->application is unique.
1480 bool appFound = false;
1481 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1482 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1484 /* application found */
1485 if ( app->isStudyOpened( name ) )
1487 /* already opened: prompt for reopen */
1488 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1489 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1490 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1491 QAD_NO ) == QAD_NO )
1493 putInfo ( tr("INF_READY") );
1496 /* now the study is closed to be re-opened */
1497 //don't ask user to remove study permanently
1498 if (app->getStudyByName ( name ) != NULL)
1499 onCloseStudy ( app->getStudyByName ( name ), false );
1500 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1501 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1505 /* open the study */
1506 QAD_Study* openStudy = app->loadStudy( studyname );
1508 QAD_MessageBox::error1( this,
1510 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1517 QAD_MessageBox::error1( this,
1519 tr("ERR_DOC_UNKNOWNTYPE"),
1522 putInfo ( tr("INF_READY") );
1527 QAD_Study* QAD_Desktop::loadStudy(QString theStudyName) {
1528 QString studyname("");
1530 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1531 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1532 ASSERT(! CORBA::is_nil(myStudyMgr));
1534 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1535 for (unsigned int ind = 0; ind < List->length();ind++) {
1536 if (theStudyName == QString(List[ind])) {
1537 studyname = theStudyName;
1541 if (studyname == "") {
1544 bool appFound = false;
1545 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1547 QAD_Study* openStudy = app->loadStudy( studyname );
1549 // if (myActiveApp == 0)
1550 //myActiveApp = app;
1560 Opens the existing study.
1561 Displays select file dialog and calls corresponding function of
1563 (application is defined according to extension of selected file).
1565 void QAD_Desktop::onOpenStudy()
1569 /* Select a file to open */
1570 name = selectFileName ( true );
1571 if ( name.isNull() || name.isEmpty() )
1574 // Workaround for non-existent files
1576 if (!fi.exists() || !fi.isFile()) {
1577 QAD_MessageBox::error1 ( this, tr("ERR_ERROR"),
1578 tr("ERR_DOC_CANTOPEN") +": " + name,
1583 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1584 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1585 ASSERT(! CORBA::is_nil(myStudyMgr));
1586 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1587 for (unsigned int ind = 0; ind < List->length();ind++) {
1588 QString NameExistingStudy(List[ind]);
1589 QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, true );
1590 if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) {
1591 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1592 tr("QUE_DOC_ALREADYEXIST").arg( name ),
1593 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1594 QAD_NO ) == QAD_NO )
1596 putInfo ( tr("INF_READY") );
1608 Try to associate an application to the opened study.
1609 Assumed that the association study<->application is unique.
1611 bool appFound = false;
1612 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1613 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1615 QString ext = QAD_Tools::getFileExtensionFromPath ( name );
1616 if ( app->getStudyExtension() == ext )
1618 /* application found */
1619 if ( app->isStudyOpened( name ) )
1621 /* already opened: prompt for reopen */
1622 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1623 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1624 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1625 QAD_NO ) == QAD_NO )
1627 putInfo ( tr("INF_READY") );
1630 /* now the study is closed to be re-opened */
1631 //don't ask user to remove study permanently
1632 if (app->getStudyByName ( name ) != NULL)
1633 onCloseStudy ( app->getStudyByName ( name ), false );
1634 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1635 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1639 /* open the study */
1640 QAD_Study* openStudy = app->openStudy( name );
1642 QAD_MessageBox::error1( this,
1644 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1646 } else if (myActiveComp != "") {
1647 QApplication::setOverrideCursor( Qt::waitCursor );
1648 loadComponentData(mapComponentName[myActiveComp]);
1649 openStudy->updateObjBrowser(true);
1650 QApplication::restoreOverrideCursor();
1658 QAD_MessageBox::error1( this,
1660 tr("ERR_DOC_UNKNOWNTYPE"),
1663 putInfo ( tr("INF_READY") );
1666 bool QAD_Desktop::loadComponentData( const QString& compName )
1668 // Open component's data in active study if any
1669 MESSAGE("loadComponentData(): Opening " << compName << " component data ")
1670 if (!myActiveStudy) {
1671 MESSAGE("loadComponentData(): No active study exists")
1675 Engines::Component_var comp ;
1676 if ( compName.compare("SUPERV") == 0 ) {
1677 comp = getEngine( "SuperVisionContainer", compName) ;
1680 /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) :
1681 getEngine( "FactoryServerPy", compName);
1683 comp = getEngine( "FactoryServer", compName);
1684 if ( comp->_is_nil() )
1685 comp = getEngine( "FactoryServerPy", compName);
1688 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1689 SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
1691 if (!SCO->_is_nil()) {
1692 if (!CORBA::is_nil(comp)) {
1693 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
1694 if (!CORBA::is_nil(driver)) {
1695 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
1696 if (!CORBA::is_nil(B)) {
1697 // QAD_Operation* op = new QAD_Operation( myActiveStudy );
1699 B->LoadWith(SCO,driver);
1705 MESSAGE("loadComponentData(): Driver is null");
1709 MESSAGE("loadComponentData(): Engine is null");
1713 MESSAGE("loadComponentData(): SComponent is null");
1721 Saves the active study
1723 bool QAD_Desktop::onSaveStudy()
1725 return onSaveStudy ( myActiveStudy );
1729 Saves the given study
1731 bool QAD_Desktop::onSaveStudy( QAD_Study* study )
1733 if ( !study ) return true;
1735 if ( !study->isSaved() )
1736 return onSaveAsStudy ( study );
1738 /* saving study... */
1739 QAD_Application* app = study->getApp();
1740 QAD_ASSERT_DEBUG_ONLY ( app );
1741 putInfo ( tr("INF_DOC_SAVING") + study->getTitle() );
1742 if ( !app->saveStudy( study ) )
1744 putInfo( tr("INF_CANCELLED") );
1749 putInfo ( tr("INF_DOC_SAVED").arg( "" ) );
1754 Saves the active study under a new name
1756 bool QAD_Desktop::onSaveAsStudy()
1758 return onSaveAsStudy( myActiveStudy );
1762 Saves the given study under a new name
1764 bool QAD_Desktop::onSaveAsStudy( QAD_Study* study )
1766 if ( !study ) return true;
1768 /* Save study in a format supported by its application
1770 QAD_Application* app = study->getApp();
1771 QAD_ASSERT_DEBUG_ONLY ( app );
1773 /* Select a file where to save
1775 QString name = selectFileName ( false );
1776 if ( name.isNull() || name.isEmpty() )
1778 putInfo( tr("INF_CANCELLED") );
1784 putInfo ( tr("INF_DOC_SAVING") + name );
1785 if ( !app->saveAsStudy( study, name ) ) {
1786 /* can't save the file */
1787 QAD_MessageBox::error1( this,
1789 tr("ERR_DOC_CANTWRITE") + "\n" + name,
1792 return false; /* cannot save */
1794 putInfo ( tr("INF_DOC_SAVED").arg( name ) );
1795 return true; /* saved ok */
1799 Closes the active study
1801 bool QAD_Desktop::onCloseStudy()
1803 bool close = this->onCloseStudy ( myActiveStudy, true );
1804 if ( close && !myXmlHandler->myIdList.IsEmpty() ) {
1807 myCombo->setCurrentItem (0);
1808 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
1809 aButton->setOn(false);
1816 Closes the given study and ask user to remove study
1817 from the study manager permanently
1819 bool QAD_Desktop::onCloseStudy( QAD_Study* study )
1821 return onCloseStudy( study, true );
1825 Closes the given study and ask user to remove study
1826 from the study manager permanently if ask is equal true
1828 bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask )
1830 bool removePerm = false;
1834 SALOMEGUI_CloseDlg aDlg( this );
1835 int res = aDlg.exec();
1840 //if ( study->isModified() )
1841 if ( !onSaveStudy( study ) ) {
1842 putInfo( tr("INF_CANCELLED") );
1855 putInfo( tr("INF_CANCELLED") );
1859 /* close active component */
1860 if (!myXmlHandler->myIdList.IsEmpty())
1864 myCombo->setCurrentItem (0);
1865 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() )
1866 aButton->setOn(false);
1867 qApp->processEvents();
1869 /* close the study */
1870 return study->getApp()->closeStudy( study, removePerm );
1873 // Displays study properties dialog box
1874 void QAD_Desktop::onStudyProperties()
1876 if (myActiveStudy) {
1878 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1881 SALOMEGUI_StudyPropertiesDlg aDlg(this);
1882 int res = aDlg.exec();
1884 if ( res == QDialog::Accepted && aDlg.isChanged() )
1889 // T2.12 - add the word "locked" to study frame captions if <myActiveStudy> study is locked
1890 myActiveStudy->updateCaptions();
1896 locate all windows in cascade mode
1899 void QAD_Desktop::onCascade()
1901 myWorkspace->cascade();
1902 int w = myWorkspace->width();
1903 int h = myWorkspace->height();
1904 QWidgetList wList = myWorkspace->windowList();
1905 QWidgetListIt it(wList);
1907 for(;it.current(); ++it)
1908 it.current()->resize((int)(0.8*w), (int)(0.8*h));
1912 // called when help window closed
1914 // void QAD_Desktop::onHelpWindowClosed()
1916 // myHelpWindow = 0;
1920 Called when 'view status bar' option
1923 void QAD_Desktop::onViewStatusBar()
1925 bool show = myStdActions.at( ViewStatusBarId )->isOn();
1926 if ( show == myStatusBar->isVisible() )
1929 myStatusBar->show();
1931 myStatusBar->hide();
1935 Called when View/Toolbars popup menu is about to show
1937 void QAD_Desktop::onToolBarPopupAboutToShow()
1939 myToolBarAction.clear();
1940 myToolBarsPopup.clear();
1941 QPtrList<QDockWindow> wlist = dockWindows();
1942 for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) {
1943 if ( w->inherits( "QToolBar" ) ) {
1944 QToolBar* tb = ( QToolBar* )w;
1945 if ( appropriate( tb ) ) {
1946 ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true );
1947 a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") );
1948 a->setOn( tb->isVisible() );
1949 QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) );
1950 QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) );
1951 a->addTo( &myToolBarsPopup );
1952 myToolBarAction.append( a );
1959 Called on 'View\Selection Mode'
1961 void QAD_Desktop::onSelectionMode()
1963 const QActionP* obj = (QActionP*) sender();
1965 int SelectionMode = 4;
1967 if ( obj == myStdActions.at(SelectionActorId) ) {
1969 if ( obj->isOn() ) {
1970 myStdActions.at(SelectionCellId)->setOn(false);
1971 myStdActions.at(SelectionEdgeId)->setOn(false);
1972 myStdActions.at(SelectionPointId)->setOn(false);
1974 myStdActions.at(SelectionActorId)->setOn(true);
1976 } else if ( obj == myStdActions.at(SelectionCellId) ) {
1978 if ( obj->isOn() ) {
1979 myStdActions.at(SelectionActorId)->setOn(false);
1980 myStdActions.at(SelectionEdgeId)->setOn(false);
1981 myStdActions.at(SelectionPointId)->setOn(false);
1983 myStdActions.at(SelectionActorId)->setOn(true);
1985 } else if ( obj == myStdActions.at(SelectionEdgeId) ) {
1987 if ( obj->isOn() ) {
1988 myStdActions.at(SelectionActorId)->setOn(false);
1989 myStdActions.at(SelectionCellId)->setOn(false);
1990 myStdActions.at(SelectionPointId)->setOn(false);
1992 myStdActions.at(SelectionActorId)->setOn(true);
1994 } else if ( obj == myStdActions.at(SelectionPointId) ) {
1996 if ( obj->isOn() ) {
1997 myStdActions.at(SelectionEdgeId)->setOn(false);
1998 myStdActions.at(SelectionCellId)->setOn(false);
1999 myStdActions.at(SelectionActorId)->setOn(false);
2001 myStdActions.at(SelectionActorId)->setOn(true);
2004 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2005 sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode );
2007 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2008 Sel->SetSelectionMode( SelectionMode );
2012 Called on 'View\Selection Mode'
2014 void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly)
2019 myStdActions.at(SelectionEdgeId)->setOn(false);
2020 myStdActions.at(SelectionCellId)->setOn(false);
2021 myStdActions.at(SelectionActorId)->setOn(false);
2022 myStdActions.at(SelectionPointId)->setOn(true);
2027 myStdActions.at(SelectionActorId)->setOn(false);
2028 myStdActions.at(SelectionCellId)->setOn(false);
2029 myStdActions.at(SelectionPointId)->setOn(false);
2030 myStdActions.at(SelectionEdgeId)->setOn(true);
2035 myStdActions.at(SelectionActorId)->setOn(false);
2036 myStdActions.at(SelectionEdgeId)->setOn(false);
2037 myStdActions.at(SelectionPointId)->setOn(false);
2038 myStdActions.at(SelectionCellId)->setOn(true);
2043 myStdActions.at(SelectionCellId)->setOn(false);
2044 myStdActions.at(SelectionEdgeId)->setOn(false);
2045 myStdActions.at(SelectionPointId)->setOn(false);
2046 myStdActions.at(SelectionActorId)->setOn(true);
2051 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2052 if ( sf->getTypeView() == VIEW_VTK ) {
2053 sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode );
2054 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2055 Sel->SetSelectionMode( mode, activeCompOnly );
2061 Called on 'Window\NewWindow3d'
2063 void QAD_Desktop::onNewWindow3d()
2067 //VRV: T2.5 - add default viewer
2068 QApplication::restoreOverrideCursor();
2069 SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE);
2070 int r = choice->exec();
2073 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer()));
2075 //VRV: T2.5 - add default viewer
2077 const QActionP* obj = (QActionP*) sender();
2078 if ( obj == myStdActions.at(ViewOCCId) ) {
2079 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0));
2080 } else if ( obj == myStdActions.at(ViewVTKId) ) {
2081 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1));
2082 } else if ( obj == myStdActions.at(ViewPlot2dId) ) {
2083 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3));
2088 // Helps to execute command
2089 class RunBrowser: public QThread {
2092 RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
2093 myApp(theApp), myParams(theParams), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {};
2099 if ( !myApp.isEmpty())
2101 aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
2102 myStatus = system(aCommand);
2105 QCustomEvent* ce2000 = new QCustomEvent (2000);
2106 postEvent (qApp, ce2000);
2110 if( myStatus != 0 || myApp.isEmpty())
2113 aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
2114 myStatus = system(aCommand);
2117 QCustomEvent* ce2001 = new QCustomEvent (2001);
2118 postEvent (qApp, ce2001);
2132 Called on 'help\contents'
2134 void QAD_Desktop::onHelpContents()
2135 { if (myActiveComp == "")
2136 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2141 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2142 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2143 if ( QFileInfo( root + "index.html" ).exists() ) {
2146 QMessageBox::warning( this, tr("WRN_WARNING"),
2147 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2152 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2153 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2154 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2156 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2161 Called on 'help\GUI Reference'
2163 void QAD_Desktop::onHelpContentsGUI()
2169 // if ( (dir = getenv("KERNEL_ROOT_DIR")) ) {
2170 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" );
2171 // root = QAD_Tools::addSlash( root + "guihtml" );
2172 // root = QAD_Tools::addSlash( root + "guihtml" );
2173 // if ( QFileInfo( root + "salomedoc.html" ).exists() ) {
2177 // if ( root.isEmpty() ) {
2178 // if ( QFileInfo( "/usr/local/doc/guihtml/salomedoc.html" ).exists() ) {
2179 // homeDir = "/usr/local/doc/guihtml/";
2182 // if ( root.isEmpty() )
2184 // QString helpFile = QFileInfo( homeDir + "salomedoc.html" ).absFilePath();
2185 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2186 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2188 // RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2194 Called on 'help\TUI Reference'
2196 void QAD_Desktop::onHelpContentsTUI()
2198 if (myActiveComp == "")
2199 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2204 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2205 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2206 if ( QFileInfo( root + "index.html" ).exists() ) {
2209 QMessageBox::warning( this, tr("WRN_WARNING"),
2210 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2215 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2217 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2218 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2220 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2225 // Called on 'help\search'
2227 // void QAD_Desktop::onHelpSearch()
2230 // myActiveApp->helpSearch();
2236 Called on 'help\about'
2238 void QAD_Desktop::onHelpAbout()
2241 myActiveApp->helpAbout();
2248 Activates the application and its active study
2250 void QAD_Desktop::onActivateApp( QAD_Application* activeApp )
2252 bool appChanged = ( activeApp != myActiveApp );
2255 updateDesktop( DeactivateApp );
2259 myActiveApp = activeApp;
2260 myActiveStudy = myActiveApp->getActiveStudy();
2270 updateDesktop( ActivateApp );
2271 updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp );
2277 Called when the last study is removed from
2278 the application 'app'.
2280 void QAD_Desktop::onDeactivateApp(QAD_Application* app)
2282 if ( app && app == myActiveApp )
2287 Enables/disables standard actions
2289 void QAD_Desktop::updateActions()
2291 myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
2292 myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
2293 myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
2294 myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
2295 // myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
2296 // myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
2297 // myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL );
2298 // myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL );
2300 // myToolsPopup.setEnabled ( myActiveStudy != NULL );
2301 // myPrefPopup.setEnabled ( myActiveStudy != NULL );
2303 mySelectionModePopup.setEnabled ( myActiveStudy != NULL );
2306 myStdActions.at( ViewOCCId )->setEnabled( myActiveStudy != NULL );
2307 myStdActions.at( ViewVTKId )->setEnabled( myActiveStudy != NULL );
2308 myStdActions.at( ViewPlot2dId )->setEnabled( myActiveStudy != NULL );
2313 Called when 'Window' popup is about to show
2315 void QAD_Desktop::onWindowPopupAboutToShow()
2317 /* add cascade/tile items */
2318 myWindowPopup.clear();
2321 //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup );
2322 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
2323 //myStdActions.at( WindowNew3dId )->setEnabled( true );
2324 myWindowPopup.setItemEnabled( WindowNew3dId, true );
2326 myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup );
2327 myStdActions.at( WindowCascadeId )->setEnabled( true );
2328 myStdActions.at( WindowTileId )->addTo( &myWindowPopup );
2329 myStdActions.at( WindowTileId )->setEnabled( true );
2331 /* add names of opened studies */
2332 QWidgetList windows = myWorkspace->windowList();
2333 if ( windows.isEmpty() )
2335 //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false );
2336 myWindowPopup.setItemEnabled( WindowNew3dId, false );
2338 myStdActions.at( WindowCascadeId )->setEnabled( false );
2339 myStdActions.at( WindowTileId )->setEnabled( false );
2343 myWindowPopup.insertSeparator();
2344 for ( int i = 0; i < int(windows.count()); ++i )
2346 int id = myWindowPopup.insertItem( windows.at(i)->caption(),
2347 this, SLOT( onWindowsPopupActivated( int ) ) );
2348 myWindowPopup.setItemParameter( id, i );
2349 myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) );
2351 QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this,
2352 SLOT(onWindowsPopupStatusText( int )) ));
2357 Called when the item with 'id' of 'Windows' popup
2360 void QAD_Desktop::onWindowsPopupStatusText( int id )
2362 int cascadeId = myWindowPopup.idAt( 0 );
2363 int tileId = myWindowPopup.idAt( 1 );
2364 if ( id == cascadeId || id == tileId )
2366 putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
2370 Called when user wants to activate a child window with 'wid'
2373 void QAD_Desktop::onWindowsPopupActivated( int wid )
2375 QWidget* w = myWorkspace->windowList().at( wid );
2376 if ( w ) w->setFocus();
2380 Selects a file name when opening or saving files.
2381 The basic implementation just uses the standard
2383 Please redefine if another behaviour is required.
2385 QString QAD_Desktop::selectFileName ( bool open )
2387 QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true );
2391 QStringList filters;
2394 // All the file types of the supported applications
2396 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
2398 filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2399 "(*." + app->getStudyExtension() + ")";
2403 QAD_ASSERT_DEBUG_ONLY ( myActiveStudy );
2404 if (myActiveStudy) {
2405 // get file name of active study
2406 name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() );
2407 // get path to the active study file
2408 dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
2410 QAD_ASSERT_DEBUG_ONLY ( !name.isNull() );
2411 // the file types supported by the active application
2412 filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2413 "(*." + myActiveApp->getStudyExtension() + ")" ;
2415 if (!dir.isEmpty()) {
2416 // when saving document ("Save As" command) - to get dir from active study filename
2417 // for new documents - to use last opened directory
2420 fd->setSelection( name );
2421 fd->setFilters( filters );
2424 QString filename = fd->selectedFile();
2426 qApp->processEvents();
2431 Closes all the studies of 'app'. Returns
2432 'true' if thay are closed OK, 'false' at least
2433 one can't be closed or user cancel the closure.
2435 bool QAD_Desktop::closeAllStudies( QAD_Application* app )
2437 QList<QAD_Study>& studies = app->getStudies();
2438 while ( !studies.isEmpty() )
2440 //don't ask user to remove study permanently
2441 if ( !onCloseStudy( studies.at(0), false ) )
2442 return false; /* user cancelled closing */
2448 Called on Popup item when SComponent representation in Object Browser is selected.
2450 void QAD_Desktop::onOpenWith()
2452 Engines::Component_var comp;
2453 QString ComponentSelected;
2455 SALOMEDS::SObject_var SO;
2456 SALOMEDS::SComponent_var SCO;
2457 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2458 SALOMEDS::GenericAttribute_var anAttr;
2459 SALOMEDS::AttributeName_var aName;
2461 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2462 if ( Sel->IObjectCount() == 1 ) {
2463 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
2464 SO = aStudy->FindObjectID( IO->getEntry() );
2465 SCO = SO->GetFatherComponent();
2467 if (SCO->FindAttribute(anAttr, "AttributeName")) {
2468 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2469 name = aName->Value();
2470 SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( mapComponentName[name] );
2471 if ( !Comp->_is_nil() ) {
2473 SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
2474 myCatalogue->GetTypedComponentList( Comp->component_type() );
2476 if ( list_type_composants->length() == 1 ) {
2477 ComponentSelected = name;
2478 } else if ( list_type_composants->length() > 1 ) {
2479 SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
2480 for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
2481 QString compusername = getComponentUserName(strdup(list_type_composants[ind]));
2482 if ( compusername.compare("") != 0 )
2483 aDlg->addComponent( compusername );
2486 int retVal = aDlg->exec();
2487 ComponentSelected = aDlg->getComponent();
2489 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2493 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2498 MESSAGE( "This component not exists in the catalog" );
2502 QApplication::setOverrideCursor( Qt::waitCursor );
2503 Sel->ClearIObjects();
2505 // if (loadComponentData(ComponentSelected)) {
2506 onComboActiveComponent(ComponentSelected);
2507 // int nbItem = myCombo->count();
2509 // for (int i = 0; i < nbItem; i++) {
2510 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2515 // myCombo->setCurrentItem(Index);
2516 // myActiveStudy->updateObjBrowser(true);
2520 QApplication::restoreOverrideCursor();
2523 typedef bool OneDim1(QAD_Desktop*);
2524 typedef bool OneDim2(QAD_Desktop*, char*);
2527 Called to define settings of component.
2529 void QAD_Desktop::setSettings()
2531 if (!myActiveComp.isEmpty()) {
2532 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2536 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2541 QString Component =mapComponentName[myActiveComp];
2542 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2543 (*f1)(this, (char*)Component.latin1());
2549 Called to load Component : xml resources and GUI librairy.
2551 bool QAD_Desktop::loadComponent(QString Component)
2554 QString resDir("/"); //NRI : Pb under Windows
2556 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2559 if (!resMgr->loadResources( Component, msg ))
2561 //NRI QCString errMsg;
2562 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2563 // Component.latin1() );
2565 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2570 /* Parse xml file */
2571 myXmlHandler = new QAD_XmlHandler();
2572 myXmlHandler->setMainWindow(this);
2573 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2575 QString language = resMgr->language( Component );
2577 QString ComponentXml = Component + "_" + language + ".xml";
2578 //ComponentXml = resMgr->resources(Component + "GUI") ;
2579 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2580 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2581 QFile file( ComponentXml );
2583 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2585 errMsg.sprintf( "Cannot open xml file: %s\n.",
2586 (file.name()).latin1() );
2588 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2593 QXmlInputSource source( file );
2594 QXmlSimpleReader reader;
2595 reader.setContentHandler( myXmlHandler );
2596 reader.setErrorHandler( myXmlHandler );
2598 bool IsMaxActStudy = myActiveStudy->getActiveStudyFrame()->isMaximized();
2599 if (IsMaxActStudy) {
2600 QString aSourceData = source.data();
2601 aSourceData = changeXmlInputSourceData( aSourceData, Component );
2602 source.setData(aSourceData);
2605 bool ok = reader.parse( source );
2609 QMessageBox::critical( this,
2610 tr( "INF_PARSE_ERROR" ),
2611 tr( myXmlHandler->errorProtocol() ) );
2615 myMenusList=myXmlHandler->myMenusList;
2616 myActiveMenus=myMenusList.at(0);
2617 myOperatorMenus->showMenuBar(0);
2618 myActiveMenus->showAllToolBars();
2620 /* Components toolbars */
2623 nbToolbars = myActiveMenus->getToolBarList().count();
2624 /* Open Shared Library */
2625 mySharedLibrary = OSD_SharedLibrary();
2628 QString ComponentLib;
2630 QFileInfo fileInfo ;
2631 QString fileString ;
2634 if ( libs = getenv("LD_LIBRARY_PATH")) {
2635 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
2636 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
2637 for ( int i = dirList.count()-1; i >= 0; i-- ) {
2640 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ;
2642 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ;
2645 fileInfo.setFile(fileString) ;
2646 if (fileInfo.exists()) {
2647 // MESSAGE ( " GUI library = " << fileString );
2648 ComponentLib = fileInfo.fileName() ;
2655 if (!_islibso) // component GUI could be in PyQt, use generic library
2657 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
2659 if (dir = getenv("KERNEL_ROOT_DIR"))
2661 dir = QAD_Tools::addSlash(dir) ;
2663 dir = QAD_Tools::addSlash(dir) ;
2664 dir = dir + "salome" ;
2665 dir = QAD_Tools::addSlash(dir) ;
2667 dir = dir + "libSalomePyQtcmodule.dll" ;
2669 dir = dir + "libSalomePyQtcmodule.so" ;
2671 MESSAGE ( " GUI library = " << dir );
2672 fileInfo.setFile(dir) ;
2673 if (fileInfo.exists())
2675 ComponentLib = fileInfo.fileName() ;
2681 QMessageBox::critical( this,
2683 tr("ERR_LIBGUI" ).arg(Component) );
2688 mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
2689 ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY);
2692 QMessageBox::critical( this,
2694 tr( mySharedLibrary.DlError() ) );
2699 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2703 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2708 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2709 (*f1)(this, (char*)Component.latin1());
2714 /* COMPONENT INTERFACE */
2715 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2716 myCatalogue->GetComponent(Component.latin1());
2718 if (CORBA::is_nil (aComponent)) {
2719 MESSAGE( "Catalog Error : Component not found in the catalog" )
2723 myActiveStudy->setMessage(QString("Component : ") +
2724 aComponent->componentusername() + " created " );
2725 myActiveStudy->setMessage(QString("Type : ") +
2726 QString::number(aComponent->component_type()));
2727 myActiveStudy->setMessage(QString("Constraint : ") +
2728 aComponent->constraint() );
2730 /* obtain interfaces list of the component */
2731 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2732 new SALOME_ModuleCatalog::ListOfInterfaces;
2733 _list = aComponent->GetInterfaceList();
2735 if (_list->length() != 0 ) {
2737 for (unsigned int ind = 0; ind < _list->length();ind++)
2738 myActiveStudy->setMessage( QString("Interface name : ") +
2742 /* obtain services list of the component */
2743 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2744 new SALOME_ModuleCatalog::ListOfServices;
2745 list_services_component = aComponent->GetServiceList(_list[0]);
2747 if (list_services_component->length() != 0 ) {
2749 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2750 myActiveStudy->setMessage( QString("Service name : ") +
2751 list_services_component[ind] );
2753 // Get a service of the component
2754 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2755 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2756 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2757 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2758 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2759 (const char *) service->ServiceinParameter[ind1].Parametertype);
2760 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2761 (const char *) service->ServiceinParameter[ind1].Parametername);
2763 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2764 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2765 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2766 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2767 (const char *) service->ServiceoutParameter[ind1].Parametername);
2774 QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent)
2776 if ( theComponent=="Supervision" ) {
2777 //Supervision main menu item
2780 QString aStrOld = createString( aItemId, aPosId );
2781 QString aStrNew = createString( aItemId, aPosId+1 );
2782 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2785 if ( theComponent == "Visu" ) {
2786 //Visualization main menu item
2789 QString aStrOld = createString( aItemId, aPosId );
2790 QString aStrNew = createString( aItemId, aPosId+1 );
2791 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2793 //Selection main menu item
2796 aStrOld = createString( aItemId, aPosId );
2797 aStrNew = createString( aItemId, aPosId+1 );
2798 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2800 //Representation main menu item
2803 aStrOld = createString( aItemId, aPosId );
2804 aStrNew = createString( aItemId, aPosId+1 );
2805 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2808 if ( theComponent == "SMESH" ) {
2809 //Hypotheses main menu item
2812 QString aStrOld = createString( aItemId, aPosId );
2813 QString aStrNew = createString( aItemId, aPosId+1 );
2814 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2816 //Mesh main menu item
2819 aStrOld = createString( aItemId, aPosId );
2820 aStrNew = createString( aItemId, aPosId+1 );
2821 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2823 //Controls main menu item
2826 aStrOld = createString( aItemId, aPosId );
2827 aStrNew = createString( aItemId, aPosId+1 );
2828 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2830 //Modification main menu item
2833 aStrOld = createString( aItemId, aPosId );
2834 aStrNew = createString( aItemId, aPosId+1 );
2835 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2837 //Numbering main menu item
2840 aStrOld = createString( aItemId, aPosId );
2841 aStrNew = createString( aItemId, aPosId+1 );
2842 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2845 if ( theComponent == "Geometry" ) {
2846 //New Entity main menu item
2849 QString aStrOld = createString( aItemId, aPosId );
2850 QString aStrNew = createString( aItemId, aPosId+1 );
2851 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2853 //Operations main menu item
2856 aStrOld = createString( aItemId, aPosId );
2857 aStrNew = createString( aItemId, aPosId+1 );
2858 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2860 //Repair main menu item
2863 aStrOld = createString( aItemId, aPosId );
2864 aStrNew = createString( aItemId, aPosId+1 );
2865 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2867 //Measures main menu item
2870 aStrOld = createString( aItemId, aPosId );
2871 aStrNew = createString( aItemId, aPosId+1 );
2872 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2875 if ( theComponent == "Med" ) {
2876 //MED main menu item
2879 QString aStrOld = createString( aItemId, aPosId );
2880 QString aStrNew = createString( aItemId, aPosId+1 );
2881 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2887 typedef bool OneDim(int, QAD_Desktop*);
2888 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2892 void QAD_Desktop::onDispatch()
2894 const QObject* obj = sender();
2896 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2897 QAD_ListMenuIdAction* aMenu;
2899 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2900 if (aMenu->getAction()==obj) {
2901 id = aMenu->getId();
2910 void QAD_Desktop::onDispatchTools(int id)
2912 /* Open Shared Library */
2913 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2917 QFileInfo fileInfo ;
2921 bool libToolsGUI = true;
2922 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2924 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2925 dir = QAD_Tools::addSlash(dir) ;
2927 dir = QAD_Tools::addSlash(dir) ;
2928 dir = dir + "salome" ;
2929 dir = QAD_Tools::addSlash(dir) ;
2931 dir = dir + "libToolsGUI.dll" ;
2933 dir = dir + "libToolsGUI.so" ;
2935 MESSAGE ( " GUI library = " << dir );
2936 fileInfo.setFile(dir) ;
2937 if (fileInfo.exists()) {
2938 ToolsLib = fileInfo.fileName() ;
2944 libToolsGUI = false;
2945 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
2946 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2947 dir = QAD_Tools::addSlash(dir) ;
2949 dir = QAD_Tools::addSlash(dir) ;
2950 dir = dir + "salome" ;
2951 dir = QAD_Tools::addSlash(dir) ;
2952 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2953 MESSAGE ( " GUI library = " << dir );
2954 fileInfo.setFile(dir) ;
2955 if (fileInfo.exists()) {
2956 ToolsLib = fileInfo.fileName() ;
2962 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
2963 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
2965 if ( libToolsGUI ) {
2966 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2967 OneDim (*f1) = NULL;
2968 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2971 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
2972 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
2973 CORBA::ORB_var &orb = init(0 , 0 ) ;
2974 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2975 PTR_FACTORY_FUNCTION f1 = NULL;
2976 f1 = (PTR_FACTORY_FUNCTION) osdF;
2977 f1(orb,0,"Registry");
2980 QMessageBox::critical( this,
2982 tr( ToolsLibrary.DlError() ) );
2988 void QAD_Desktop::onDispatch(int id)
2990 if (!myActiveComp.isEmpty()) {
2991 OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent");
2992 OneDim (*f1) = NULL;
2993 if ( osdF != NULL ) {
2994 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
3001 Returns the component's catalogue
3003 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
3010 void QAD_Desktop::onComboActiveComponent( const QString & component ){
3011 onComboActiveComponent(component,true);
3013 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
3015 if (myActiveStudy != 0) {
3016 if (myActiveComp.compare(component)!=0) {
3017 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3018 if ( myCombo->currentText() != component )
3019 myCombo->setCurrentText( component );
3020 //NRI if (component.compare(QString("Salome"))!= 0) {
3021 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
3022 // QApplication::setOverrideCursor( Qt::waitCursor );
3023 myActiveComp = component;
3025 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3027 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3028 if ( aButton->textLabel().compare(component)==0)
3029 aButton->setOn(true);
3031 aButton->setOn(false);
3034 myActiveStudy->Selection( component );
3035 if ( !loadComponent(mapComponentName[component]) ) {
3036 myCombo->setCurrentItem (0);
3037 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3038 aButton->setOn(false);
3043 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3044 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
3045 for(;It.More();It.Next()) {
3046 int res = Sel->AddIObject( It.Value() );
3049 myActiveStudy->highlight( It.Value(), false );
3051 myActiveStudy->highlight( It.Value(), true );
3055 // Open new component's data in active study if any
3056 if(isLoadData) loadComponentData(mapComponentName[component]);
3059 myActiveStudy->updateObjBrowser(true);
3061 // QApplication::restoreOverrideCursor();
3063 } else { // component == "Salome"
3065 //NRI myActiveStudy->Selection( "Salome" );
3066 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
3067 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3068 Sel->ClearIObjects();
3069 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3070 aButton->setOn(false);
3074 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3075 if ( aButton->textLabel().compare(component)==0)
3076 aButton->setOn(true);
3079 } else if (component.compare(QString("Salome"))!= 0) {
3081 SALOMEGUI_ActivateComponentDlg aDlg( this );
3082 int res = aDlg.exec();
3088 onComboActiveComponent(component,true);
3092 onComboActiveComponent(component,true);
3096 onComboActiveComponent(component,true);;
3100 putInfo( tr("INF_CANCELLED") );
3101 myCombo->setCurrentItem (0);
3102 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3103 aButton->setOn(false);
3112 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
3114 int nbItem = myCombo->count();
3117 for (int i = 0; i < nbItem; i++) {
3118 if (myCombo->text(i).compare(theName)==0) {
3123 myCombo->setCurrentItem (Index);
3124 onComboActiveComponent(theName,isLoadData);
3127 void QAD_Desktop::onButtonActiveComponent( )
3129 QToolButton* obj = (QToolButton*)sender();
3130 activateComponent(obj->textLabel());
3134 Clears All Resources of current component
3136 void QAD_Desktop::clearMenus()
3138 onActiveStudyChanged();
3141 myMenusList.clear();
3143 int length = myXmlHandler->myIdList.Length();
3144 for (int k=length; k>0; k--) {
3146 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
3147 parent->removeItem( myXmlHandler->myIdList.Value(k) );
3152 if (myActiveMenus) {
3153 int nbtoolbars = myActiveMenus->getToolBarList().count();
3154 for (int k=0; k<nbtoolbars; k++) {
3155 myActiveMenus->getToolBarList().at(k)->hide();
3156 myActiveMenus->getToolBarList().at(k)->clear();
3158 myActiveMenus->clearToolBar();
3161 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
3162 QAD_ListPopupMenu* aPopup;
3163 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
3164 aPopup->getPopup()->clear();
3167 myActiveMenus->clearPopupMenu();
3173 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3175 Exports Key Events in active component ( GUI Librairy )
3177 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
3179 // MESSAGE ( "QAD_Desktop::onKeyPress" )
3180 if (!myActiveComp.isEmpty()) {
3181 OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress");
3182 if ( osdF != NULL ) {
3183 TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3184 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3189 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3191 Exports Mouse Press Events in active component ( GUI Librairy )
3193 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
3195 // MESSAGE ( "QAD_Desktop::onMousePress" )
3196 if (!myActiveComp.isEmpty()) {
3197 OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress");
3198 if ( osdF != NULL ) {
3199 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3200 return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3207 Exports Mouse Move Events in active component ( GUI Librairy )
3209 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
3211 if (!myActiveComp.isEmpty()) {
3212 OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove");
3213 if ( osdF != NULL ) {
3214 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3215 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3221 Returns name of active component
3223 const QString& QAD_Desktop::getActiveComponent() const
3225 return myActiveComp;
3229 typedef bool defineP( QString & theContext, QString & theParent, QString & theObject);
3231 void QAD_Desktop::definePopup(QString & theContext,
3232 QString & theParent,
3233 QString & theObject )
3235 if (!myActiveComp.isEmpty()) {
3236 OSD_Function osdF = mySharedLibrary.DlSymb("definePopup");
3237 if ( osdF != NULL ) {
3238 defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF;
3239 (*f1)(theContext, theParent, theObject);
3247 void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
3248 QString text, int popupID, bool separator)
3250 QMenuItem* item = popup->findItem(popupID);
3252 QPopupMenu* popupChild = item->popup();
3254 QPopupMenu* newPopup = new QPopupMenu;
3255 int count = popupChild->count();
3256 // add items at the top of <popupFather>
3257 for (int i = count - 1; i >= 0; i--) {
3258 int j = popupChild->idAt(i);
3259 QString text = popupChild->text(j);
3260 createPopup( newPopup, popupChild, text, j);
3262 popupFather->insertItem(popup->text(popupID),
3263 newPopup, popupID, 0);
3265 if ( !text.isNull() ) {
3266 popupFather->insertItem(popup->text(popupID),
3268 SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top
3269 } /*else if ( separator )
3270 popupFather->insertTearOffHandle(-1, 0);*/
3272 popupFather->insertSeparator(0);
3280 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
3281 const QString & theParent, const QString & theObject )
3283 if ( !myActiveComp.isEmpty() &&
3284 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
3285 QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup();
3286 int count = aPopup->count();
3288 //for (int i = 0; i < count; i++) {
3289 for (int i = count - 1; i >= 0; i--) {
3290 int id = aPopup->idAt(i);
3291 QString text = aPopup->text(id);
3292 //QString mes("Inserting popup menu item loaded from XML: ");
3294 //MESSAGE ( mes.latin1() )
3296 popup->insertItem(aPopup->text(id),
3298 SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top
3300 createPopup( popup, aPopup, text, id);
3303 //QString mes("Popup does not exist for given (Context = ");
3304 //mes += theContext;
3305 //mes += ", Parent = ";
3307 //mes += ", Object = ";
3309 //MESSAGE (mes.latin1())
3314 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3315 if ( myActiveComp.isEmpty() ) {
3316 popup->removeItem(QAD_Display_Popup_ID);
3317 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3318 popup->removeItem(QAD_Erase_Popup_ID);
3319 int id = popup->idAt(popup->count()-1); // last item
3320 if (id < 0 && id != -1) popup->removeItem(id); // separator
3322 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3323 if ( popup->count()>0 ) {
3324 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3325 popup->insertSeparator (3);
3328 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3335 typedef bool activeStudyChanged(QAD_Desktop*);
3337 void QAD_Desktop::onActiveStudyChanged()
3339 if (!myActiveComp.isEmpty()) {
3340 OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged");
3341 if ( osdF != NULL ) {
3342 activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF;
3348 typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext,
3349 const QString & theParent, const QString & theObject);
3351 Custom popup ( GUI Library )
3353 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3354 const QString & theParent, const QString & theObject)
3356 if (!myActiveComp.isEmpty()) {
3357 OSD_Function osdF = mySharedLibrary.DlSymb("customPopup");
3358 if ( osdF != NULL ) {
3359 customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &,
3360 const QString &, const QString &)) osdF;
3361 (*f1)(this, popup, theContext, theParent, theObject);
3366 void QAD_Desktop::onObjectBrowser()
3368 bool checkDiff = false;
3370 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3372 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3376 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3378 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3381 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3385 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3387 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3390 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3394 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3396 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3399 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3402 /* To sort created object in chrono order or reverse chrono order */
3403 bool showCHRONO_SORT ;
3404 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3405 showCHRONO_SORT = true;
3406 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "true");
3408 showCHRONO_SORT = false;
3409 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "false");
3412 /* To show or not to show UseCase browser */
3414 if ( myStdActions.at( PrefObjectBrowserShowUseCaseId )->isOn() ) {
3416 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "true");
3418 showUseCase = false;
3419 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "false");
3422 /* Resize or don't resize columns automatically */
3424 if ( myStdActions.at( PrefObjectBrowserNoAutoSizeColumnsId )->isOn() ) {
3426 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "true");
3429 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "false");
3432 if ( myActiveApp ) {
3433 QList<QAD_Study>& studies = myActiveApp->getStudies();
3434 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3435 int nbSf = study->getStudyFramesCount();
3436 for ( int i = 0; i < nbSf; i++ ) {
3437 QAD_StudyFrame* sf = study->getStudyFrame(i);
3438 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3439 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3440 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3441 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3442 sf->getLeftFrame()->getObjectBrowser()->showUseCaseBrowser( showUseCase );
3443 sf->getLeftFrame()->getObjectBrowser()->autoSizeColumns( autoSize );
3445 study->updateObjBrowser(true);
3450 void QAD_Desktop::onViewerTrihedron()
3452 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3455 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3456 if (!Size.isEmpty())
3457 Dlg->setTrihedronSize(Size.toInt());
3458 int r = Dlg->exec();
3459 dim = Dlg->getTrihedronSize();
3462 if (r == QDialog::Accepted) {
3463 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3466 QList<QAD_Study>& studies = myActiveApp->getStudies();
3467 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3468 int nbSf = study->getStudyFramesCount();
3469 for ( int i = 0; i < nbSf; i++ ) {
3470 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->onAdjustTrihedron();
3477 void QAD_Desktop::onExternalBrowser()
3480 QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3481 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3483 SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
3485 if (!theApp.isEmpty())
3487 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3488 Dlg->setSettings(theApp, theParams);
3490 int r = Dlg->exec();
3491 QString theAppFromDialog = Dlg->getApp();
3492 QString theParamsFromDialog = Dlg->getParams();
3495 if (r == QDialog::Accepted)
3497 QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
3498 QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
3504 void QAD_Desktop::onDirList()
3506 // getting dir list from settings
3507 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3508 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3509 dlg->setPathList(dirList);
3510 if ( dlg->exec() == QDialog::Accepted) {
3511 dlg->getPathList(dirList);
3512 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3517 void QAD_Desktop::onConsoleFontAction()
3519 // getting font from settings
3520 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3521 QFont font = QAD_Tools::stringToFont( fntSet );
3523 font = QFontDialog::getFont( &bOk, font, this );
3525 fntSet = QAD_Tools::fontToString( font );
3526 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3529 QList<QAD_Study>& studies = myActiveApp->getStudies();
3530 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3531 int nbSf = study->getStudyFramesCount();
3532 for ( int i = 0; i < nbSf; i++ ) {
3533 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3534 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3541 void QAD_Desktop::onSavePref()
3543 QAD_CONFIG->createConfigFile(true);
3546 //VRV: T2.5 - add default viewer
3547 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3549 int type = VIEW_TYPE_MAX;
3552 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3554 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3556 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3557 type = VIEW_GRAPHSUPERV;
3558 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3560 if ( type != VIEW_TYPE_MAX )
3561 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3563 //VRV: T2.5 - add default viewer
3565 void QAD_Desktop::onViewerOCC()
3567 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3568 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3569 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3572 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3573 color = QColor(BackgroundColorRed.toInt(),
3574 BackgroundColorGreen.toInt(),
3575 BackgroundColorBlue.toInt());
3577 color = QColor(35, 136, 145);
3579 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3582 if ( myActiveApp ) {
3583 QList<QAD_Study>& studies = myActiveApp->getStudies();
3584 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3585 int nbSf = study->getStudyFramesCount();
3586 for ( int i = 0; i < nbSf; i++ ) {
3587 QAD_StudyFrame* sf = study->getStudyFrame(i);
3588 if ( sf->getTypeView() == VIEW_OCC ) {
3589 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3594 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3595 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3596 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3600 void QAD_Desktop::onGraphSupervisor()
3602 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3603 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3604 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3607 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3608 color = QColor(BackgroundColorRed.toInt(),
3609 BackgroundColorGreen.toInt(),
3610 BackgroundColorBlue.toInt());
3612 color = QColor(35, 136, 145);
3614 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3617 if ( myActiveApp ) {
3618 QList<QAD_Study>& studies = myActiveApp->getStudies();
3619 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3620 int nbSf = study->getStudyFramesCount();
3621 for ( int i = 0; i < nbSf; i++ ) {
3622 QAD_StudyFrame* sf = study->getStudyFrame(i);
3623 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3624 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3630 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3631 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3632 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3636 void QAD_Desktop::onViewerVTK()
3638 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3639 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3640 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3643 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3644 color = QColor(BackgroundColorRed.toInt(),
3645 BackgroundColorGreen.toInt(),
3646 BackgroundColorBlue.toInt());
3648 color = QColor(0, 0, 0);
3650 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3653 if ( myActiveApp ) {
3654 QList<QAD_Study>& studies = myActiveApp->getStudies();
3655 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3656 int nbSf = study->getStudyFramesCount();
3657 for ( int i = 0; i < nbSf; i++ ) {
3658 QAD_StudyFrame* sf = study->getStudyFrame(i);
3659 if ( sf->getTypeView() == VIEW_VTK ) {
3660 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3666 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3667 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3668 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3672 void QAD_Desktop::onPlot2d()
3675 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3676 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3677 QStringList bgData = QStringList::split( ":", bgString, true );
3678 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3679 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3680 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3681 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3682 color = QColor( bgRed, bgGreen, bgBlue );
3685 color = QColor(0, 0, 0);
3688 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3690 if ( color.isValid() ) {
3691 if ( myActiveApp ) {
3692 QList<QAD_Study>& studies = myActiveApp->getStudies();
3693 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3694 int nbSf = study->getStudyFramesCount();
3695 for ( int i = 0; i < nbSf; i++ ) {
3696 QAD_StudyFrame* sf = study->getStudyFrame(i);
3697 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3698 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3704 bgData.append( QString::number( color.red() ) );
3705 bgData.append( QString::number( color.green() ) );
3706 bgData.append( QString::number( color.blue() ) );
3707 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3712 void QAD_Desktop::helpAbout()
3714 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3719 // /* Help Search */
3720 // void QAD_Desktop::helpSearch()
3724 // /* Help Contents */
3725 // void QAD_Desktop::helpContents()
3727 // if (myActiveComp == "")
3728 // myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3732 // if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3733 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3734 // if ( QFileInfo( root + "index.html" ).exists() ) {
3735 // helpContext( root + "index.html", "" );
3738 // root = QAD_Tools::addSlash( root + "html" );
3739 // if ( QFileInfo( root + "index.html" ).exists() ) {
3740 // helpContext( root + "index.html", "" );
3743 // root = QAD_Tools::addSlash( root + "html" );
3744 // if ( QFileInfo( root + "index.html" ).exists() ) {
3745 // helpContext( root + "index.html", "" );
3751 // // //NRI getHelpWindow()->contents();
3752 // // getHelpWindow()->show();
3753 // // getHelpWindow()->raise();
3754 // // getHelpWindow()->setActiveWindow();
3758 //void QAD_Desktop::helpContext(const QString& source, const QString& context)
3760 // //getHelpWindow()->context(source, context); //implemented in QAD_HelpWindow::context( const QString& _source, const QString& _context)
3761 // //getHelpWindow()->show(); //from QMainWindow class
3762 // //getHelpWindow()->raise(); //from QMainWindow class
3763 // //getHelpWindow()->setActiveWindow(); //from QMainWindow class
3765 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3766 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3768 // RunBrowser* rs = new RunBrowser(anApp, aParams, source, context);
3772 /* Preferences/MultiFile Save */
3773 void QAD_Desktop::onMultiFileSave()
3775 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3776 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3778 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3781 /* Preferences/ASCII Save */
3782 void QAD_Desktop::onASCIISave()
3784 if ( myStdActions.at( PrefASCIISave )->isOn() )
3785 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3787 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3790 /* Preferences / Undo Level */
3791 void QAD_Desktop::onUndoLevel()
3793 static int MAX_UNDO_LEVEL = 1000;
3794 bool isAccepted = false;
3795 static QString aLabel = QString("Level value (%1 ... %2) : ").
3796 arg(1).arg(MAX_UNDO_LEVEL);
3798 SALOMEGUI_SetValueDlg::getInteger("Undo Level",aLabel,
3799 1,MAX_UNDO_LEVEL,getUndoLevel(),
3801 if(!isAccepted) return;
3802 QAD_CONFIG->addSetting("Desktop:UndoLevel", anUndoLevel);
3803 if(!myActiveApp) return;
3804 QList<QAD_Study>& studies = myActiveApp->getStudies();
3805 int aWasWarning = 0;
3806 for(QAD_Study* study = studies.first(); study; study = studies.next()){
3807 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
3808 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDoc->NewBuilder();
3809 if (!aStudyDoc->GetProperties()->IsLocked()) {
3810 aStudyBuilder->UndoLimit(anUndoLevel);
3813 QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
3814 QObject::tr("WRN_WARNING"),
3815 QObject::tr("WRN_STUDY_LOCKED"),
3816 QObject::tr("BUT_OK"));
3823 /*********************************************************************
3824 ** Class: AppSelectionDlg
3825 ** Descr: Dialog for the selection of the application when several
3826 ** applications exist in the desktop and new study creation
3827 ** is activated by user.
3829 **********************************************************************/
3831 \class Desktop_AppSelectionDlg QAD_Desktop.h
3832 \brief Dialog for the selection of the application when several
3833 applications exist in the desktop and new study creation
3834 is activated by user.
3839 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
3840 QList<QAD_Application>& apps ) :
3841 QDialog( desktop, 0, true ),
3845 QAD_ASSERT_DEBUG_ONLY ( desktop );
3846 setCaption( tr("INF_DESK_DOC_CREATE") );
3847 if ( desktop->icon() )
3848 setIcon( *desktop->icon() );
3850 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
3852 /* Create selection buttons */
3853 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
3854 buttonGrp->setExclusive ( true );
3855 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
3856 vLayout->addWidget ( buttonGrp );
3858 /* Create selection button for available app */
3860 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
3862 /* add radio button for application */
3863 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
3864 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
3867 /* make the first application selected */
3868 buttonGrp->setButton( 0 );
3870 /* listen to the selection */
3871 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
3873 /* Create OK/Cancel buttons
3875 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
3876 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
3877 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
3878 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
3879 buttonOK->setDefault( true );
3881 hLayout->addStretch();
3882 hLayout->addWidget( buttonOK );
3883 hLayout->addWidget( buttonCancel );
3884 hLayout->addWidget( buttonHelp );
3886 /* connect buttons */
3887 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
3888 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
3889 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
3891 /* disable resizing */
3892 setFixedSize( 0, 0 );
3893 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
3896 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
3900 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
3902 return myApps.at( myAppId );
3905 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
3907 QAD_Tools::centerWidget( this, parentWidget() );
3913 void Desktop_AppSelectionDlg::onAppSelected( int id )
3918 void Desktop_AppSelectionDlg::onHelp()