// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // $Id: G4OpenGLWtViewer.cc 75567 2013-11-04 11:35:11Z gcosmo $ // // // G4OpenGLWtViewer : Class to provide Wt specific // functionality for OpenGL in GEANT4 // // 27/06/2003 : G.Barrand : implementation (at last !). #ifdef G4VIS_BUILD_OPENGLWT_DRIVER #include "G4OpenGLWtViewer.hh" #include "G4VViewer.hh" #include "G4VSceneHandler.hh" #include "G4OpenGLSceneHandler.hh" #include "G4ios.hh" #include "G4VisExtent.hh" #include "G4LogicalVolume.hh" #include "G4VSolid.hh" #include "G4Point3D.hh" #include "G4Normal3D.hh" #include "G4Scene.hh" //#include "G4OpenGLWtExportDialog.hh" //#include "G4OpenGLWtMovieDialog.hh" #include "G4UnitsTable.hh" #include "G4Wt.hh" #include "G4UIWt.hh" #include "G4UImanager.hh" #include "G4UIcommandTree.hh" #include #include #include ////////////////////////////////////////////////////////////////////////////// void G4OpenGLWtViewer::CreateMainWindow ( Wt::WGLWidget* glWidget ,Wt::WString name ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLWtViewer::CreateMainWindow \n"); #endif if(fWindow) return; //Done. fWindow = glWidget ; // fWindow->makeCurrent(); // G4Wt* interactorManager = G4Wt::getInstance (); // return false if G4UIWt was not launch G4UImanager* UI = G4UImanager::GetUIpointer(); if (UI == NULL) return; if (! static_cast (UI->GetG4UIWindow())) { // NO UI, should be batch mode fBatchMode = true; return; } fUiWt = static_cast (UI->GetG4UIWindow()); bool isTabbedView = false; if ( fUiWt) { if (!fBatchMode) { // if (!interactorManager->IsExternalApp()) { // resize window to get the good size at the beginning ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY()); isTabbedView = fUiWt->AddTabWidget(fWindow->parent(),name,getWinWidth(),getWinHeight()); // change color fWindow->parent()->decorationStyle().setBackgroundColor (Wt::WColor("blue")); // Have to resize ! #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLWtViewer::CreateMainWindow :: resize :%d %d\n",getWinWidth(),getWinHeight()); #endif fWindow->resize(getWinWidth(),getWinHeight()); fUISceneTreeComponentsTBWidget = fUiWt->GetSceneTreeComponentsTBWidget(); fWindow->resize(fWindow->parent()->width(),fWindow->parent()->height()); isTabbedView = true; // } } } #ifdef G4DEBUG_VIS_OGL else { printf("G4OpenGLWtViewer::CreateMainWindow :: UIWt NOt found \n"); } #endif /* if (!isTabbedView) { // we have to do a dialog Wt::WWidget *myParent = getParentWidget(); #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLWtViewer::CreateMainWindow :: getParent OK \n"); #endif if (myParent != NULL) { glWidget->setParent(myParent); } Wt::WHBoxLayout *mainLayout = new Wt::WHBoxLayout(fGLWindow); mainLayout->setMargin(0); mainLayout->setSpacing(0); mainLayout->addWidget(fWindow); if (fGLWindow->inherits("Wt::WContainerWidget")) { fGLWindow->setWindowTitle( name); } fGLWindow->setLayout(mainLayout); */ /* //useful for MACOSX, we have to compt the menuBar height int offset = QApplication::desktop()->height() - QApplication::desktop()->availableGeometry().height(); G4int YPos= fVP.GetWindowAbsoluteLocationHintY(QApplication::desktop()->height()); if (fVP.GetWindowAbsoluteLocationHintY(QApplication::desktop()->height())< offset) { YPos = offset; } #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLQtViewer::CreateMainWindow :: resizing to %d %d \n",getWinWidth(), getWinHeight()); #endif fGLWindow->move(fVP.GetWindowAbsoluteLocationHintX(QApplication::desktop()->width()),YPos); */ // fGLWindow->show(); // } else { fGLWindow = fWindow; // } if(!fWindow) return; #ifdef _A_FINIR_FIXME if (!fContextMenu) createPopupMenu(); #endif } /** Close the dialog and set the pointer to NULL */ // void G4OpenGLWtViewer::dialogClosed() { // // fGLWindow = NULL; // } ////////////////////////////////////////////////////////////////////////////// G4OpenGLWtViewer::G4OpenGLWtViewer ( G4OpenGLSceneHandler& scene ) :G4VViewer (scene, -1) ,G4OpenGLViewer (scene) ,fWindow(0) ,fRecordFrameNumber(0) //#ifdef _A_FINIR_FIXME ,fContextMenu(0) ,fMouseAction(STYLE1) ,fDeltaRotation(1) ,fDeltaSceneTranslation(0.01) ,fDeltaDepth(0.01) ,fDeltaZoom(0.05) ,fDeltaMove(0.05) ,fHoldKeyEvent(false) ,fHoldMoveEvent(false) ,fHoldRotateEvent(false) ,fAutoMove(false) ,fEncoderPath("") ,fTempFolderPath("") ,fMovieTempFolderPath("") ,fSaveFileName("") ,fParameterFileName("mpeg_encode_parameter_file.par") ,fMovieParametersDialog(NULL) ,fRecordingStep(WAIT) ,fProcess(NULL) ,fNbMaxFramesPerSec(100) ,fNbMaxAnglePerSec(360) ,fLaunchSpinDelay(100) ,fXRot(0) ,fYRot(0) ,fNoKeyPress(true) ,fAltKeyPress(false) ,fControlKeyPress(false) ,fShiftKeyPress(false) ,fBatchMode(false) ,fUiWt(NULL) { // launch Wt if not G4Wt::getInstance (); // FIXME : all stuff with G4VIS_BUILD_OPENGL_ES_DRIVER // G4OpenGLViewer::SetView(this); #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLWtViewer::Create \n"); #endif fLastPos3 = Wt::WPoint(-1,-1); fLastPos2 = Wt::WPoint(-1,-1); fLastPos1 = Wt::WPoint(-1,-1); mMatrix.setToIdentity(); #ifdef _A_FINIR_FIXME initMovieParameters(); #endif fLastEventTime = new Wt::WTime(); #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLWtViewer::G4OpenGLWtViewer END\n"); #endif } void G4OpenGLWtViewer::resizeGL(int width, int height) { #ifdef G4DEBUG_VIS_OGL printf("G4OpenGLWtViewer resizeGL %d %d\n",width,height); #endif } ////////////////////////////////////////////////////////////////////////////// G4OpenGLWtViewer::~G4OpenGLWtViewer ( ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { #ifdef _A_FINIR_FIXME G4cout <addMenu("&Mouse actions"); fRotateAction = mMouseAction->addAction("Rotate"); fMoveAction = mMouseAction->addAction("Move"); fPickAction = mMouseAction->addAction("Pick"); WAction *shortcutsAction = mMouseAction->addAction("Show shortcuts"); fRotateAction->setCheckable(true); fMoveAction->setCheckable(false); fPickAction->setCheckable(false); shortcutsAction->setCheckable(false); fRotateAction->setChecked(true); fMoveAction->setChecked(false); fPickAction->setChecked(false); shortcutsAction->setChecked(false); WObject ::connect(fRotateAction, SIGNAL(triggered(bool)), this, SLOT(actionMouseRotate())); WObject ::connect(fMoveAction, SIGNAL(triggered(bool)), this, SLOT(actionMouseMove())); WObject ::connect(fPickAction, SIGNAL(triggered(bool)), this, SLOT(actionMousePick())); WObject ::connect(shortcutsAction, SIGNAL(triggered(bool)), this, SLOT(showShortcuts())); // === Style Menu === WMenu *mStyle = fContextMenu->addMenu("&Style"); WMenu *mRepresentation = mStyle->addMenu("&Representation"); WMenu *mProjection = mStyle->addMenu("&Projection"); WAction *polyhedron = mRepresentation->addAction("Polyhedron"); WAction *nurbs = mRepresentation->addAction("NURBS"); WAction *ortho = mProjection->addAction("Orthographic"); WAction *perspective = mProjection->addAction("Persepective"); // INIT mRepresentation G4ViewParameters::RepStyle style; style = fVP.GetRepStyle(); if (style == G4ViewParameters::polyhedron) { createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),1); } else if (style == G4ViewParameters::nurbs) { createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),2); } else { mRepresentation->clear(); } // INIT mProjection if (fVP.GetFieldHalfAngle() == 0) { createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),1); } else { createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),2); } // === Drawing Menu === WMenu *mDrawing = mStyle->addMenu("&Drawing"); fDrawingWireframe = mDrawing->addAction("Wireframe"); fDrawingWireframe->setCheckable(true); fDrawingLineRemoval = mDrawing->addAction("Hidden line removal"); fDrawingLineRemoval->setCheckable(true); fDrawingSurfaceRemoval = mDrawing->addAction("Hidden Surface removal"); fDrawingSurfaceRemoval->setCheckable(true); fDrawingLineSurfaceRemoval = mDrawing->addAction("Hidden line and surface removal"); fDrawingLineSurfaceRemoval->setCheckable(true); // INIT Drawing G4ViewParameters::DrawingStyle d_style; d_style = fVP.GetDrawingStyle(); if (d_style == G4ViewParameters::wireframe) { fDrawingWireframe->setChecked(true); } else if (d_style == G4ViewParameters::hlr) { fDrawingLineRemoval->setChecked(true); } else if (d_style == G4ViewParameters::hsr) { fDrawingSurfaceRemoval->setChecked(true); } else if (d_style == G4ViewParameters::hlhsr) { fDrawingLineSurfaceRemoval->setChecked(true); } else { mDrawing->clear(); } WObject ::connect(fDrawingWireframe, SIGNAL(triggered(bool)), this, SLOT(actionDrawingWireframe())); WObject ::connect(fDrawingLineRemoval, SIGNAL(triggered(bool)), this, SLOT(actionDrawingLineRemoval())); WObject ::connect(fDrawingSurfaceRemoval, SIGNAL(triggered(bool)), this, SLOT(actionDrawingSurfaceRemoval())); WObject ::connect(fDrawingLineSurfaceRemoval, SIGNAL(triggered(bool)), this, SLOT(actionDrawingLineSurfaceRemoval())); // Background Color WAction *backgroundColorChooser ; // === Action Menu === backgroundColorChooser = mStyle->addAction("Background color"); WObject ::connect(backgroundColorChooser, SIGNAL(triggered()), this, SLOT(actionChangeBackgroundColor())); // Text Color WAction *textColorChooser ; // === Action Menu === textColorChooser = mStyle->addAction("Text color"); WObject ::connect(textColorChooser, SIGNAL(triggered()), this, SLOT(actionChangeTextColor())); // Default Color WAction *defaultColorChooser ; // === Action Menu === defaultColorChooser = mStyle->addAction("Default color"); WObject ::connect(defaultColorChooser, SIGNAL(triggered()), this, SLOT(actionChangeDefaultColor())); // === Action Menu === WMenu *mActions = fContextMenu->addMenu("&Actions"); WAction *createEPS = mActions->addAction("Save as ..."); WObject ::connect(createEPS, SIGNAL(triggered()), this, SLOT(actionSaveImage())); // === Action Menu === WAction *movieParameters = mActions->addAction("Movie parameters..."); WObject ::connect(movieParameters, SIGNAL(triggered()), this, SLOT(actionMovieParameters())); // === Special Menu === WMenu *mSpecial = fContextMenu->addMenu("S&pecial"); WMenu *mTransparency = mSpecial->addMenu("Transparency"); WAction *transparencyOn = mTransparency->addAction("On"); WAction *transparencyOff = mTransparency->addAction("Off"); if (transparency_enabled == false) { createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),2); } else if (transparency_enabled == true) { createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),1); } else { mSpecial->clear(); } WMenu *mAntialiasing = mSpecial->addMenu("Antialiasing"); WAction *antialiasingOn = mAntialiasing->addAction("On"); WAction *antialiasingOff = mAntialiasing->addAction("Off"); if (antialiasing_enabled == false) { createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),2); } else if (antialiasing_enabled == true) { createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),1); } else { mAntialiasing->clear(); } WMenu *mHaloing = mSpecial->addMenu("Haloing"); WAction *haloingOn = mHaloing->addAction("On"); WAction *haloingOff = mHaloing->addAction("Off"); if (haloing_enabled == false) { createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),2); } else if (haloing_enabled == true) { createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),1); } else { mHaloing->clear(); } WMenu *mAux = mSpecial->addMenu("Auxiliary edges"); WAction *auxOn = mAux->addAction("On"); WAction *auxOff = mAux->addAction("Off"); if (!fVP.IsAuxEdgeVisible()) { createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),1); } else { createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),2); } WMenu *mFullScreen = mSpecial->addMenu("&Full screen"); fFullScreenOn = mFullScreen->addAction("On"); fFullScreenOff = mFullScreen->addAction("Off"); createRadioAction(fFullScreenOn,fFullScreenOff,SLOT(toggleFullScreen(bool)),2); } void G4OpenGLWtViewer::G4manageContextMenuEvent(WContextMenuEvent *e) { if (!fGLWindow) { G4cerr << "Visualization window not defined, please choose one before" << G4endl; } else { if (!fContextMenu) createPopupMenu(); // launch menu if ( fContextMenu ) { fContextMenu->exec( e->globalPos() ); // delete fContextMenu; } } e->accept(); } /** Create a radio button menu. The two menu will be connected. When click on one, eatch state will be invert and callback method will be called. @param action1 first action to connect @param action2 second action to connect @param method callback method @param nCheck: 1 : first action will be set true. 2 : second action will be set true */ void G4OpenGLWtViewer::createRadioAction(WAction *action1,WAction *action2, const std::string& method,unsigned int nCheck) { action1->setCheckable(true); action2->setCheckable(true); if (nCheck ==1) action1->setChecked (true); else action2->setChecked (true); WObject ::connect(action1, SIGNAL(triggered(bool)),action2, SLOT(toggle())); WObject ::connect(action2, SIGNAL(triggered(bool)),action1, SLOT(toggle())); WObject ::connect(action1, SIGNAL(toggled(bool)),this, method.c_str()); } /** Slot activate when mouseAction->rotate menu is set */ void G4OpenGLWtViewer::actionMouseRotate() { emit toggleMouseAction(STYLE1); } /** Slot activate when mouseAction->rotate menu is set */ void G4OpenGLWtViewer::actionMouseMove() { emit toggleMouseAction(STYLE2); } /** Slot activate when mouseAction->zoom menu is set */ void G4OpenGLWtViewer::actionMousePick() { emit toggleMouseAction(STYLE3); } /** Slot activate when drawing->wireframe menu is set */ void G4OpenGLWtViewer::actionDrawingWireframe() { emit toggleDrawingAction(1); } /** Slot activate when drawing->line removal menu is set */ void G4OpenGLWtViewer::actionDrawingLineRemoval() { emit toggleDrawingAction(2); } /** Slot activate when drawing->surface removal menu is set */ void G4OpenGLWtViewer::actionDrawingSurfaceRemoval() { emit toggleDrawingAction(3); } /** Slot activate when drawing->wireframe menu is set */ void G4OpenGLWtViewer::actionDrawingLineSurfaceRemoval() { emit toggleDrawingAction(4); } /** Slot activated when mouse action is toggle @param aAction : STYLE1, STYLE2, STYLE3 */ void G4OpenGLWtViewer::toggleMouseAction(mouseActions aAction) { if ((aAction == STYLE1) || //initialize all (aAction == STYLE2) || (aAction == STYLE3)) { fRotateAction->setChecked (false); fMoveAction->setChecked (false); fPickAction->setChecked (false); fVP.SetPicking(false); fMouseAction = aAction; } // rotate if (aAction == STYLE1) { // rotate showShortcuts(); fRotateAction->setChecked (true); } else if (aAction == STYLE2) { //move fMoveAction->setChecked (true); } else if (aAction == STYLE3) { //pick fPickAction->setChecked (true); fVP.SetPicking(true); } } #endif /** Show shortcuts for this mouse action */ void G4OpenGLWtViewer::showShortcuts() { G4cout << "========= Mouse Shortcuts =========" << G4endl; if (fMouseAction == STYLE1) { // rotate G4cout << "Click and move mouse to rotate volume " << G4endl; G4cout << "ALT + Click and move mouse to rotate volume (View Direction)" << G4endl; G4cout << "CTRL + Click and zoom mouse to zoom in/out" << G4endl; G4cout << "SHIFT + Click and zoommove camera point of view" << G4endl; } else if (fMouseAction == STYLE2) { //move G4cout << "Move camera point of view with mouse" << G4endl; } else if (fMouseAction == STYLE3) { //pick G4cout << "Click and pick " << G4endl; } G4cout << "========= Move Shortcuts =========" << G4endl; G4cout << "Press left/right arrows to move volume left/right" << G4endl; G4cout << "Press up/down arrows to move volume up/down" << G4endl; G4cout << "Press '+'/'-' to move volume toward/forward" << G4endl; G4cout << G4endl; G4cout << "========= Rotation (Theta/Phi) Shortcuts =========" << G4endl; G4cout << "Press SHIFT + left/right arrows to rotate volume left/right" << G4endl; G4cout << "Press SHIFT + up/down arrows to rotate volume up/down" << G4endl; G4cout << G4endl; G4cout << "========= Rotation (View Direction) Shortcuts =========" << G4endl; G4cout << "Press ALT + left/right to rotate volume around vertical direction" << G4endl; G4cout << "Press ALT + up/down to rotate volume around horizontal direction" << G4endl; G4cout << G4endl; G4cout << "========= Zoom View =========" << G4endl; G4cout << "Press CTRL + '+'/'-' to zoom into volume" << G4endl; G4cout << G4endl; G4cout << "========= Misc =========" << G4endl; G4cout << "Press ALT +/- to slow/speed rotation/move" << G4endl; G4cout << "Press H to reset view" << G4endl; G4cout << "Press Esc to exit FullScreen" << G4endl; G4cout << G4endl; G4cout << "========= Video =========" << G4endl; G4cout << "In video mode : " << G4endl; G4cout << " Press SPACE to Start/Pause video recording " << G4endl; G4cout << " Press RETURN to Stop video recording " << G4endl; G4cout << G4endl; } #ifdef _A_FINIR_FIXME /** Slot activated when drawing menu is toggle Warning : When G4OpenGLStoredWtViewer::DrawView() method call, KernelVisitDecision () will be call and will set the fNeedKernelVisit to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations. It will cause a redraw of the view @param aAction : 1 wireframe, 2 line removal, 3 surface removal, 4 line & surface removal @see G4OpenGLStoredWtViewer::DrawView @see G4XXXStoredViewer::CompareForKernelVisit */ void G4OpenGLWtViewer::toggleDrawingAction(int aAction) { G4ViewParameters::DrawingStyle d_style = G4ViewParameters::wireframe; // initialize if ((aAction >0) && (aAction <5)) { fDrawingWireframe->setChecked (false); fDrawingLineRemoval->setChecked (false); fDrawingSurfaceRemoval->setChecked (false); fDrawingLineSurfaceRemoval->setChecked (false); } if (aAction ==1) { fDrawingWireframe->setChecked (true); d_style = G4ViewParameters::wireframe; } else if (aAction ==2) { fDrawingLineRemoval->setChecked (true); d_style = G4ViewParameters::hlr; } else if (aAction ==3) { fDrawingSurfaceRemoval->setChecked (true); d_style = G4ViewParameters::hsr; } else if (aAction ==4) { fDrawingLineSurfaceRemoval->setChecked (true); d_style = G4ViewParameters::hlhsr; } fVP.SetDrawingStyle(d_style); updateWWidget(); } /** SLOT Activate by a click on the representation menu Warning : When G4OpenGLStoredWtViewer::DrawView() method call, KernelVisitDecision () will be call and will set the fNeedKernelVisit to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations. It will cause a redraw of the view @param check : 1 polyhedron, 0 nurbs @see G4OpenGLStoredWtViewer::DrawView @see G4XXXStoredViewer::CompareForKernelVisit */ void G4OpenGLWtViewer::toggleRepresentation(bool check) { G4ViewParameters::RepStyle style; if (check == 1) { style = G4ViewParameters::polyhedron; } else { style = G4ViewParameters::nurbs; } fVP.SetRepStyle (style); updateWWidget(); } /** SLOT Activate by a click on the projection menu Warning : When G4OpenGLStoredWtViewer::DrawView() method call, KernelVisitDecision () will be call and will set the fNeedKernelVisit to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations. It will cause a redraw of the view @param check : 1 orthographic, 2 perspective @see G4OpenGLStoredWtViewer::DrawView @see G4XXXStoredViewer::CompareForKernelVisit */ void G4OpenGLWtViewer::toggleProjection(bool check) { if (check == 1) { G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/projection o"); } else { G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/projection p"); } updateWWidget(); } /** SLOT Activate by a click on the transparency menu @param check : 1 , 0 */ void G4OpenGLWtViewer::toggleTransparency(bool check) { if (check) { transparency_enabled = false; } else { transparency_enabled = true; } SetNeedKernelVisit (true); updateWWidget(); } /** SLOT Activate by a click on the antialiasing menu @param check : 1 , 0 */ void G4OpenGLWtViewer::toggleAntialiasing(bool check) { if (!check) { antialiasing_enabled = false; glDisable (GL_LINE_SMOOTH); glDisable (GL_POLYGON_SMOOTH); } else { antialiasing_enabled = true; glEnable (GL_LINE_SMOOTH); glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); glEnable (GL_POLYGON_SMOOTH); glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); } updateWWidget(); } /** SLOT Activate by a click on the haloing menu @param check : 1 , 0 */ //FIXME : I SEE NOTHING... void G4OpenGLWtViewer::toggleHaloing(bool check) { if (check) { haloing_enabled = false; } else { haloing_enabled = true; } updateWWidget(); } /** SLOT Activate by a click on the auxiliaire edges menu @param check : 1 , 0 */ void G4OpenGLWtViewer::toggleAux(bool check) { if (check) { fVP.SetAuxEdgeVisible(true); } else { fVP.SetAuxEdgeVisible(false); } SetNeedKernelVisit (true); updateWWidget(); } /** SLOT Activate by a click on the full screen menu */ void G4OpenGLWtViewer::toggleFullScreen(bool check) { if (check != fGLWindow->isFullScreen()) { //toggle fGLWindow->setWindowState(fGLWindow->windowState() ^ Wt::WindowFullScreen); G4cerr << "This version of Wt could not do fullScreen. Resizing the widget is the only solution available." << G4endl; } } #endif #ifdef _A_FINIR_FIXME void G4OpenGLWtViewer::savePPMToTemp() { if (fMovieTempFolderPath == "") { return; } Wt::WString fileName ="Test"+Wt::WString::number(fRecordFrameNumber)+".ppm"; Wt::WString filePath =fMovieTempFolderPath+fileName; WImage image; image = fWindow->grabFrameBuffer(); bool res = false; res = image.save(filePath,0); if (res == false) { resetRecording(); setRecordingInfos("Can't save tmp file "+filePath); return; } setRecordingInfos("File "+fileName+" saved"); fRecordFrameNumber++; } void G4OpenGLWtViewer::actionSaveImage() { Wt::WString filters; WList formats = WImageWriter::supportedImageFormats (); for (int i = 0; i < formats.size(); ++i) { filters +=formats.at(i) + ";;"; } filters += "eps;;"; filters += "ps;;"; filters += "pdf"; Wt::WString* selectedFormat = new Wt::WString(); std::string name; name = WFileDialog::getSaveFileName ( fGLWindow, tr("Save as ..."), ".", filters, selectedFormat ).toUTF8().c_str(); // bmp jpg jpeg png ppm xbm xpm if (name.empty()) { return; } name += "." + selectedFormat->toUTF8(); Wt::WString format = selectedFormat->toLower(); setPrintFilename(name.c_str(),0); G4OpenGLWtExportDialog* exportDialog= new G4OpenGLWtExportDialog(fGLWindow,format,fWindow->height(),fWindow->width()); if( exportDialog->exec()) { WImage image; bool res = false; if ((exportDialog->getWidth() !=fWindow->width()) || (exportDialog->getHeight() !=fWindow->height())) { setPrintSize(exportDialog->getWidth(),exportDialog->getHeight()); if ((format != Wt::WString("eps")) && (format != Wt::WString("ps"))) { G4cerr << "Export->Change Size : This function is not implemented, to export in another size, please resize your frame to what you need" << G4endl; // rescaleImage(exportDialog->getWidth(),exportDialog->getHeight());// re-scale image // WGLWidget* glResized = fWindow; // FIXME : // L.Garnier : I've try to implement change size function, but the problem is // the renderPixmap function call the WGLWidget to resize and it doesn't draw // the content of this widget... It only draw the background. // fWindow->renderPixmap (exportDialog->getWidth()*2,exportDialog->getHeight()*2,true ); // WPixmap pixmap = fWindow->renderPixmap (); // image = pixmap->toImage(); // glResized->resize(exportDialog->getWidth()*2,exportDialog->getHeight()*2); // image = glResized->grabFrameBuffer(); } } else { image = fWindow->grabFrameBuffer(); } if (format == Wt::WString("eps")) { fVectoredPs = exportDialog->getVectorEPS(); printEPS(); } else if (format == "ps") { fVectoredPs = true; printEPS(); } else if (format == "pdf") { res = printPDF(name,exportDialog->getNbColor(),image); } else if ((format == "tif") || (format == "tiff") || (format == "jpg") || (format == "jpeg") || (format == "png") || (format == "pbm") || (format == "pgm") || (format == "ppm") || (format == "bmp") || (format == "xbm") || (format == "xpm")) { res = image.save(Wt::WString(name.c_str()),0,exportDialog->getSliderValue()); } else { G4cerr << "This version of G4UI Could not generate the selected format" << G4endl; } if ((format == Wt::WString("eps")) && (format == Wt::WString("ps"))) { if (res == false) { G4cerr << "Error while saving file... "<