void ViewHelpMenu::endEvent() { ViewerSettings settings; settings.beginGroup("WinStyle"); settings.setValue("StyleName",getStyleName()); settings.endGroup(); }
void ViewCameraGL::endEvent() { ViewerSettings settings; settings.beginGroup("Camera"); settings.setValue("AutoFit",!isDimLock()); settings.setValue("PglRefSystem",__geomsys); settings.setValue("ResizePolicy",(int)__resizePolicy); settings.endGroup(); }
void ViewCameraGL::init() { ViewerSettings settings; settings.beginGroup("Camera"); bool autofit = settings.value("AutoFit",!__lockdim).toBool(); __geomsys = settings.value("PglRefSystem",__geomsys).toBool(); lockDim(!autofit); __resizePolicy = (eCameraResizePolicy)settings.value("ResizePolicy",(int)__resizePolicy).toInt(); settings.endGroup(); }
ViewHelpMenu::ViewHelpMenu(QWidget * parent, QGLWidget * glwidget, const char * name) : QMenu(parent), __glwidget(glwidget) { if(name) setObjectName(name); __about = new ViewAboutDialog(this,false); QObject::connect(__about,SIGNAL(licenseView()),this,SLOT(showLicense())); addAction( tr("What's &This?"), parent->parent() , SLOT(whatsThis()), Qt::Key_F1); addAction(QPixmap(ViewSysInfo::tools_logo),tr("&Help"),this,SLOT(showHelp()),Qt::SHIFT+Qt::Key_F1); addSeparator(); addAction(QPixmap(ViewerIcon::getPixmap(ViewerIcon::flower)),tr("&About Viewer"),this,SLOT(showAbout()), Qt::CTRL+Qt::Key_F1); addAction(tr("&License"),this,SLOT(showLicense())); addAction(QPixmap(ViewSysInfo::qt_logo),tr("About &Qt"),this,SLOT(aboutQt())); // addAction(QPixmap(ViewSysInfo::qt_logo),tr("About &QGLViewer"),glwidget,SLOT(aboutQGLViewer())); addSeparator(); addAction(QPixmap(ViewSysInfo::info_logo),tr("Technical Characteristics"),this,SLOT(generalInfo())); // addAction(QPixmap(ViewSysInfo::qt_logo),tr("Qt Hierarchy"),this,SLOT(qtbrowse())); addSeparator(); __style = new QMenu(this); __style->setTitle(tr("Style")); addMenu(__style); QStringList styles = QStyleFactory::keys(); QActionGroup * actiongroup = new QActionGroup(__style); actiongroup->setExclusive(true); QAction * action = NULL; for(uint k = 0 ; k < styles.size(); k++){ action = __style->addAction(styles[k]); action->setCheckable(true); actiongroup->addAction(action); __ids.push_back( action ); } __style->addSeparator(); action = __style->addAction("Default"); action->setCheckable(true); actiongroup->addAction(action); __ids.push_back( action ); default_style_name = QApplication::style()->metaObject()->className(); checkItem(__ids.size()-1); ViewerSettings settings; settings.beginGroup("WinStyle"); QString stylename = settings.value("StyleName","Default").toString(); settings.endGroup(); setStyle(stylename); QObject::connect(__style,SIGNAL(triggered(QAction *)),this,SLOT(setStyleCorrespondingTo(QAction*))); }
void Viewer::initialize() { // qt_set_sequence_auto_mnemonic (true); setWindowIcon(QPixmap(ViewerIcon::getPixmap(ViewerIcon::flower))); setWhatsThis(tr("<b>The PlantGL 3D Viewer</b><br><br>" "A Viewer for 3D scene.<br><br>")); setGeometry(50,50,780,675); __isFullScreen = false; __focusAtRefresh = true; __GLFrame->setGeometry(0,58,724,574); __GLFrame->setWhatsThis(tr("<b>The 3D Display</b><br><br>" "This frame displays the 3D scenes.<br><br>" "Pressing button of the mouse and moving allows you to move around the scene :<br>" "Press <i>Left Button</i> to rotate.<br>" "Press <i>Middle Button</i> to zoom.<br>" "Press <i>Rigth Button</i> to translate.<br><br>" "The same manipulation and pressing the Ctrl Key allows you to control the light source.<br><br>" "The same manipulation and pressing the Shift Key allows you to select shapes from the scene.<br>" )); setCentralWidget(__GLFrame); __GLFrame->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); __GLFrame->sizePolicy().setHorizontalStretch(3); // Control Group Box. __controlPanel = new ViewControlPanel(__GLFrame,"Control Panel",this); __controlPanel->setWhatsThis(tr("<b>The Control Panel</b><br><br>" "This panel shows you parameters from the <i>ligth source</i>, its position and its material.<br><br>" "It shows also parameters from the position of the <i>camera</i> " "and the size of an <i>unitary move</i> and of the <i>unit of the grid</i>")); addDockWidget(Qt::RightDockWidgetArea,__controlPanel); //menubar __MainMenu = new QMenuBar( this); setMenuBar(__MainMenu); __HelpMenu = new ViewHelpMenu(__MainMenu,__GLFrame,"Help Menu"); QObject::connect(__GLFrame,SIGNAL(initMessage(const QString&)), __HelpMenu,SLOT(setInitText(const QString&)) ); __GLFrame->rendererStatus(); __FileMenu = new ViewFileManager(this, "File Operation", __GLFrame, __HelpMenu, __controlPanel); QToolBar * locatToolBar = __FileMenu->getLocationBar(); addToolBar(Qt::TopToolBarArea,locatToolBar); addToolBarBreak(); __GLFrame->addOtherToolBar(this); addToolBarBreak(); /// ToolBar __ViewToolBar = new ViewToolBar("View ToolBar",this,"ViewToolBar"); __ViewToolBar->setIconSize(QSize(32,32)); addToolBar(__ViewToolBar); /// ToolBar __FileToolBar = new ViewToolBar("File ToolBar",this,"FileToolBar"); __FileToolBar->setIconSize(QSize(32,32)); addToolBar(__FileToolBar); __GLFrame->connectTo(__ErrorDialog); __FileMenu->connectTo(__ErrorDialog); // Preparation de la boite de dialog Object Browser __Browser= new ViewBrowser(this, "Object Browser"); __Browser->setWhatsThis(tr("<b>Viewer Object Browser</b><br><br>" "This frame displays the structure and the parameters of the 3D scenes.<br><br>" "Double clicking on one of the shape will select it" )); setCorner(Qt::BottomRightCorner,Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea,__Browser); // __Browser->setFloating(true); __Browser->hide(); // * View Menu // - Camera __ViewMenu = new QMenu( this ); // - ToolBar QAction * _ViewMenuAction = __ViewMenu->addAction(tr("&Menu Bar"),this,SLOT(displayMenuBar()),Qt::Key_F6); _ViewMenuAction->setCheckable(true); _ViewMenuAction->setChecked(true); _ViewMenuAction = __controlPanel->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F7); _ViewMenuAction = __FileToolBar->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F8); _ViewMenuAction = __ViewToolBar->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); // _ViewMenuAction->setShortcut(Qt::Key_F9); if(__FileMenu->getLocationBar()){ _ViewMenuAction = __FileMenu->getLocationBar()->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F10); } __ViewMenu->addSeparator(); // - Browser _ViewMenuAction = __Browser->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F2); _ViewMenuAction = __ErrorDialog->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F3); __ViewMenu->addSeparator(); #ifdef _WIN32 __ViewMenu->addAction(tr("&Debug Log"),this,SLOT(debugLog())); __ViewMenu->addSeparator(); #endif QMenu * FrameGLSize = new QMenu(tr("GL Frame Size"),__ViewMenu); __ViewMenu->addMenu(FrameGLSize); FrameGLSize->addAction(tr("800x600"),this,SLOT(set800x600FrameGL())); FrameGLSize->addAction(tr("640x480"),this,SLOT(set640x480FrameGL())); FrameGLSize->addAction(tr("512x384"),this,SLOT(set512x384FrameGL())); FrameGLSize->addAction(tr("320x240"),this,SLOT(set320x240FrameGL())); FrameGLSize->addSeparator(); FrameGLSize->addAction(tr("Customize"),this,SLOT(setCustomFrameGLSize()),Qt::Key_F4); __ViewMenu->addSeparator(); _ViewMenuAction = __ViewMenu->addAction(tr("GL Frame only"),this,SLOT(displayGLWidgetOnly()), Qt::Key_F10); QPixmap _fulls(ViewerIcon::getPixmap(ViewerIcon::fullscreen)); __actFullScreen = __ViewMenu->addAction(_fulls,tr("Full Screen"),this,SLOT(displayFullScreen()), Qt::Key_F11); // The Status Bar. __statusBar= new ViewStatusBar(this); __statusBar->showMessage(tr("Ready")); __statusBar->setWhatsThis(tr("<b>The Status Bar</b>")); setStatusBar(__statusBar); __GLFrame->connectTo(__statusBar); __FileMenu->connectTo(__statusBar); //Title setWindowTitle(tr("PlantGL 3D Viewer")); __trayIcon = new QSystemTrayIcon(QPixmap(ViewerIcon::getPixmap(ViewerIcon::flower)),this); __trayIcon->setToolTip("PlantGL Viewer"); QMenu * trayMenu = new QMenu(this); trayMenu->addAction(tr("About PlantGL Viewer ..."),__HelpMenu,SLOT(showAbout())); trayMenu->addSeparator(); trayMenu->addAction(tr("GL Frame only"),this,SLOT(displayGLWidgetOnly())); trayMenu->addAction(tr("Full Screen"),this,SLOT(displayFullScreen())); trayMenu->addSeparator(); trayMenu->addAction(tr("Unique PGL Windows"),this,SLOT(startDaemon())); trayMenu->addAction(tr("Multiple PGL Windows"),this,SLOT(stopDaemon())); trayMenu->addSeparator(); trayMenu->addAction(tr("Exit"),this,SLOT(bye())); __trayIcon->setContextMenu(trayMenu); // __trayIcon->show(); __trayIcon->showMessage("PlantGL","PlantGL Viewer ... Ready",QSystemTrayIcon::Information,2000); QObject::connect(__trayIcon,SIGNAL(messageClicked()),this,SLOT(appear())); QObject::connect(__trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(appear())); initializeRenderer(); QObject::connect(__GLFrame,SIGNAL(rendererChanged()), this,SLOT(initializeRenderer()) ); ViewerSettings settings; settings.beginGroup("Viewer"); qDebug("Try to retrieve %s Application Data.", ViewerSettings::getAppliName().toAscii().data()); int version = settings.value("StateVersion",-1).toInt(); if(version != -1) { QRect rect = settings.value("Geometry",geometry()).toRect(); QRect maxrect = QApplication::desktop()->geometry(); if( maxrect.contains(rect) && rect.width() > 100 && rect.height() > 100){ setGeometry(rect); qDebug("MainWindow.setGeometry(%i,%i,%i,%i)", rect.x(),rect.y(),rect.width(),rect.height()); } QByteArray b = settings.value("State").toByteArray(); restoreState(b,version); qDebug("Restore State"); } else qDebug("Cannot restore State"); __focusAtRefresh = settings.value("FocusAtRefresh",__focusAtRefresh).toBool(); settings.endGroup(); }