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.
34 # include "Utils_ORB_INIT.hxx"
35 # include "Utils_SINGLETON.hxx"
37 #define INCLUDE_MENUITEM_DEF
38 #define DEFAULT_BROWSER "mozilla"
43 #include "QAD_Tools.h"
44 #include "QAD_Desktop.h"
45 #include "QAD_LeftFrame.h"
46 #include "QAD_RightFrame.h"
47 #include "QAD_Operation.h"
48 #include "QAD_XmlHandler.h"
49 #include "QAD_MessageBox.h"
50 #include "QAD_Application.h"
51 #include "QAD_Settings.h"
52 #include "QAD_Config.h"
53 #include "QAD_ObjectBrowser.h"
54 #include "QAD_Resource.h"
55 #include "QAD_FileDlg.h"
56 //NRI #include "QAD_HelpWindow.h"
57 #include "QAD_DirListDlg.h"
58 #include "QAD_WaitCursor.h"
59 #include "SALOMEGUI_OpenWith.h"
60 #include "SALOMEGUI_StudyPropertiesDlg.h"
61 #include "SALOMEGUI_TrihedronSizeDlg.h"
62 #include "SALOMEGUI_ExternalBrowserDlg.h"
63 #include "SALOMEGUI_LoadStudiesDlg.h"
64 #include "SALOME_Selection.h"
65 #include "SALOME_InteractiveObject.hxx"
66 #include "SALOME_ListIteratorOfListIO.hxx"
67 #include "SALOMEGUI_AboutDlg.h"
68 #include "SALOMEGUI_ViewChoiceDlg.h"
69 #include "SALOMEGUI_SetValueDlg.h"
70 #include "utilities.h"
72 #include "SALOMEGUI_CloseDlg.h"
73 #include "SALOMEGUI_ActivateComponentDlg.h"
78 #include <qmessagebox.h>
79 #include <qcolordialog.h>
80 #include <qradiobutton.h>
81 #include <qapplication.h>
82 #include <qvbuttongroup.h>
84 #include <qmessagebox.h>
87 #include <qpopupmenu.h>
88 #include <qlistview.h>
92 #include <qfontdialog.h>
93 #include <qlineedit.h>
94 #include <qdatetime.h>
102 // Open CASCADE Includes
103 #include <OSD_LoadMode.hxx>
104 #include <OSD_Function.hxx>
105 #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 aDlg->addComponent( strdup(list_type_composants[ind]) );
2484 int retVal = aDlg->exec();
2485 ComponentSelected = aDlg->getComponent();
2487 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2491 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2496 MESSAGE( "This component not exists in the catalog" );
2500 QApplication::setOverrideCursor( Qt::waitCursor );
2501 Sel->ClearIObjects();
2503 // if (loadComponentData(ComponentSelected)) {
2504 onComboActiveComponent(ComponentSelected);
2505 // int nbItem = myCombo->count();
2507 // for (int i = 0; i < nbItem; i++) {
2508 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2513 // myCombo->setCurrentItem(Index);
2514 // myActiveStudy->updateObjBrowser(true);
2518 QApplication::restoreOverrideCursor();
2521 typedef bool OneDim1(QAD_Desktop*);
2522 typedef bool OneDim2(QAD_Desktop*, char*);
2525 Called to define settings of component.
2527 void QAD_Desktop::setSettings()
2529 if (!myActiveComp.isEmpty()) {
2530 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2534 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2539 QString Component =mapComponentName[myActiveComp];
2540 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2541 (*f1)(this, (char*)Component.latin1());
2547 Called to load Component : xml resources and GUI librairy.
2549 bool QAD_Desktop::loadComponent(QString Component)
2552 QString resDir("/"); //NRI : Pb under Windows
2554 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2557 if (!resMgr->loadResources( Component, msg ))
2559 //NRI QCString errMsg;
2560 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2561 // Component.latin1() );
2563 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2568 /* Parse xml file */
2569 myXmlHandler = new QAD_XmlHandler();
2570 myXmlHandler->setMainWindow(this);
2571 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2573 QString language = resMgr->language( Component );
2575 QString ComponentXml = Component + "_" + language + ".xml";
2576 //ComponentXml = resMgr->resources(Component + "GUI") ;
2577 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2578 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2579 QFile file( ComponentXml );
2581 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2583 errMsg.sprintf( "Cannot open xml file: %s\n.",
2584 (file.name()).latin1() );
2586 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2591 QXmlInputSource source( file );
2592 QXmlSimpleReader reader;
2593 reader.setContentHandler( myXmlHandler );
2594 reader.setErrorHandler( myXmlHandler );
2596 bool IsMaxActStudy = myActiveStudy->getActiveStudyFrame()->isMaximized();
2597 if (IsMaxActStudy) {
2598 QString aSourceData = source.data();
2599 aSourceData = changeXmlInputSourceData( aSourceData, Component );
2600 source.setData(aSourceData);
2603 bool ok = reader.parse( source );
2607 QMessageBox::critical( this,
2608 tr( "INF_PARSE_ERROR" ),
2609 tr( myXmlHandler->errorProtocol() ) );
2613 myMenusList=myXmlHandler->myMenusList;
2614 myActiveMenus=myMenusList.at(0);
2615 myOperatorMenus->showMenuBar(0);
2616 myActiveMenus->showAllToolBars();
2618 /* Components toolbars */
2621 nbToolbars = myActiveMenus->getToolBarList().count();
2622 /* Open Shared Library */
2623 mySharedLibrary = OSD_SharedLibrary();
2626 QString ComponentLib;
2628 QFileInfo fileInfo ;
2629 QString fileString ;
2632 if ( libs = getenv("LD_LIBRARY_PATH")) {
2633 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
2634 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
2635 for ( int i = dirList.count()-1; i >= 0; i-- ) {
2638 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ;
2640 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ;
2643 fileInfo.setFile(fileString) ;
2644 if (fileInfo.exists()) {
2645 // MESSAGE ( " GUI library = " << fileString );
2646 ComponentLib = fileInfo.fileName() ;
2653 if (!_islibso) // component GUI could be in PyQt, use generic library
2655 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
2657 if (dir = getenv("KERNEL_ROOT_DIR"))
2659 dir = QAD_Tools::addSlash(dir) ;
2661 dir = QAD_Tools::addSlash(dir) ;
2662 dir = dir + "salome" ;
2663 dir = QAD_Tools::addSlash(dir) ;
2665 dir = dir + "libSalomePyQtcmodule.dll" ;
2667 dir = dir + "libSalomePyQtcmodule.so" ;
2669 MESSAGE ( " GUI library = " << dir );
2670 fileInfo.setFile(dir) ;
2671 if (fileInfo.exists())
2673 ComponentLib = fileInfo.fileName() ;
2679 QMessageBox::critical( this,
2681 tr("ERR_LIBGUI" ).arg(Component) );
2686 mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
2687 ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY);
2690 QMessageBox::critical( this,
2692 tr( mySharedLibrary.DlError() ) );
2697 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2701 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2706 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2707 (*f1)(this, (char*)Component.latin1());
2712 /* COMPONENT INTERFACE */
2713 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2714 myCatalogue->GetComponent(Component.latin1());
2716 if (CORBA::is_nil (aComponent)) {
2717 MESSAGE( "Catalog Error : Component not found in the catalog" )
2721 myActiveStudy->setMessage(QString("Component : ") +
2722 aComponent->componentusername() + " created " );
2723 myActiveStudy->setMessage(QString("Type : ") +
2724 QString::number(aComponent->component_type()));
2725 myActiveStudy->setMessage(QString("Constraint : ") +
2726 aComponent->constraint() );
2728 /* obtain interfaces list of the component */
2729 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2730 new SALOME_ModuleCatalog::ListOfInterfaces;
2731 _list = aComponent->GetInterfaceList();
2733 if (_list->length() != 0 ) {
2735 for (unsigned int ind = 0; ind < _list->length();ind++)
2736 myActiveStudy->setMessage( QString("Interface name : ") +
2740 /* obtain services list of the component */
2741 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2742 new SALOME_ModuleCatalog::ListOfServices;
2743 list_services_component = aComponent->GetServiceList(_list[0]);
2745 if (list_services_component->length() != 0 ) {
2747 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2748 myActiveStudy->setMessage( QString("Service name : ") +
2749 list_services_component[ind] );
2751 // Get a service of the component
2752 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2753 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2754 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2755 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2756 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2757 (const char *) service->ServiceinParameter[ind1].Parametertype);
2758 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2759 (const char *) service->ServiceinParameter[ind1].Parametername);
2761 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2762 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2763 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2764 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2765 (const char *) service->ServiceoutParameter[ind1].Parametername);
2772 QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent)
2774 if ( theComponent=="Supervision" ) {
2775 //Supervision main menu item
2778 QString aStrOld = createString( aItemId, aPosId );
2779 QString aStrNew = createString( aItemId, aPosId+1 );
2780 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2783 if ( theComponent == "Visu" ) {
2784 //Visualization main menu item
2787 QString aStrOld = createString( aItemId, aPosId );
2788 QString aStrNew = createString( aItemId, aPosId+1 );
2789 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2791 //Selection main menu item
2794 aStrOld = createString( aItemId, aPosId );
2795 aStrNew = createString( aItemId, aPosId+1 );
2796 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2798 //Representation main menu item
2801 aStrOld = createString( aItemId, aPosId );
2802 aStrNew = createString( aItemId, aPosId+1 );
2803 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2806 if ( theComponent == "SMESH" ) {
2807 //Hypotheses main menu item
2810 QString aStrOld = createString( aItemId, aPosId );
2811 QString aStrNew = createString( aItemId, aPosId+1 );
2812 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2814 //Mesh main menu item
2817 aStrOld = createString( aItemId, aPosId );
2818 aStrNew = createString( aItemId, aPosId+1 );
2819 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2821 //Controls main menu item
2824 aStrOld = createString( aItemId, aPosId );
2825 aStrNew = createString( aItemId, aPosId+1 );
2826 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2828 //Modification main menu item
2831 aStrOld = createString( aItemId, aPosId );
2832 aStrNew = createString( aItemId, aPosId+1 );
2833 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2835 //Numbering main menu item
2838 aStrOld = createString( aItemId, aPosId );
2839 aStrNew = createString( aItemId, aPosId+1 );
2840 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2843 if ( theComponent == "Geometry" ) {
2844 //New Entity main menu item
2847 QString aStrOld = createString( aItemId, aPosId );
2848 QString aStrNew = createString( aItemId, aPosId+1 );
2849 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2851 //Operations main menu item
2854 aStrOld = createString( aItemId, aPosId );
2855 aStrNew = createString( aItemId, aPosId+1 );
2856 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2858 //Repair main menu item
2861 aStrOld = createString( aItemId, aPosId );
2862 aStrNew = createString( aItemId, aPosId+1 );
2863 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2865 //Measures main menu item
2868 aStrOld = createString( aItemId, aPosId );
2869 aStrNew = createString( aItemId, aPosId+1 );
2870 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2873 if ( theComponent == "Med" ) {
2874 //MED main menu item
2877 QString aStrOld = createString( aItemId, aPosId );
2878 QString aStrNew = createString( aItemId, aPosId+1 );
2879 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2885 typedef bool OneDim(int, QAD_Desktop*);
2886 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2890 void QAD_Desktop::onDispatch()
2892 const QObject* obj = sender();
2894 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2895 QAD_ListMenuIdAction* aMenu;
2897 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2898 if (aMenu->getAction()==obj) {
2899 id = aMenu->getId();
2908 void QAD_Desktop::onDispatchTools(int id)
2910 /* Open Shared Library */
2911 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2915 QFileInfo fileInfo ;
2919 bool libToolsGUI = true;
2920 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2922 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2923 dir = QAD_Tools::addSlash(dir) ;
2925 dir = QAD_Tools::addSlash(dir) ;
2926 dir = dir + "salome" ;
2927 dir = QAD_Tools::addSlash(dir) ;
2929 dir = dir + "libToolsGUI.dll" ;
2931 dir = dir + "libToolsGUI.so" ;
2933 MESSAGE ( " GUI library = " << dir );
2934 fileInfo.setFile(dir) ;
2935 if (fileInfo.exists()) {
2936 ToolsLib = fileInfo.fileName() ;
2942 libToolsGUI = false;
2943 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
2944 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2945 dir = QAD_Tools::addSlash(dir) ;
2947 dir = QAD_Tools::addSlash(dir) ;
2948 dir = dir + "salome" ;
2949 dir = QAD_Tools::addSlash(dir) ;
2950 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2951 MESSAGE ( " GUI library = " << dir );
2952 fileInfo.setFile(dir) ;
2953 if (fileInfo.exists()) {
2954 ToolsLib = fileInfo.fileName() ;
2960 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
2961 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
2963 if ( libToolsGUI ) {
2964 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2965 OneDim (*f1) = NULL;
2966 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2969 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
2970 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
2971 CORBA::ORB_var &orb = init(0 , 0 ) ;
2972 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2973 PTR_FACTORY_FUNCTION f1 = NULL;
2974 f1 = (PTR_FACTORY_FUNCTION) osdF;
2975 f1(orb,0,"Registry");
2978 QMessageBox::critical( this,
2980 tr( ToolsLibrary.DlError() ) );
2986 void QAD_Desktop::onDispatch(int id)
2988 if (!myActiveComp.isEmpty()) {
2989 OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent");
2990 OneDim (*f1) = NULL;
2991 if ( osdF != NULL ) {
2992 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2999 Returns the component's catalogue
3001 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
3008 void QAD_Desktop::onComboActiveComponent( const QString & component ){
3009 onComboActiveComponent(component,true);
3011 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
3013 if (myActiveStudy != 0) {
3014 if (myActiveComp.compare(component)!=0) {
3015 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3016 if ( myCombo->currentText() != component )
3017 myCombo->setCurrentText( component );
3018 //NRI if (component.compare(QString("Salome"))!= 0) {
3019 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
3020 // QApplication::setOverrideCursor( Qt::waitCursor );
3021 myActiveComp = component;
3023 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3025 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3026 if ( aButton->textLabel().compare(component)==0)
3027 aButton->setOn(true);
3029 aButton->setOn(false);
3032 myActiveStudy->Selection( component );
3033 if ( !loadComponent(mapComponentName[component]) ) {
3034 myCombo->setCurrentItem (0);
3035 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3036 aButton->setOn(false);
3041 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3042 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
3043 for(;It.More();It.Next()) {
3044 int res = Sel->AddIObject( It.Value() );
3047 myActiveStudy->highlight( It.Value(), false );
3049 myActiveStudy->highlight( It.Value(), true );
3053 // Open new component's data in active study if any
3054 if(isLoadData) loadComponentData(mapComponentName[component]);
3057 myActiveStudy->updateObjBrowser(true);
3059 // QApplication::restoreOverrideCursor();
3061 } else { // component == "Salome"
3063 //NRI myActiveStudy->Selection( "Salome" );
3064 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
3065 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3066 Sel->ClearIObjects();
3067 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3068 aButton->setOn(false);
3072 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3073 if ( aButton->textLabel().compare(component)==0)
3074 aButton->setOn(true);
3077 } else if (component.compare(QString("Salome"))!= 0) {
3079 SALOMEGUI_ActivateComponentDlg aDlg( this );
3080 int res = aDlg.exec();
3086 onComboActiveComponent(component,true);
3090 onComboActiveComponent(component,true);
3094 onComboActiveComponent(component,true);;
3098 putInfo( tr("INF_CANCELLED") );
3099 myCombo->setCurrentItem (0);
3100 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3101 aButton->setOn(false);
3110 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
3112 int nbItem = myCombo->count();
3115 for (int i = 0; i < nbItem; i++) {
3116 if (myCombo->text(i).compare(theName)==0) {
3121 myCombo->setCurrentItem (Index);
3122 onComboActiveComponent(theName,isLoadData);
3125 void QAD_Desktop::onButtonActiveComponent( )
3127 QToolButton* obj = (QToolButton*)sender();
3128 activateComponent(obj->textLabel());
3132 Clears All Resources of current component
3134 void QAD_Desktop::clearMenus()
3136 onActiveStudyChanged();
3139 myMenusList.clear();
3141 int length = myXmlHandler->myIdList.Length();
3142 for (int k=length; k>0; k--) {
3144 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
3145 parent->removeItem( myXmlHandler->myIdList.Value(k) );
3150 if (myActiveMenus) {
3151 int nbtoolbars = myActiveMenus->getToolBarList().count();
3152 for (int k=0; k<nbtoolbars; k++) {
3153 myActiveMenus->getToolBarList().at(k)->hide();
3154 myActiveMenus->getToolBarList().at(k)->clear();
3156 myActiveMenus->clearToolBar();
3159 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
3160 QAD_ListPopupMenu* aPopup;
3161 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
3162 aPopup->getPopup()->clear();
3165 myActiveMenus->clearPopupMenu();
3171 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3173 Exports Key Events in active component ( GUI Librairy )
3175 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
3177 // MESSAGE ( "QAD_Desktop::onKeyPress" )
3178 if (!myActiveComp.isEmpty()) {
3179 OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress");
3180 if ( osdF != NULL ) {
3181 TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3182 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3187 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3189 Exports Mouse Press Events in active component ( GUI Librairy )
3191 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
3193 // MESSAGE ( "QAD_Desktop::onMousePress" )
3194 if (!myActiveComp.isEmpty()) {
3195 OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress");
3196 if ( osdF != NULL ) {
3197 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3198 return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3205 Exports Mouse Move Events in active component ( GUI Librairy )
3207 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
3209 if (!myActiveComp.isEmpty()) {
3210 OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove");
3211 if ( osdF != NULL ) {
3212 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3213 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3219 Returns name of active component
3221 const QString& QAD_Desktop::getActiveComponent() const
3223 return myActiveComp;
3227 typedef bool defineP( QString & theContext, QString & theParent, QString & theObject);
3229 void QAD_Desktop::definePopup(QString & theContext,
3230 QString & theParent,
3231 QString & theObject )
3233 if (!myActiveComp.isEmpty()) {
3234 OSD_Function osdF = mySharedLibrary.DlSymb("definePopup");
3235 if ( osdF != NULL ) {
3236 defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF;
3237 (*f1)(theContext, theParent, theObject);
3245 void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
3246 QString text, int popupID, bool separator)
3248 QMenuItem* item = popup->findItem(popupID);
3250 QPopupMenu* popupChild = item->popup();
3252 QPopupMenu* newPopup = new QPopupMenu;
3253 int count = popupChild->count();
3254 // add items at the top of <popupFather>
3255 for (int i = count - 1; i >= 0; i--) {
3256 int j = popupChild->idAt(i);
3257 QString text = popupChild->text(j);
3258 createPopup( newPopup, popupChild, text, j);
3260 popupFather->insertItem(popup->text(popupID),
3261 newPopup, popupID, 0);
3263 if ( !text.isNull() ) {
3264 popupFather->insertItem(popup->text(popupID),
3266 SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top
3267 } /*else if ( separator )
3268 popupFather->insertTearOffHandle(-1, 0);*/
3270 popupFather->insertSeparator(0);
3278 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
3279 const QString & theParent, const QString & theObject )
3281 if ( !myActiveComp.isEmpty() &&
3282 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
3283 QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup();
3284 int count = aPopup->count();
3286 //for (int i = 0; i < count; i++) {
3287 for (int i = count - 1; i >= 0; i--) {
3288 int id = aPopup->idAt(i);
3289 QString text = aPopup->text(id);
3290 //QString mes("Inserting popup menu item loaded from XML: ");
3292 //MESSAGE ( mes.latin1() )
3294 popup->insertItem(aPopup->text(id),
3296 SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top
3298 createPopup( popup, aPopup, text, id);
3301 //QString mes("Popup does not exist for given (Context = ");
3302 //mes += theContext;
3303 //mes += ", Parent = ";
3305 //mes += ", Object = ";
3307 //MESSAGE (mes.latin1())
3312 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3313 if ( myActiveComp.isEmpty() ) {
3314 popup->removeItem(QAD_Display_Popup_ID);
3315 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3316 popup->removeItem(QAD_Erase_Popup_ID);
3317 int id = popup->idAt(popup->count()-1); // last item
3318 if (id < 0 && id != -1) popup->removeItem(id); // separator
3320 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3321 if ( popup->count()>0 ) {
3322 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3323 popup->insertSeparator (3);
3326 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3333 typedef bool activeStudyChanged(QAD_Desktop*);
3335 void QAD_Desktop::onActiveStudyChanged()
3337 if (!myActiveComp.isEmpty()) {
3338 OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged");
3339 if ( osdF != NULL ) {
3340 activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF;
3346 typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext,
3347 const QString & theParent, const QString & theObject);
3349 Custom popup ( GUI Library )
3351 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3352 const QString & theParent, const QString & theObject)
3354 if (!myActiveComp.isEmpty()) {
3355 OSD_Function osdF = mySharedLibrary.DlSymb("customPopup");
3356 if ( osdF != NULL ) {
3357 customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &,
3358 const QString &, const QString &)) osdF;
3359 (*f1)(this, popup, theContext, theParent, theObject);
3364 void QAD_Desktop::onObjectBrowser()
3366 bool checkDiff = false;
3368 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3370 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3374 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3376 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3379 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3383 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3385 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3388 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3392 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3394 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3397 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3400 /* To sort created object in chrono order or reverse chrono order */
3401 bool showCHRONO_SORT ;
3402 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3403 showCHRONO_SORT = true;
3404 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "true");
3406 showCHRONO_SORT = false;
3407 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "false");
3410 /* To show or not to show UseCase browser */
3412 if ( myStdActions.at( PrefObjectBrowserShowUseCaseId )->isOn() ) {
3414 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "true");
3416 showUseCase = false;
3417 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "false");
3420 /* Resize or don't resize columns automatically */
3422 if ( myStdActions.at( PrefObjectBrowserNoAutoSizeColumnsId )->isOn() ) {
3424 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "true");
3427 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "false");
3430 if ( myActiveApp ) {
3431 QList<QAD_Study>& studies = myActiveApp->getStudies();
3432 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3433 int nbSf = study->getStudyFramesCount();
3434 for ( int i = 0; i < nbSf; i++ ) {
3435 QAD_StudyFrame* sf = study->getStudyFrame(i);
3436 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3437 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3438 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3439 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3440 sf->getLeftFrame()->getObjectBrowser()->showUseCaseBrowser( showUseCase );
3441 sf->getLeftFrame()->getObjectBrowser()->autoSizeColumns( autoSize );
3443 study->updateObjBrowser(true);
3448 void QAD_Desktop::onViewerTrihedron()
3450 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3453 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3454 if (!Size.isEmpty())
3455 Dlg->setTrihedronSize(Size.toInt());
3456 int r = Dlg->exec();
3457 dim = Dlg->getTrihedronSize();
3460 if (r == QDialog::Accepted) {
3461 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3464 QList<QAD_Study>& studies = myActiveApp->getStudies();
3465 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3466 int nbSf = study->getStudyFramesCount();
3467 for ( int i = 0; i < nbSf; i++ ) {
3468 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->onAdjustTrihedron();
3475 void QAD_Desktop::onExternalBrowser()
3478 QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3479 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3481 SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
3483 if (!theApp.isEmpty())
3485 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3486 Dlg->setSettings(theApp, theParams);
3488 int r = Dlg->exec();
3489 QString theAppFromDialog = Dlg->getApp();
3490 QString theParamsFromDialog = Dlg->getParams();
3493 if (r == QDialog::Accepted)
3495 QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
3496 QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
3502 void QAD_Desktop::onDirList()
3504 // getting dir list from settings
3505 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3506 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3507 dlg->setPathList(dirList);
3508 if ( dlg->exec() == QDialog::Accepted) {
3509 dlg->getPathList(dirList);
3510 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3515 void QAD_Desktop::onConsoleFontAction()
3517 // getting font from settings
3518 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3519 QFont font = QAD_Tools::stringToFont( fntSet );
3521 font = QFontDialog::getFont( &bOk, font, this );
3523 fntSet = QAD_Tools::fontToString( font );
3524 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3527 QList<QAD_Study>& studies = myActiveApp->getStudies();
3528 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3529 int nbSf = study->getStudyFramesCount();
3530 for ( int i = 0; i < nbSf; i++ ) {
3531 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3532 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3539 void QAD_Desktop::onSavePref()
3541 QAD_CONFIG->createConfigFile(true);
3544 //VRV: T2.5 - add default viewer
3545 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3547 int type = VIEW_TYPE_MAX;
3550 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3552 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3554 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3555 type = VIEW_GRAPHSUPERV;
3556 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3558 if ( type != VIEW_TYPE_MAX )
3559 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3561 //VRV: T2.5 - add default viewer
3563 void QAD_Desktop::onViewerOCC()
3565 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3566 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3567 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3570 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3571 color = QColor(BackgroundColorRed.toInt(),
3572 BackgroundColorGreen.toInt(),
3573 BackgroundColorBlue.toInt());
3575 color = QColor(35, 136, 145);
3577 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3580 if ( myActiveApp ) {
3581 QList<QAD_Study>& studies = myActiveApp->getStudies();
3582 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3583 int nbSf = study->getStudyFramesCount();
3584 for ( int i = 0; i < nbSf; i++ ) {
3585 QAD_StudyFrame* sf = study->getStudyFrame(i);
3586 if ( sf->getTypeView() == VIEW_OCC ) {
3587 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3592 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3593 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3594 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3598 void QAD_Desktop::onGraphSupervisor()
3600 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3601 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3602 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3605 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3606 color = QColor(BackgroundColorRed.toInt(),
3607 BackgroundColorGreen.toInt(),
3608 BackgroundColorBlue.toInt());
3610 color = QColor(35, 136, 145);
3612 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3615 if ( myActiveApp ) {
3616 QList<QAD_Study>& studies = myActiveApp->getStudies();
3617 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3618 int nbSf = study->getStudyFramesCount();
3619 for ( int i = 0; i < nbSf; i++ ) {
3620 QAD_StudyFrame* sf = study->getStudyFrame(i);
3621 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3622 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3628 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3629 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3630 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3634 void QAD_Desktop::onViewerVTK()
3636 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3637 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3638 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3641 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3642 color = QColor(BackgroundColorRed.toInt(),
3643 BackgroundColorGreen.toInt(),
3644 BackgroundColorBlue.toInt());
3646 color = QColor(0, 0, 0);
3648 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3651 if ( myActiveApp ) {
3652 QList<QAD_Study>& studies = myActiveApp->getStudies();
3653 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3654 int nbSf = study->getStudyFramesCount();
3655 for ( int i = 0; i < nbSf; i++ ) {
3656 QAD_StudyFrame* sf = study->getStudyFrame(i);
3657 if ( sf->getTypeView() == VIEW_VTK ) {
3658 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3664 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3665 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3666 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3670 void QAD_Desktop::onPlot2d()
3673 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3674 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3675 QStringList bgData = QStringList::split( ":", bgString, true );
3676 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3677 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3678 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3679 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3680 color = QColor( bgRed, bgGreen, bgBlue );
3683 color = QColor(0, 0, 0);
3686 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3688 if ( color.isValid() ) {
3689 if ( myActiveApp ) {
3690 QList<QAD_Study>& studies = myActiveApp->getStudies();
3691 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3692 int nbSf = study->getStudyFramesCount();
3693 for ( int i = 0; i < nbSf; i++ ) {
3694 QAD_StudyFrame* sf = study->getStudyFrame(i);
3695 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3696 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3702 bgData.append( QString::number( color.red() ) );
3703 bgData.append( QString::number( color.green() ) );
3704 bgData.append( QString::number( color.blue() ) );
3705 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3710 void QAD_Desktop::helpAbout()
3712 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3717 // /* Help Search */
3718 // void QAD_Desktop::helpSearch()
3722 // /* Help Contents */
3723 // void QAD_Desktop::helpContents()
3725 // if (myActiveComp == "")
3726 // myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3730 // if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3731 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3732 // if ( QFileInfo( root + "index.html" ).exists() ) {
3733 // helpContext( root + "index.html", "" );
3736 // root = QAD_Tools::addSlash( root + "html" );
3737 // if ( QFileInfo( root + "index.html" ).exists() ) {
3738 // helpContext( root + "index.html", "" );
3741 // root = QAD_Tools::addSlash( root + "html" );
3742 // if ( QFileInfo( root + "index.html" ).exists() ) {
3743 // helpContext( root + "index.html", "" );
3749 // // //NRI getHelpWindow()->contents();
3750 // // getHelpWindow()->show();
3751 // // getHelpWindow()->raise();
3752 // // getHelpWindow()->setActiveWindow();
3756 //void QAD_Desktop::helpContext(const QString& source, const QString& context)
3758 // //getHelpWindow()->context(source, context); //implemented in QAD_HelpWindow::context( const QString& _source, const QString& _context)
3759 // //getHelpWindow()->show(); //from QMainWindow class
3760 // //getHelpWindow()->raise(); //from QMainWindow class
3761 // //getHelpWindow()->setActiveWindow(); //from QMainWindow class
3763 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3764 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3766 // RunBrowser* rs = new RunBrowser(anApp, aParams, source, context);
3770 /* Preferences/MultiFile Save */
3771 void QAD_Desktop::onMultiFileSave()
3773 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3774 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3776 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3779 /* Preferences/ASCII Save */
3780 void QAD_Desktop::onASCIISave()
3782 if ( myStdActions.at( PrefASCIISave )->isOn() )
3783 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3785 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3788 /* Preferences / Undo Level */
3789 void QAD_Desktop::onUndoLevel()
3791 static int MAX_UNDO_LEVEL = 1000;
3792 bool isAccepted = false;
3793 static QString aLabel = QString("Level value (%1 ... %2) : ").
3794 arg(1).arg(MAX_UNDO_LEVEL);
3796 SALOMEGUI_SetValueDlg::getInteger("Undo Level",aLabel,
3797 1,MAX_UNDO_LEVEL,getUndoLevel(),
3799 if(!isAccepted) return;
3800 QAD_CONFIG->addSetting("Desktop:UndoLevel", anUndoLevel);
3801 if(!myActiveApp) return;
3802 QList<QAD_Study>& studies = myActiveApp->getStudies();
3803 int aWasWarning = 0;
3804 for(QAD_Study* study = studies.first(); study; study = studies.next()){
3805 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
3806 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDoc->NewBuilder();
3807 if (!aStudyDoc->GetProperties()->IsLocked()) {
3808 aStudyBuilder->UndoLimit(anUndoLevel);
3811 QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
3812 QObject::tr("WRN_WARNING"),
3813 QObject::tr("WRN_STUDY_LOCKED"),
3814 QObject::tr("BUT_OK"));
3821 /*********************************************************************
3822 ** Class: AppSelectionDlg
3823 ** Descr: Dialog for the selection of the application when several
3824 ** applications exist in the desktop and new study creation
3825 ** is activated by user.
3827 **********************************************************************/
3829 \class Desktop_AppSelectionDlg QAD_Desktop.h
3830 \brief Dialog for the selection of the application when several
3831 applications exist in the desktop and new study creation
3832 is activated by user.
3837 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
3838 QList<QAD_Application>& apps ) :
3839 QDialog( desktop, 0, true ),
3843 QAD_ASSERT_DEBUG_ONLY ( desktop );
3844 setCaption( tr("INF_DESK_DOC_CREATE") );
3845 if ( desktop->icon() )
3846 setIcon( *desktop->icon() );
3848 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
3850 /* Create selection buttons */
3851 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
3852 buttonGrp->setExclusive ( true );
3853 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
3854 vLayout->addWidget ( buttonGrp );
3856 /* Create selection button for available app */
3858 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
3860 /* add radio button for application */
3861 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
3862 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
3865 /* make the first application selected */
3866 buttonGrp->setButton( 0 );
3868 /* listen to the selection */
3869 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
3871 /* Create OK/Cancel buttons
3873 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
3874 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
3875 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
3876 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
3877 buttonOK->setDefault( true );
3879 hLayout->addStretch();
3880 hLayout->addWidget( buttonOK );
3881 hLayout->addWidget( buttonCancel );
3882 hLayout->addWidget( buttonHelp );
3884 /* connect buttons */
3885 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
3886 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
3887 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
3889 /* disable resizing */
3890 setFixedSize( 0, 0 );
3891 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
3894 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
3898 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
3900 return myApps.at( myAppId );
3903 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
3905 QAD_Tools::centerWidget( this, parentWidget() );
3911 void Desktop_AppSelectionDlg::onAppSelected( int id )
3916 void Desktop_AppSelectionDlg::onHelp()