- Timestamp:
- Nov 9, 2007, 3:32:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/management/src/G4VSceneHandler.cc
r561 r593 25 25 // 26 26 // 27 // $Id: G4VSceneHandler.cc,v 1. 77 2006/11/21 14:23:53allison Exp $28 // GEANT4 tag $Name: geant4-0 8-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 $ 29 29 // 30 30 // … … 71 71 #include "G4ModelingParameters.hh" 72 72 #include "G4VTrajectory.hh" 73 #include "G4VTrajectoryPoint.hh" 74 #include "G4HitsModel.hh" 73 75 #include "G4VHit.hh" 74 76 #include "Randomize.hh" … … 77 79 #include "G4Run.hh" 78 80 #include "G4Transform3D.hh" 81 #include "G4AttHolder.hh" 82 #include "G4AttDef.hh" 79 83 80 84 G4VSceneHandler::G4VSceneHandler (G4VGraphicsSystem& system, G4int id, const G4String& name): … … 95 99 fpObjectTransformation (0), 96 100 fNestingDepth (0), 97 fpVisAttribs (0), 98 fRequestedEvent (0) 101 fpVisAttribs (0) 99 102 { 100 103 G4VisManager* pVMan = G4VisManager::GetInstance (); … … 421 424 G4NURBS* pNURBS = 0; 422 425 G4Polyhedron* pPolyhedron = 0; 423 const G4VisAttributes* pVisAttribs =424 fpViewer -> GetApplicableVisAttributes (fpVisAttribs);425 426 switch (fpViewer -> GetViewParameters () . GetRepStyle ()) { 426 427 case G4ViewParameters::nurbs: 427 428 pNURBS = solid.CreateNURBS (); 428 429 if (pNURBS) { 429 pNURBS -> SetVisAttributes 430 (fpViewer -> GetApplicableVisAttributes (pVisAttribs)); 430 pNURBS -> SetVisAttributes (fpVisAttribs); 431 431 AddPrimitive (*pNURBS); 432 432 delete pNURBS; … … 447 447 case G4ViewParameters::polyhedron: 448 448 default: 449 G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides ( pVisAttribs));449 G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides (fpVisAttribs)); 450 450 pPolyhedron = solid.GetPolyhedron (); 451 451 G4Polyhedron::ResetNumberOfRotationSteps (); 452 452 if (pPolyhedron) { 453 pPolyhedron -> SetVisAttributes ( pVisAttribs);453 pPolyhedron -> SetVisAttributes (fpVisAttribs); 454 454 AddPrimitive (*pPolyhedron); 455 455 } … … 471 471 472 472 void G4VSceneHandler::ProcessScene (G4VViewer&) { 473 printf("G4VSceneHandler::ProcessScene\n"); 473 474 474 if (!fpScene) return; 475 475 … … 545 545 G4StateManager* stateManager = G4StateManager::GetStateManager(); 546 546 G4ApplicationState state = stateManager->GetCurrentState(); 547 548 printf("G4VSceneHandler::ProcessScene 1\n");549 547 if (state == G4State_Idle) { 550 printf("G4VSceneHandler::ProcessScene 2 : idle\n");551 548 552 549 visManager->SetEventRefreshing(true); 553 550 554 if (fRequestedEvent) { 555 DrawEvent(fRequestedEvent); 556 printf("G4VSceneHandler::ProcessScene 3 : fRequestedEvent\n"); 551 if (visManager->GetRequestedEvent()) { 552 DrawEvent(visManager->GetRequestedEvent()); 557 553 558 554 } else { 559 printf("G4VSceneHandler::ProcessScene 3 : not fRequestedEvent\n");560 555 561 556 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();567 557 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(); 587 572 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 } 596 591 } 597 592 } 598 593 } 599 594 } 600 }601 visManager->SetEventRefreshing(false);602 }595 } 596 visManager->SetEventRefreshing(false); 597 } 603 598 604 599 fMarkForClearingTransientStore = tmpMarkForClearingTransientStore; 605 printf("G4VSceneHandler::ProcessScene terminé \n");606 600 } 607 601 608 602 void G4VSceneHandler::DrawEvent(const G4Event* event) 609 603 { 610 printf("G4VSceneHandler::DrawEvent \n");611 604 const std::vector<G4VModel*>& EOEModelList = 612 605 fpScene -> GetEndOfEventModelList (); … … 718 711 } 719 712 713 void 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 720 764 const G4Colour& G4VSceneHandler::GetColour (const G4Visible& visible) { 721 765 // Colour is determined by the applicable vis attributes. … … 734 778 } 735 779 736 G4double G4VSceneHandler::GetLineWidth(const G4Visible& visible) 737 { 738 G4double lineWidth = fpViewer-> 739 GetApplicableVisAttributes(visible.GetVisAttributes())->GetLineWidth(); 780 G4double G4VSceneHandler::GetLineWidth(const G4VisAttributes* pVisAttribs) 781 { 782 G4double lineWidth = pVisAttribs->GetLineWidth(); 740 783 if (lineWidth < 1.) lineWidth = 1.; 741 784 lineWidth *= fpViewer -> GetViewParameters().GetGlobalLineWidthScale(); … … 749 792 // it can be overriddden by the ForceDrawingStyle flag in the vis 750 793 // attributes. 751 G4ViewParameters::DrawingStyle style = 794 G4ViewParameters::DrawingStyle style = 752 795 fpViewer->GetViewParameters().GetDrawingStyle(); 753 796 if (pVisAttribs -> IsForceDrawingStyle ()) { … … 821 864 // ForceLineSegmentsPerCircle in the vis attributes. 822 865 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 } 832 877 } 833 878 return lineSegmentsPerCircle;
Note: See TracChangeset
for help on using the changeset viewer.