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.3 2001/07/11 10:01:16 gunter Exp $ 29 // ------------------------------------------- << 25 // GEANT4 tag $Name: geant4-04-00 $ >> 26 // >> 27 // 30 28 31 #include "G4UIcmdWith3Vector.hh" 29 #include "G4UIcmdWith3Vector.hh" >> 30 #include "g4std/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 // ------------------------------------------- << 44 G4ThreeVector G4UIcmdWith3Vector::GetNew3VectorValue(G4String paramString) 47 G4ThreeVector G4UIcmdWith3Vector::GetNew3Vecto << 45 { >> 46 G4double vx; >> 47 G4double vy; >> 48 G4double vz; >> 49 const char* t = paramString; >> 50 G4std::istrstream is((char*)t); >> 51 is >> vx >> vy >> vz; >> 52 return G4ThreeVector(vx,vy,vz); >> 53 } >> 54 >> 55 G4String G4UIcmdWith3Vector::ConvertToString(G4ThreeVector vec) 48 { 56 { 49 return ConvertTo3Vector(paramString); << 57 char st[100]; >> 58 G4std::ostrstream os(st,100); >> 59 os << vec.x() << " " << vec.y() << " " << vec.z() << '\0'; >> 60 G4String vl = st; >> 61 return vl; 50 } 62 } 51 63 52 // ------------------------------------------- << 64 void G4UIcmdWith3Vector::SetParameterName 53 void G4UIcmdWith3Vector::SetParameterName(cons << 65 (const char * theNameX,const char * theNameY,const char * theNameZ, 54 cons << 66 G4bool omittable,G4bool currentAsDefault) 55 G4bo << 56 { 67 { 57 G4UIparameter* theParamX = GetParameter(0); << 68 G4UIparameter * theParamX = GetParameter(0); 58 theParamX->SetParameterName(theNameX); 69 theParamX->SetParameterName(theNameX); 59 theParamX->SetOmittable(omittable); 70 theParamX->SetOmittable(omittable); 60 theParamX->SetCurrentAsDefault(currentAsDefa 71 theParamX->SetCurrentAsDefault(currentAsDefault); 61 G4UIparameter* theParamY = GetParameter(1); << 72 G4UIparameter * theParamY = GetParameter(1); 62 theParamY->SetParameterName(theNameY); 73 theParamY->SetParameterName(theNameY); 63 theParamY->SetOmittable(omittable); 74 theParamY->SetOmittable(omittable); 64 theParamY->SetCurrentAsDefault(currentAsDefa 75 theParamY->SetCurrentAsDefault(currentAsDefault); 65 G4UIparameter* theParamZ = GetParameter(2); << 76 G4UIparameter * theParamZ = GetParameter(2); 66 theParamZ->SetParameterName(theNameZ); 77 theParamZ->SetParameterName(theNameZ); 67 theParamZ->SetOmittable(omittable); 78 theParamZ->SetOmittable(omittable); 68 theParamZ->SetCurrentAsDefault(currentAsDefa 79 theParamZ->SetCurrentAsDefault(currentAsDefault); 69 } 80 } 70 81 71 // ------------------------------------------- << 82 void G4UIcmdWith3Vector::SetDefaultValue(G4ThreeVector vec) 72 void G4UIcmdWith3Vector::SetDefaultValue(const << 73 { 83 { 74 G4UIparameter* theParamX = GetParameter(0); << 84 G4UIparameter * theParamX = GetParameter(0); 75 theParamX->SetDefaultValue(vec.x()); 85 theParamX->SetDefaultValue(vec.x()); 76 G4UIparameter* theParamY = GetParameter(1); << 86 G4UIparameter * theParamY = GetParameter(1); 77 theParamY->SetDefaultValue(vec.y()); 87 theParamY->SetDefaultValue(vec.y()); 78 G4UIparameter* theParamZ = GetParameter(2); << 88 G4UIparameter * theParamZ = GetParameter(2); 79 theParamZ->SetDefaultValue(vec.z()); 89 theParamZ->SetDefaultValue(vec.z()); 80 } 90 } >> 91 81 92