Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4UIcmdWith3Vector << 27 // 23 // 28 // Author: M.Asai, 1998 << 24 // $Id: G4UIcmdWith3Vector.cc,v 1.5 2003/06/16 16:55:36 gunter Exp $ 29 // ------------------------------------------- << 25 // GEANT4 tag $Name: geant4-05-02-patch-01 $ >> 26 // >> 27 // 30 28 31 #include "G4UIcmdWith3Vector.hh" 29 #include "G4UIcmdWith3Vector.hh" >> 30 #include <strstream> 32 31 33 // ------------------------------------------- << 32 G4UIcmdWith3Vector::G4UIcmdWith3Vector 34 G4UIcmdWith3Vector::G4UIcmdWith3Vector(const c << 33 (const char * theCommandPath,G4UImessenger * theMessenger) 35 : G4UIcommand(theCommandPath, theMessenger) << 34 :G4UIcommand(theCommandPath,theMessenger) 36 { 35 { 37 auto* dblParamX = new G4UIparameter('d'); << 36 G4UIparameter * dblParamX = new G4UIparameter('d'); 38 SetParameter(dblParamX); 37 SetParameter(dblParamX); 39 auto* dblParamY = new G4UIparameter('d'); << 38 G4UIparameter * dblParamY = new G4UIparameter('d'); 40 SetParameter(dblParamY); 39 SetParameter(dblParamY); 41 auto* dblParamZ = new G4UIparameter('d'); << 40 G4UIparameter * dblParamZ = new G4UIparameter('d'); 42 SetParameter(dblParamZ); 41 SetParameter(dblParamZ); 43 SetCommandType(With3VectorCmd); << 44 } 42 } 45 43 46 // ------------------------------------------- << 47 G4ThreeVector G4UIcmdWith3Vector::GetNew3Vecto 44 G4ThreeVector G4UIcmdWith3Vector::GetNew3VectorValue(const char* paramString) 48 { 45 { 49 return ConvertTo3Vector(paramString); << 46 G4double vx; >> 47 G4double vy; >> 48 G4double vz; >> 49 std::istrstream is((char*)paramString); >> 50 is >> vx >> vy >> vz; >> 51 return G4ThreeVector(vx,vy,vz); >> 52 } >> 53 >> 54 G4String G4UIcmdWith3Vector::ConvertToString(G4ThreeVector vec) >> 55 { >> 56 char st[100]; >> 57 std::ostrstream os(st,100); >> 58 os << vec.x() << " " << vec.y() << " " << vec.z() << '\0'; >> 59 G4String vl = st; >> 60 return vl; 50 } 61 } 51 62 52 // ------------------------------------------- << 63 void G4UIcmdWith3Vector::SetParameterName 53 void G4UIcmdWith3Vector::SetParameterName(cons << 64 (const char * theNameX,const char * theNameY,const char * theNameZ, 54 cons << 65 G4bool omittable,G4bool currentAsDefault) 55 G4bo << 56 { 66 { 57 G4UIparameter* theParamX = GetParameter(0); << 67 G4UIparameter * theParamX = GetParameter(0); 58 theParamX->SetParameterName(theNameX); 68 theParamX->SetParameterName(theNameX); 59 theParamX->SetOmittable(omittable); 69 theParamX->SetOmittable(omittable); 60 theParamX->SetCurrentAsDefault(currentAsDefa 70 theParamX->SetCurrentAsDefault(currentAsDefault); 61 G4UIparameter* theParamY = GetParameter(1); << 71 G4UIparameter * theParamY = GetParameter(1); 62 theParamY->SetParameterName(theNameY); 72 theParamY->SetParameterName(theNameY); 63 theParamY->SetOmittable(omittable); 73 theParamY->SetOmittable(omittable); 64 theParamY->SetCurrentAsDefault(currentAsDefa 74 theParamY->SetCurrentAsDefault(currentAsDefault); 65 G4UIparameter* theParamZ = GetParameter(2); << 75 G4UIparameter * theParamZ = GetParameter(2); 66 theParamZ->SetParameterName(theNameZ); 76 theParamZ->SetParameterName(theNameZ); 67 theParamZ->SetOmittable(omittable); 77 theParamZ->SetOmittable(omittable); 68 theParamZ->SetCurrentAsDefault(currentAsDefa 78 theParamZ->SetCurrentAsDefault(currentAsDefault); 69 } 79 } 70 80 71 // ------------------------------------------- << 81 void G4UIcmdWith3Vector::SetDefaultValue(G4ThreeVector vec) 72 void G4UIcmdWith3Vector::SetDefaultValue(const << 73 { 82 { 74 G4UIparameter* theParamX = GetParameter(0); << 83 G4UIparameter * theParamX = GetParameter(0); 75 theParamX->SetDefaultValue(vec.x()); 84 theParamX->SetDefaultValue(vec.x()); 76 G4UIparameter* theParamY = GetParameter(1); << 85 G4UIparameter * theParamY = GetParameter(1); 77 theParamY->SetDefaultValue(vec.y()); 86 theParamY->SetDefaultValue(vec.y()); 78 G4UIparameter* theParamZ = GetParameter(2); << 87 G4UIparameter * theParamZ = GetParameter(2); 79 theParamZ->SetDefaultValue(vec.z()); 88 theParamZ->SetDefaultValue(vec.z()); 80 } 89 } >> 90 81 91