G4VisCommandsViewerDefault.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4VisCommandsDefault.cc,v 1.4 2007-01-05 16:29:38 allison Exp $
00028 // GEANT4 tag $Name: not supported by cvs2svn $
00029 
00030 // /vis/default commands - John Allison  30th October 2011
00031 
00032 #include "G4VisCommandsViewerDefault.hh"
00033 
00034 #include "G4VisManager.hh"
00035 #include "G4UIcmdWithAString.hh"
00036 #include "G4UIcmdWithABool.hh"
00037 
00039 
00040 G4VisCommandViewerDefaultHiddenEdge::G4VisCommandViewerDefaultHiddenEdge()
00041 {
00042   G4bool omitable;
00043   fpCommand = new G4UIcmdWithABool("/vis/viewer/default/hiddenEdge", this);
00044   fpCommand->SetGuidance("Default hiddenEdge drawing for future viewers.");
00045   fpCommand->SetGuidance
00046     ("Edges become hidden/seen in wireframe or surface mode.");
00047   fpCommand->SetParameterName("hidden-edge",omitable = true);
00048   fpCommand->SetDefaultValue(true);
00049 }
00050 
00051 G4VisCommandViewerDefaultHiddenEdge::~G4VisCommandViewerDefaultHiddenEdge()
00052 {
00053   delete fpCommand;
00054 }
00055 
00056 G4String G4VisCommandViewerDefaultHiddenEdge::GetCurrentValue(G4UIcommand*)
00057 {
00058   return "";
00059 }
00060 
00061 void G4VisCommandViewerDefaultHiddenEdge::SetNewValue(G4UIcommand*, G4String newValue)
00062 {
00063   // Follows /vis/viewer/set/hiddenEdge
00064 
00065   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00066   G4ViewParameters vp = fpVisManager->GetDefaultViewParameters();
00067   G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
00068 
00069   if (G4UIcommand::ConvertToBool(newValue)) {
00070     switch (existingStyle) {
00071     case G4ViewParameters::wireframe:
00072       vp.SetDrawingStyle(G4ViewParameters::hlr);
00073       break;
00074     case G4ViewParameters::hlr:
00075       break;
00076     case G4ViewParameters::hsr:
00077       vp.SetDrawingStyle(G4ViewParameters::hlhsr);
00078       break;
00079     case G4ViewParameters::hlhsr:
00080       break;
00081     }
00082   }
00083   else {
00084     switch (existingStyle) {
00085     case G4ViewParameters::wireframe:
00086       break;
00087     case G4ViewParameters::hlr:
00088       vp.SetDrawingStyle(G4ViewParameters::wireframe);
00089       break;
00090     case G4ViewParameters::hsr:
00091       break;
00092     case G4ViewParameters::hlhsr:
00093       vp.SetDrawingStyle(G4ViewParameters::hsr);
00094       break;
00095     }
00096   }
00097 
00098   fpVisManager->SetDefaultViewParameters(vp);
00099 
00100   if (verbosity >= G4VisManager::confirmations) {
00101     G4cout << "Default drawing style set to " << vp.GetDrawingStyle()
00102            << G4endl;
00103   }
00104 }
00105 
00107 
00108 G4VisCommandViewerDefaultStyle::G4VisCommandViewerDefaultStyle()
00109 {
00110   G4bool omitable;
00111   fpCommand = new G4UIcmdWithAString("/vis/viewer/default/style", this);
00112   fpCommand->SetGuidance("Default drawing style for future viewers.");
00113   fpCommand->SetGuidance
00114     ("Set style of drawing - w[ireframe] or s[urface].");
00115   fpCommand->SetGuidance 
00116     ("(Default hidden line drawing is controlled by \"/vis/viewer/default/hiddenEdge\".)");
00117   fpCommand->SetParameterName ("style",omitable = false);
00118 }
00119 
00120 G4VisCommandViewerDefaultStyle::~G4VisCommandViewerDefaultStyle()
00121 {
00122   delete fpCommand;
00123 }
00124 
00125 G4String G4VisCommandViewerDefaultStyle::GetCurrentValue(G4UIcommand*)
00126 {
00127   return "";
00128 }
00129 
00130 void G4VisCommandViewerDefaultStyle::SetNewValue(G4UIcommand*, G4String newValue)
00131 {
00132   // Follows /vis/viewer/set/style
00133 
00134   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00135   G4ViewParameters vp = fpVisManager->GetDefaultViewParameters();
00136   G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
00137 
00138   const size_t iPos0 = 0;
00139   if (newValue[iPos0] == 'w') {  // "wireframe"
00140     switch (existingStyle) {
00141     case G4ViewParameters::wireframe:
00142       break;
00143     case G4ViewParameters::hlr:
00144       break;
00145     case G4ViewParameters::hsr:
00146       vp.SetDrawingStyle(G4ViewParameters::wireframe);
00147       break;
00148     case G4ViewParameters::hlhsr:
00149       vp.SetDrawingStyle(G4ViewParameters::hlr);
00150       break;
00151     }
00152   }
00153   else if (newValue[iPos0] == 's') {  // "surface"
00154     switch (existingStyle) {
00155     case G4ViewParameters::wireframe:
00156       vp.SetDrawingStyle(G4ViewParameters::hsr);
00157       break;
00158     case G4ViewParameters::hlr:
00159       vp.SetDrawingStyle(G4ViewParameters::hlhsr);
00160       break;
00161     case G4ViewParameters::hsr:
00162       break;
00163     case G4ViewParameters::hlhsr:
00164       break;
00165     }
00166   }
00167   else {
00168     if (verbosity >= G4VisManager::errors) {
00169       G4cout << "ERROR: \"" << newValue << "\" not recognised."
00170         "  Looking for 'w' or 's' first character." << G4endl;
00171     }
00172     return;
00173   }
00174 
00175   fpVisManager->SetDefaultViewParameters(vp);
00176 
00177   if (verbosity >= G4VisManager::confirmations) {
00178     G4cout << "Default drawing style set to " << vp.GetDrawingStyle()
00179            << G4endl;
00180   }
00181 }

Generated on Mon May 27 17:50:16 2013 for Geant4 by  doxygen 1.4.7