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/OpenInventor/src/G4OpenInventorSceneHandler.cc

    r529 r593  
    2525//
    2626//
    27 // $Id: G4OpenInventorSceneHandler.cc,v 1.50 2006/11/05 20:48:57 allison Exp $
    28 // GEANT4 tag $Name: geant4-08-02-patch-01 $
     27// $Id: G4OpenInventorSceneHandler.cc,v 1.53 2007/04/03 13:35:48 allison Exp $
     28// GEANT4 tag $Name: geant4-09-00-ref-01 $
    2929//
    3030//
     
    9696#include "G4Trap.hh"
    9797#include "G4Trd.hh"
    98 #include "G4PhysicalVolumeModel.hh"
    99 #include "G4TrajectoriesModel.hh"
    100 #include "G4VTrajectory.hh"
    101 #include "G4VTrajectoryPoint.hh"
    102 #include "G4HitsModel.hh"
    103 #include "G4VHit.hh"
    10498#include "G4ModelingParameters.hh"
    10599#include "G4VPhysicalVolume.hh"
     
    189183}
    190184
    191 void G4OpenInventorSceneHandler::LoadAtts
    192 (const G4Visible& visible,
    193  G4AttHolder* holder)
    194 {
    195   // Load G4Atts from G4VisAttributes, if any...
    196   const std::map<G4String,G4AttDef>* vaDefs =
    197     visible.GetVisAttributes()->GetAttDefs();
    198   if (vaDefs) {
    199     holder->AddAtts(visible.GetVisAttributes()->CreateAttValues(), vaDefs);
    200   }
    201 
    202   G4PhysicalVolumeModel* pPVModel =
    203     dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
    204   if (pPVModel) {
    205     // Load G4Atts from G4PhysicalVolumeModel...
    206     const std::map<G4String,G4AttDef>* defs = pPVModel->GetAttDefs();
    207     if (defs) {
    208       holder->AddAtts(pPVModel->CreateCurrentAttValues(), defs);
    209     }
    210   }
    211 
    212   G4TrajectoriesModel* trajModel = dynamic_cast<G4TrajectoriesModel*>(fpModel);
    213   if (trajModel) {
    214     // Load G4Atts from trajectory...
    215     const G4VTrajectory* traj = trajModel->GetCurrentTrajectory();
    216     const std::map<G4String,G4AttDef>* defs = traj->GetAttDefs();
    217     if (defs) {
    218       holder->AddAtts(traj->CreateAttValues(), defs);
    219     }
    220     G4int nPoints = traj->GetPointEntries();
    221     for (G4int i = 0; i < nPoints; ++i) {
    222       G4VTrajectoryPoint* trajPoint = traj->GetPoint(i);
    223       const std::map<G4String,G4AttDef>* defs = trajPoint->GetAttDefs();
    224       if (defs) {
    225         holder->AddAtts(trajPoint->CreateAttValues(), defs);
    226       }
    227     }
    228   }
    229 
    230   G4HitsModel* hitsModel = dynamic_cast<G4HitsModel*>(fpModel);
    231   if (hitsModel) {
    232     // Load G4Atts from hit...
    233     const G4VHit* hit = hitsModel->GetCurrentHit();
    234     const std::map<G4String,G4AttDef>* defs = hit->GetAttDefs();
    235     if (defs) {
    236       holder->AddAtts(hit->CreateAttValues(), defs);
    237     }
    238   }
    239 }
    240 
    241185//
    242186// Method for handling G4Polyline objects (from tracking).
    243187//
    244 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline& line) {
     188void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline& line)
     189{
     190  AddProperties(line.GetVisAttributes());  // Transformation, colour, etc.
     191
    245192  G4int nPoints = line.size();
    246193  SbVec3f* pCoords = new SbVec3f[nPoints];
     
    252199  }
    253200
    254   // Don't understand why I have to do this again (done in
    255   // GeneratePrerequisites) - JA.
    256   //
    257   // Color
    258   //
    259   const G4Colour& c = GetColour (line);
    260   SoMaterial* material =
    261     fStyleCache->getMaterial((float)c.GetRed(),
    262                              (float)c.GetGreen(),
    263                              (float)c.GetBlue(),
    264                              (float)(1-c.GetAlpha()));
    265   fCurrentSeparator->addChild(material);
    266  
    267201  //
    268202  // Point Set
     
    281215
    282216  // Loads G4Atts for picking...
    283   LoadAtts(line, pLine);
     217  if (fpViewer->GetViewParameters().IsPicking()) LoadAtts(line, pLine);
    284218
    285219#ifdef INVENTOR2_0
     
    294228}
    295229
    296 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker& polymarker) {
     230void G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
     231{
     232  AddProperties(polymarker.GetVisAttributes()); // Transformation, colour, etc.
     233
    297234  G4int pointn = polymarker.size();
    298235  if(pointn<=0) return;
     
    305242  }
    306243
    307   // Don't understand why I have to do this again (done in
    308   // GeneratePrerequisites) - JA.
    309   const G4Colour& c = GetColour (polymarker);
    310   SoMaterial* material =
    311     fStyleCache->getMaterial((float)c.GetRed(),
    312                              (float)c.GetGreen(),
    313                              (float)c.GetBlue(),
    314                              (float)(1-c.GetAlpha()));
    315   fCurrentSeparator->addChild(material);
    316  
    317244  SoCoordinate3* coordinate3 = new SoCoordinate3;
    318245  coordinate3->point.setValues(0,pointn,points);
     
    336263
    337264  // Loads G4Atts for picking...
    338   LoadAtts(polymarker, markerSet);
     265  if (fpViewer->GetViewParameters().IsPicking())
     266    LoadAtts(polymarker, markerSet);
    339267
    340268  G4VMarker::FillStyle style = polymarker.GetFillStyle();
     
    410338// Method for handling G4Text objects
    411339//
    412 void G4OpenInventorSceneHandler::AddPrimitive (const G4Text& text) {
     340void G4OpenInventorSceneHandler::AddPrimitive (const G4Text& text)
     341{
     342  AddProperties(text.GetVisAttributes());  // Transformation, colour, etc.
     343
    413344  //
    414345  // Color.  Note: text colour is worked out differently.  This
    415   // over-rides the colour added in GeneratePrerequisites...
     346  // over-rides the colour added in AddProperties...
    416347  //
    417348  const G4Colour& c = GetTextColour (text);
     
    476407
    477408void G4OpenInventorSceneHandler::AddCircleSquare
    478 (G4OIMarker markerType, const G4VMarker& marker) {
    479 
    480   // Don't understand why I have to do this again (done in
    481   // GeneratePrerequisites) - JA.
    482   //
    483   // Color
    484   //
    485   const G4Colour& c = GetColour (marker);
    486   SoMaterial* material =
    487     fStyleCache->getMaterial((float)c.GetRed(),
    488                              (float)c.GetGreen(),
    489                              (float)c.GetBlue(),
    490                              (float)(1-c.GetAlpha()));
    491   fCurrentSeparator->addChild(material);
     409(G4OIMarker markerType, const G4VMarker& marker)
     410{
     411  AddProperties(marker.GetVisAttributes());  // Transformation, colour, etc.
    492412
    493413  MarkerSizeType sizeType;
     
    519439
    520440  // Loads G4Atts for picking...
    521   LoadAtts(marker, markerSet);
     441  if (fpViewer->GetViewParameters().IsPicking()) LoadAtts(marker, markerSet);
    522442
    523443  G4VMarker::FillStyle style = marker.GetFillStyle();
     
    574494// Method for handling G4Polyhedron objects for drawing solids.
    575495//
    576 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
     496void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron)
     497{
    577498  if (polyhedron.GetNoFacets() == 0) return;
    578499
     500  AddProperties(polyhedron.GetVisAttributes()); // Transformation, colour, etc.
     501
    579502  SoG4Polyhedron* soPolyhedron = new SoG4Polyhedron(polyhedron);
    580503
    581504  // Loads G4Atts for picking...
    582   LoadAtts(polyhedron, soPolyhedron);
     505  if (fpViewer->GetViewParameters().IsPicking())
     506    LoadAtts(polyhedron, soPolyhedron);
    583507
    584508  SbString name = "Non-geometry";
     
    600524//
    601525void G4OpenInventorSceneHandler::AddPrimitive (const G4NURBS& nurb) {
     526
     527  AddProperties(nurb.GetVisAttributes()); // Transformation, colour, etc.
    602528
    603529  G4float *u_knot_array, *u_knot_array_ptr;
     
    618544 
    619545  SoSeparator *surfSep = new SoSeparator();
    620 
    621   //
    622   // Color
    623   // 
    624   const G4Colour& c = GetColour (nurb);
    625   SoMaterial* material =
    626     fStyleCache->getMaterial((float)c.GetRed(),
    627                              (float)c.GetGreen(),
    628                              (float)c.GetBlue(),
    629                              (float)(1-c.GetAlpha()));
    630   surfSep->addChild(material);
    631546
    632547  //
     
    686601  // location on in the scene database so that when the solid is
    687602  // actually added (in addthis), it is put in the right place.
    688 
    689   // Use the applicable vis attributes...
    690   const G4VisAttributes* pApplicableVisAttribs =
    691     fpViewer->GetApplicableVisAttributes (fpVisAttribs);
    692 
    693   // First find the color attributes...
    694   const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
    695   const double red = g4Col.GetRed ();
    696   const double green = g4Col.GetGreen ();
    697   const double blue = g4Col.GetBlue ();
    698   double transparency = 1 - g4Col.GetAlpha();
    699 
    700   // Drawing style...
    701   G4ViewParameters::DrawingStyle drawing_style =
    702     GetDrawingStyle(pApplicableVisAttribs);
    703   switch (drawing_style) {
    704   case (G4ViewParameters::wireframe):   
    705     fModelingSolid = false;
    706     break;
    707   case (G4ViewParameters::hlr):
    708   case (G4ViewParameters::hsr):
    709   case (G4ViewParameters::hlhsr):
    710     fModelingSolid = true;
    711     break;
    712   }     
    713 
    714   // Edge visibility...
    715   G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pApplicableVisAttribs);
    716   fReducedWireFrame = !isAuxEdgeVisible;
    717603
    718604  G4PhysicalVolumeModel* pPVModel =
     
    771657      if(fPreviewAndFull) detectorTreeKit->setPreviewAndFull();
    772658      else detectorTreeKit->setPreview(TRUE);
     659
     660      // Colour, etc., for SoDetectorTreeKit.  Treated differently to
     661      // othere SoNodes(?).  Use fpVisAttribs stored away in
     662      // PreAddSolid...
     663      const G4VisAttributes* pApplicableVisAttribs =
     664        fpViewer->GetApplicableVisAttributes (fpVisAttribs);
     665
     666      // First find the color attributes...
     667      const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
     668      const double red = g4Col.GetRed ();
     669      const double green = g4Col.GetGreen ();
     670      const double blue = g4Col.GetBlue ();
     671      double transparency = 1 - g4Col.GetAlpha();
     672
     673      // Drawing style...
     674      G4ViewParameters::DrawingStyle drawing_style =
     675        GetDrawingStyle(pApplicableVisAttribs);
     676      switch (drawing_style) {
     677      case (G4ViewParameters::wireframe):   
     678        fModelingSolid = false;
     679        break;
     680      case (G4ViewParameters::hlr):
     681      case (G4ViewParameters::hsr):
     682      case (G4ViewParameters::hlhsr):
     683        fModelingSolid = true;
     684        break;
     685      }
    773686
    774687      SoMaterial* material =
     
    853766    }
    854767  }
     768}
     769
     770void G4OpenInventorSceneHandler::AddProperties(const G4VisAttributes* visAtts)
     771{
     772  // Use the applicable vis attributes...
     773  const G4VisAttributes* pApplicableVisAttribs =
     774    fpViewer->GetApplicableVisAttributes (visAtts);
     775
     776  // First find the color attributes...
     777  const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
     778  const double red = g4Col.GetRed ();
     779  const double green = g4Col.GetGreen ();
     780  const double blue = g4Col.GetBlue ();
     781  double transparency = 1 - g4Col.GetAlpha();
     782
     783  // Drawing style...
     784  G4ViewParameters::DrawingStyle drawing_style =
     785    GetDrawingStyle(pApplicableVisAttribs);
     786  switch (drawing_style) {
     787  case (G4ViewParameters::wireframe):   
     788    fModelingSolid = false;
     789    break;
     790  case (G4ViewParameters::hlr):
     791  case (G4ViewParameters::hsr):
     792  case (G4ViewParameters::hlhsr):
     793    fModelingSolid = true;
     794    break;
     795  }
     796
     797  // Edge visibility...
     798  G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pApplicableVisAttribs);
     799  fReducedWireFrame = !isAuxEdgeVisible;
    855800
    856801  SoMaterial* material =
     
    883828  fCurrentSeparator->addChild(matrixTransform);
    884829}
    885 
    886830#endif
Note: See TracChangeset for help on using the changeset viewer.