Ignore:
Timestamp:
Nov 9, 2007, 3:32:25 PM (17 years ago)
Author:
garnier
Message:

r627@mac-90108: laurentgarnier | 2007-11-09 07:57:42 +0100
modif dans les includes directives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/management/src/G4VSceneHandler.cc

    r561 r593  
    2525//
    2626//
    27 // $Id: G4VSceneHandler.cc,v 1.77 2006/11/21 14:23:53 allison Exp $
    28 // GEANT4 tag $Name: geant4-08-02-patch-01 $
     27// $Id: G4VSceneHandler.cc,v 1.82 2007/05/16 15:47:44 allison Exp $
     28// GEANT4 tag $Name: geant4-09-00-ref-01 $
    2929//
    3030//
     
    7171#include "G4ModelingParameters.hh"
    7272#include "G4VTrajectory.hh"
     73#include "G4VTrajectoryPoint.hh"
     74#include "G4HitsModel.hh"
    7375#include "G4VHit.hh"
    7476#include "Randomize.hh"
     
    7779#include "G4Run.hh"
    7880#include "G4Transform3D.hh"
     81#include "G4AttHolder.hh"
     82#include "G4AttDef.hh"
    7983
    8084G4VSceneHandler::G4VSceneHandler (G4VGraphicsSystem& system, G4int id, const G4String& name):
     
    9599  fpObjectTransformation (0),
    96100  fNestingDepth          (0),
    97   fpVisAttribs           (0),
    98   fRequestedEvent        (0)
     101  fpVisAttribs           (0)
    99102{
    100103  G4VisManager* pVMan = G4VisManager::GetInstance ();
     
    421424  G4NURBS* pNURBS = 0;
    422425  G4Polyhedron* pPolyhedron = 0;
    423   const G4VisAttributes* pVisAttribs =
    424     fpViewer -> GetApplicableVisAttributes (fpVisAttribs);
    425426  switch (fpViewer -> GetViewParameters () . GetRepStyle ()) {
    426427  case G4ViewParameters::nurbs:
    427428    pNURBS = solid.CreateNURBS ();
    428429    if (pNURBS) {
    429       pNURBS -> SetVisAttributes
    430         (fpViewer -> GetApplicableVisAttributes (pVisAttribs));
     430      pNURBS -> SetVisAttributes (fpVisAttribs);
    431431      AddPrimitive (*pNURBS);
    432432      delete pNURBS;
     
    447447  case G4ViewParameters::polyhedron:
    448448  default:
    449     G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides (pVisAttribs));
     449    G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides (fpVisAttribs));
    450450    pPolyhedron = solid.GetPolyhedron ();
    451451    G4Polyhedron::ResetNumberOfRotationSteps ();
    452452    if (pPolyhedron) {
    453       pPolyhedron -> SetVisAttributes (pVisAttribs);
     453      pPolyhedron -> SetVisAttributes (fpVisAttribs);
    454454      AddPrimitive (*pPolyhedron);
    455455    }
     
    471471
    472472void G4VSceneHandler::ProcessScene (G4VViewer&) {
    473   printf("G4VSceneHandler::ProcessScene\n");
     473
    474474  if (!fpScene) return;
    475475
     
    545545  G4StateManager* stateManager = G4StateManager::GetStateManager();
    546546  G4ApplicationState state = stateManager->GetCurrentState();
    547 
    548   printf("G4VSceneHandler::ProcessScene 1\n");
    549547  if (state == G4State_Idle) {
    550   printf("G4VSceneHandler::ProcessScene 2 : idle\n");
    551548
    552549    visManager->SetEventRefreshing(true);
    553550
    554     if (fRequestedEvent) {
    555       DrawEvent(fRequestedEvent);
    556       printf("G4VSceneHandler::ProcessScene 3 : fRequestedEvent\n");
     551    if (visManager->GetRequestedEvent()) {
     552      DrawEvent(visManager->GetRequestedEvent());
    557553
    558554    } else {
    559       printf("G4VSceneHandler::ProcessScene 3 : not fRequestedEvent\n");
    560555
    561556      G4RunManager* runManager = G4RunManager::GetRunManager();
    562       const G4Run* run = runManager->GetCurrentRun();
    563       const std::vector<const G4Event*>* events =
    564         run? run->GetEventVector(): 0;
    565       size_t nKeptEvents = 0;
    566       if (events) nKeptEvents = events->size();
    567557      if (runManager) {
    568           printf("G4VSceneHandler::ProcessScene 4 : run manager OK\n");
    569         if (fpScene->GetRefreshAtEndOfEvent()) {
    570           printf("G4VSceneHandler::ProcessScene 5 : fpScene->GetRefreshAtEndOfEvent()\n");
    571 
    572           if (verbosity >= G4VisManager::confirmations) {
    573             G4cout << "Refreshing event..." << G4endl;
    574           }
    575           const G4Event* event = 0;
    576           if (events && events->size()) event = events->back();
    577           if (event) DrawEvent(event);
    578 
    579         } else {  // Accumulating events.
    580   printf("G4VSceneHandler::ProcessScene 7\n");
    581 
    582           if (verbosity >= G4VisManager::confirmations) {
    583             G4cout << "Refreshing events in run..." << G4endl;
    584           }
    585           for (size_t i = 0; i < nKeptEvents; ++i) {
    586             const G4Event* event = (*events)[i];
     558        const G4Run* run = runManager->GetCurrentRun();
     559        const std::vector<const G4Event*>* events =
     560          run? run->GetEventVector(): 0;
     561        size_t nKeptEvents = 0;
     562        if (events) nKeptEvents = events->size();
     563        if (nKeptEvents) {
     564
     565          if (fpScene->GetRefreshAtEndOfEvent()) {
     566
     567            if (verbosity >= G4VisManager::confirmations) {
     568              G4cout << "Refreshing event..." << G4endl;
     569            }
     570            const G4Event* event = 0;
     571            if (events && events->size()) event = events->back();
    587572            if (event) DrawEvent(event);
    588           }
    589 
    590           if (!fpScene->GetRefreshAtEndOfRun()) {
    591             if (verbosity >= G4VisManager::warnings) {
    592               G4cout <<
    593                 "WARNING: Cannot refresh events accumulated over more"
    594                 "\n  than one runs.  Refreshed just the last run..."
    595                      << G4endl;
     573
     574          } else {  // Accumulating events.
     575
     576            if (verbosity >= G4VisManager::confirmations) {
     577              G4cout << "Refreshing events in run..." << G4endl;
     578            }
     579            for (size_t i = 0; i < nKeptEvents; ++i) {
     580              const G4Event* event = (*events)[i];
     581              if (event) DrawEvent(event);
     582            }
     583
     584            if (!fpScene->GetRefreshAtEndOfRun()) {
     585              if (verbosity >= G4VisManager::warnings) {
     586                G4cout <<
     587                  "WARNING: Cannot refresh events accumulated over more"
     588                  "\n  than one runs.  Refreshed just the last run."
     589                       << G4endl;
     590              }
    596591            }
    597592          }
    598593        }
    599594      }
    600    }
    601    visManager->SetEventRefreshing(false);
    602  }
     595    }
     596    visManager->SetEventRefreshing(false);
     597  }
    603598
    604599  fMarkForClearingTransientStore = tmpMarkForClearingTransientStore;
    605   printf("G4VSceneHandler::ProcessScene terminé \n");
    606600}
    607601
    608602void G4VSceneHandler::DrawEvent(const G4Event* event)
    609603{
    610   printf("G4VSceneHandler::DrawEvent \n");
    611604  const std::vector<G4VModel*>& EOEModelList =
    612605    fpScene -> GetEndOfEventModelList ();
     
    718711}
    719712
     713void G4VSceneHandler::LoadAtts(const G4Visible& visible, G4AttHolder* holder)
     714{
     715  // Load G4Atts from G4VisAttributes, if any...
     716  const G4VisAttributes* va = visible.GetVisAttributes();
     717  if (va) {
     718    const std::map<G4String,G4AttDef>* vaDefs =
     719      va->GetAttDefs();
     720    if (vaDefs) {
     721      holder->AddAtts(visible.GetVisAttributes()->CreateAttValues(), vaDefs);
     722    }
     723  }
     724
     725  G4PhysicalVolumeModel* pPVModel =
     726    dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
     727  if (pPVModel) {
     728    // Load G4Atts from G4PhysicalVolumeModel...
     729    const std::map<G4String,G4AttDef>* defs = pPVModel->GetAttDefs();
     730    if (defs) {
     731      holder->AddAtts(pPVModel->CreateCurrentAttValues(), defs);
     732    }
     733  }
     734
     735  G4TrajectoriesModel* trajModel = dynamic_cast<G4TrajectoriesModel*>(fpModel);
     736  if (trajModel) {
     737    // Load G4Atts from trajectory...
     738    const G4VTrajectory* traj = trajModel->GetCurrentTrajectory();
     739    const std::map<G4String,G4AttDef>* defs = traj->GetAttDefs();
     740    if (defs) {
     741      holder->AddAtts(traj->CreateAttValues(), defs);
     742    }
     743    G4int nPoints = traj->GetPointEntries();
     744    for (G4int i = 0; i < nPoints; ++i) {
     745      G4VTrajectoryPoint* trajPoint = traj->GetPoint(i);
     746      const std::map<G4String,G4AttDef>* defs = trajPoint->GetAttDefs();
     747      if (defs) {
     748        holder->AddAtts(trajPoint->CreateAttValues(), defs);
     749      }
     750    }
     751  }
     752
     753  G4HitsModel* hitsModel = dynamic_cast<G4HitsModel*>(fpModel);
     754  if (hitsModel) {
     755    // Load G4Atts from hit...
     756    const G4VHit* hit = hitsModel->GetCurrentHit();
     757    const std::map<G4String,G4AttDef>* defs = hit->GetAttDefs();
     758    if (defs) {
     759      holder->AddAtts(hit->CreateAttValues(), defs);
     760    }
     761  }
     762}
     763
    720764const G4Colour& G4VSceneHandler::GetColour (const G4Visible& visible) {
    721765  // Colour is determined by the applicable vis attributes.
     
    734778}
    735779
    736 G4double G4VSceneHandler::GetLineWidth(const G4Visible& visible)
    737 {
    738   G4double lineWidth = fpViewer->
    739     GetApplicableVisAttributes(visible.GetVisAttributes())->GetLineWidth();
     780G4double G4VSceneHandler::GetLineWidth(const G4VisAttributes* pVisAttribs)
     781{
     782  G4double lineWidth = pVisAttribs->GetLineWidth();
    740783  if (lineWidth < 1.) lineWidth = 1.;
    741784  lineWidth *= fpViewer -> GetViewParameters().GetGlobalLineWidthScale();
     
    749792  // it can be overriddden by the ForceDrawingStyle flag in the vis
    750793  // attributes.
    751   G4ViewParameters::DrawingStyle style =
     794  G4ViewParameters::DrawingStyle style = 
    752795    fpViewer->GetViewParameters().GetDrawingStyle();
    753796  if (pVisAttribs -> IsForceDrawingStyle ()) {
     
    821864  // ForceLineSegmentsPerCircle in the vis attributes.
    822865  G4int lineSegmentsPerCircle = fpViewer->GetViewParameters().GetNoOfSides();
    823   if (pVisAttribs->GetForcedLineSegmentsPerCircle() > 0)
    824     lineSegmentsPerCircle = pVisAttribs->GetForcedLineSegmentsPerCircle();
    825   const G4int nSegmentsMin = 12;
    826   if (lineSegmentsPerCircle < nSegmentsMin) {
    827     lineSegmentsPerCircle = nSegmentsMin;
    828     G4cout <<
    829       "G4VSceneHandler::GetNoOfSides: attempt to set the"
    830       "\nnumber of line segements per circle < " << nSegmentsMin
    831          << "; forced to " << lineSegmentsPerCircle << G4endl;
     866  if (pVisAttribs) {
     867    if (pVisAttribs->IsForceLineSegmentsPerCircle())
     868      lineSegmentsPerCircle = pVisAttribs->GetForcedLineSegmentsPerCircle();
     869    const G4int nSegmentsMin = 12;
     870    if (lineSegmentsPerCircle < nSegmentsMin) {
     871      lineSegmentsPerCircle = nSegmentsMin;
     872      G4cout <<
     873        "G4VSceneHandler::GetNoOfSides: attempt to set the"
     874        "\nnumber of line segements per circle < " << nSegmentsMin
     875             << "; forced to " << lineSegmentsPerCircle << G4endl;
     876    }
    832877  }
    833878  return lineSegmentsPerCircle;
Note: See TracChangeset for help on using the changeset viewer.