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