Ignore:
Timestamp:
May 20, 2010, 11:49:26 AM (14 years ago)
Author:
garnier
Message:

cvs update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/modeling/src/G4TrajectoryDrawerUtils.cc

    r1247 r1258  
    2424// ********************************************************************
    2525//
    26 // $Id: G4TrajectoryDrawerUtils.cc,v 1.13 2010/04/27 15:46:18 lgarnier Exp $
     26// $Id: G4TrajectoryDrawerUtils.cc,v 1.14 2010/05/11 11:58:18 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    4040#include "G4UIcommand.hh"
    4141#include "G4AttValue.hh"
     42#include <sstream>
    4243
    4344namespace G4TrajectoryDrawerUtils {
     
    7980    }
    8081  }
    81  
     82
     83  /***
    8284  void DrawLineAndPoints(const G4VTrajectory& traj, const G4int& i_mode, const G4Colour& colour, const G4bool& visible) {
    8385    // If i_mode>=0, draws a trajectory as a polyline (default is blue for
     
    8789    // given by std::abs(i_mode)/1000.  E.g: i_mode = 5000 gives easily
    8890    // visible markers.
     91
     92    static G4bool warnedAboutIMode = false;
     93    std::ostringstream oss;
     94    oss << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
     95        << ").  Feature will be removed at a future major release.";
     96    if (!warnedAboutIMode) {
     97      G4Exception
     98        ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, i_mode, colour, visible)",
     99         "",
     100         JustWarning,
     101         oss.str().c_str());
     102      warnedAboutIMode = true;
     103    }
    89104   
    90105    G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
     
    130145   
    131146  }
     147  ***/
    132148 
    133149  static void GetTimes(const G4VTrajectory& traj,
     
    146162
    147163      // Pre- and Post-Point times from the trajectory point...
    148       G4double trajectoryPointPreTime = -DBL_MAX;
    149       G4double trajectoryPointPostTime = DBL_MAX;
     164      G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
     165      G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
    150166      std::vector<G4AttValue>* trajectoryPointAttValues =
    151167        aTrajectoryPoint->CreateAttValues();
     
    356372  void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context, const G4int& i_mode)
    357373  {
     374    static G4bool warnedAboutIMode = false;
     375    std::ostringstream oss;
     376    oss << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
     377        << ").  Feature will be removed at a future major release.";
     378    if (!warnedAboutIMode) {
     379      G4Exception
     380        ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)",
     381         "",
     382         JustWarning,
     383         oss.str().c_str());
     384      warnedAboutIMode = true;
     385    }
     386
    358387    // Extra copy while i_mode is still around
    359388    G4VisTrajContext myContext(context);
     
    370399      myContext.SetAuxPtsSize(markerSize);
    371400      myContext.SetStepPtsSize(markerSize);
    372 
    373       static G4bool warnedAboutIMode = false;
    374 
    375       if (!warnedAboutIMode) {
    376         G4cout<<"Trajectory drawing configuration will be based on imode value of "<<i_mode<<G4endl;
    377         warnedAboutIMode = true;
    378       }
    379401    }
    380402
     
    421443    }
    422444  }
     445
     446  void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context)
     447  {
     448    // Return if don't need to do anything
     449    if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return;
     450   
     451    // Get points to draw
     452    G4Polyline trajectoryLine;
     453    G4Polymarker stepPoints;
     454    G4Polymarker auxiliaryPoints;
     455   
     456    GetPoints(traj, trajectoryLine, auxiliaryPoints, stepPoints);
     457   
     458    if (context.GetTimeSliceInterval()) {
     459
     460      // Get corresponding track time information, if any
     461      std::vector<G4double> trajectoryLineTimes;
     462      std::vector<G4double> stepPointTimes;
     463      std::vector<G4double> auxiliaryPointTimes;
     464 
     465      GetTimes(traj, trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
     466
     467      // Check validity
     468      if (trajectoryLineTimes.size() != trajectoryLine.size() ||
     469          stepPointTimes.size() != stepPoints.size() ||
     470          auxiliaryPointTimes.size() != auxiliaryPoints.size()) {
     471
     472        // Revert to drawing without time information...
     473        DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
     474      } else {
     475
     476        SliceLine(context.GetTimeSliceInterval(),
     477                  trajectoryLine, trajectoryLineTimes);
     478
     479        DrawWithTime(context,
     480                     trajectoryLine, auxiliaryPoints, stepPoints,
     481                     trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
     482      }
     483
     484    } else {
     485
     486      DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
     487
     488    }
     489  }
    423490}
Note: See TracChangeset for help on using the changeset viewer.