#include <SoLVolumeCnv.h>
Inheritance diagram for SoLVolumeCnv:
Public Types | |
INVALID_ADDRESS | |
INVALID_OBJECT | |
NO_MEMORY | |
BAD_STORAGE_TYPE | |
NO_SOURCE_OBJECT | |
ICONVERSIONSVC_LAST_ERROR | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
enum | Status |
Public Member Functions | |
SoLVolumeCnv (ISvcLocator *) | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual StatusCode | createRep (DataObject *, IOpaqueAddress *&) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual StatusCode | initialize () |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual StatusCode | finalize () |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual long | repSvcType () const |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
SoNode * | volumeToSoDetectorTreeKit (const ILVolume &, const Gaudi::Transform3D &, bool=false) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
MsgStream * | out () |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
virtual unsigned long | addRef () |
virtual unsigned long | release () |
virtual StatusCode | setDataProvider (IDataProviderSvc *svc) |
virtual IDataProviderSvc * | dataProvider () const |
virtual StatusCode | setConversionSvc (IConversionSvc *svc) |
virtual IConversionSvc * | conversionSvc () const |
virtual StatusCode | setAddressCreator (IAddressCreator *creator) |
virtual IAddressCreator * | addressCreator () const |
virtual const CLID & | objType () const |
virtual long | i_repSvcType () const |
virtual StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) |
virtual StatusCode | fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) |
virtual StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) |
virtual StatusCode | updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) |
virtual StatusCode | fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) |
virtual StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject) |
virtual StatusCode | updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) |
StatusCode | service (const std::string &name, T *&psvc, bool createIf=false) const |
StatusCode | service (const std::string &type, const std::string &name, T *&psvc) const |
Static Public Member Functions | |
static const CLID & | classID () |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
static const unsigned char | storageType () |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
static const InterfaceID & | interfaceID () |
Public Attributes | |
INVALID_ADDRESS | |
INVALID_OBJECT | |
NO_MEMORY | |
BAD_STORAGE_TYPE | |
NO_SOURCE_OBJECT | |
ICONVERSIONSVC_LAST_ERROR | |
Protected Member Functions | |
ISvcLocator * | serviceLocator () const |
IMessageSvc * | msgSvc () const |
IMessageSvc * | messageService () const |
IDataManagerSvc * | dataManager () const |
Protected Attributes | |
ISoConversionSvc * | fSoCnvSvc |
IUserInterfaceSvc * | fUISvc |
Friends | |
class | CnvFactory< SoLVolumeCnv > |
Definition at line 8 of file SoLVolumeCnv.h.
SoLVolumeCnv::SoLVolumeCnv | ( | ISvcLocator * | ) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 29 of file SoLVolumeCnv.cpp.
00030 :SoDetConverter(aSvcLoc, CLID_LVolume) 00033 { 00034 }
StatusCode SoLVolumeCnv::createRep | ( | DataObject * | , | |
IOpaqueAddress *& | ||||
) | [virtual] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Reimplemented from Converter.
Definition at line 36 of file SoLVolumeCnv.cpp.
00039 { 00040 MsgStream log(messageService(), "SoLVolumeCnv"); 00041 00042 if(!fUISvc) { 00043 log << MSG::INFO << " UI service not found" << endreq; 00044 return StatusCode::SUCCESS; 00045 } 00046 00047 ISession* session = fUISvc->session(); 00048 if(!session) { 00049 log << MSG::INFO << " can't get OnX session." << endreq; 00050 return StatusCode::FAILURE; 00051 } 00052 00053 SoRegion* region = fUISvc->currentSoRegion(); 00054 if(!region) { 00055 log << MSG::INFO << " can't get viewing region." << endreq; 00056 return StatusCode::FAILURE; 00057 } 00058 00059 if(!aObject) { 00060 log << MSG::INFO << " NULL object." << endreq; 00061 return StatusCode::FAILURE; 00062 } 00063 00064 if(!fSoCnvSvc) { 00065 log << MSG::INFO << " SoConversionSvc not found" << endreq; 00066 return StatusCode::FAILURE; 00067 } 00068 00069 std::string value; 00070 bool opened = false; 00071 if(session->parameterValue("modeling.opened",value)) 00072 Lib::smanip::tobool(value,opened); 00073 00074 log << MSG::INFO << "SoLVolumeCnv::createReps() called" << endreq; 00075 00076 const ILVolume* lv = dynamic_cast<const ILVolume*>(aObject); 00077 if(!lv) { 00078 log << MSG::INFO << " DataObject has not ILVolume interface! " << endreq; 00079 return StatusCode::FAILURE; 00080 } 00081 00082 SoNode* node = volumeToSoDetectorTreeKit(*lv,Gaudi::Transform3D(),opened); 00083 if(!node) { 00084 log << MSG::INFO << " no representation" << endreq; 00085 return StatusCode::FAILURE; 00086 } 00087 00088 // Send scene graph to the viewing region (in the "static" sub-scene graph) : 00089 region_addToStaticScene(*region,node); 00090 00091 return StatusCode::SUCCESS; 00092 }
const CLID & SoLVolumeCnv::classID | ( | ) | [static] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 94 of file SoLVolumeCnv.cpp.
00097 { 00098 return CLID_LVolume; 00099 }
const unsigned char SoLVolumeCnv::storageType | ( | ) | [static] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 101 of file SoLVolumeCnv.cpp.
00104 { 00105 return So_TechnologyType; 00106 }
StatusCode SoDetConverter::initialize | ( | ) | [virtual, inherited] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Reimplemented from Converter.
Definition at line 106 of file SoDetConverter.cpp.
00109 { 00110 StatusCode status = Converter::initialize(); 00111 if(status.isFailure()) return status; 00112 status = serviceLocator()->service("SoConversionSvc",fSoCnvSvc); 00113 if(status.isFailure()) return status; 00114 status = serviceLocator()->service("OnXSvc",fUISvc); 00115 if(status.isFailure()) return status; 00116 return status; 00117 }
StatusCode SoDetConverter::finalize | ( | ) | [virtual, inherited] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Reimplemented from Converter.
Definition at line 119 of file SoDetConverter.cpp.
00122 { 00123 //The below "release()" induce crash at exit : 00124 //debug if(fSoCnvSvc) fSoCnvSvc->release(); 00125 //debug if(fUISvc) fUISvc->release(); 00126 return StatusCode::SUCCESS; 00127 }
long SoDetConverter::repSvcType | ( | ) | const [virtual, inherited] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Implements Converter.
Definition at line 129 of file SoDetConverter.cpp.
00132 { 00133 return i_repSvcType(); 00134 }
SoNode * SoDetConverter::volumeToSoDetectorTreeKit | ( | const ILVolume & | , | |
const Gaudi::Transform3D & | , | |||
bool | = false | |||
) | [inherited] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 138 of file SoDetConverter.cpp.
00145 { 00146 ISession* session = fUISvc->session(); 00147 if(!session) return 0; 00148 00149 MsgStream log(msgSvc(), "SoDetConverter" ); 00150 00151 // Get visualization attributes : 00152 std::string value; 00153 double r = 0.5, g = 0.5, b = 0.5; 00154 //double hr = 1.0, hg = 1.0, hb = 1.0; 00155 double transparency = 0; 00156 bool modelingSolid = true; 00157 fRotationSteps = None; 00158 // Look in the ISession : 00159 if(session->parameterValue("modeling.color",value)) 00160 if(!Lib::smanip::torgb(value,r,g,b)) { r = 0.5; g = 0.5; b = 0.5;} 00161 if(session->parameterValue("modeling.transparency",value)) 00162 if(!Lib::smanip::todouble(value,transparency)) transparency = 0; 00163 //if(session->parameterValue("modeling.highlightColor",value)) 00164 // if(!Lib::smanip::torgb(value,hr,hg,hb)) { hr = 1; hg = 1; hb = 1;} 00165 if(session->parameterValue("modeling.modeling",value)) { 00166 modelingSolid = (value=="solid" ? true : false); 00167 } else { //Backward compatibility 00168 if(session->parameterValue("modeling.type",value)) { 00169 modelingSolid = (value=="solid" ? true : false); 00170 } 00171 } 00172 if(session->parameterValue("modeling.rotationSteps",value)) { 00173 if(!Lib::smanip::toint(value,fRotationSteps)) fRotationSteps = None; 00174 } 00175 if(session->parameterValue("modeling.doBooleanOperation",value)) { 00176 if(!Lib::smanip::tobool(value,fDoBooleanOperation)) fDoBooleanOperation = true; 00177 } 00178 00179 bool modelingOpened = aOpened; 00180 bool modelingVisible = true; 00181 00182 // Override with VisSvc is needed : 00183 bool useVisSvc = true; 00184 if(session->parameterValue("modeling.useVisSvc",value)) { 00185 if(!Lib::smanip::tobool(value,useVisSvc)) useVisSvc = true; 00186 } 00187 00188 VisAttribute attr; 00189 if(m_visSvc && useVisSvc) { 00190 attr = m_visSvc->visAttribute(&aLVolume); 00191 const Color color = attr.color(); 00192 if (color.isValid()) { 00193 r = color.red(); 00194 g = color.green(); 00195 b = color.blue(); 00196 transparency = color.alpha(); 00197 } 00198 if(attr.displayMode()==VisAttribute::WIRE_FRAME) { 00199 modelingSolid = false; 00200 } 00201 if(attr.openStatus()==VisAttribute::OPENED) { 00202 modelingOpened = true; 00203 } 00204 if(attr.visible()==VisAttribute::NOT_VISIBLE) { 00205 modelingVisible = false; 00206 } 00207 } 00208 00209 log << MSG::DEBUG << " opened " << modelingOpened << endreq; 00210 00211 // Logical volume 00212 SoNode* node = 0; 00213 const ISolid* solid = aLVolume.solid(); 00214 if(!solid) { 00215 //This may happen. 00216 } else { 00217 SbPolyhedron* result = solidToSbPolyhedron(*solid); 00218 if(result) { 00219 SoPolyhedron* soPolyhedron = new SoPolyhedron(*result); 00220 delete (result); 00221 soPolyhedron->solid.setValue(modelingSolid); 00222 node = soPolyhedron; 00223 } 00224 } 00225 00226 if(node) { 00227 std::string s; 00228 Lib::smanip::printf(s,128,"LVolume/0x%lx",(unsigned long)&aLVolume); 00229 node->setName(s.c_str()); 00230 } 00231 00232 // Deal with the Transformation : 00233 Gaudi::Rotation3D rot; 00234 Gaudi::XYZVector c; 00235 aMatrix.GetDecomposition(rot,c); 00236 c = c * -1.0; 00237 rot.Invert(); 00238 //Gaudi::AxisAngle axisAngle(rot); 00239 const Gaudi::Quaternion q(rot); 00240 Gaudi::AxisAngle axisAngle( q ); 00241 double angle; 00242 Gaudi::XYZVector v; 00243 axisAngle.GetComponents(v,angle); 00244 00245 int childn = aLVolume.noPVolumes(); 00246 log << MSG::DEBUG << " childn " << childn << " node " << node << endreq; 00247 if(childn==0) { 00248 00249 // Do not put an SoDetectorTreeKit here. 00250 // If so, "expanding" (with "ctrl-pick") will lead to an empty 00251 // scene without the possibility to "contract" by "shift-pick" something ! 00252 00253 // Only display if a node is present and if the visualization attribute 00254 // is ok 00255 if (node && modelingVisible) { 00256 SoSeparator* separator = new SoSeparator; 00257 separator->setName("sceneGraph"); 00258 00259 if(modelingSolid) { 00260 separator->addChild 00261 (fStyleCache->getMaterial(SbColor((float)r,(float)g,(float)b),(float)transparency)); 00262 separator->addChild(fStyleCache->getLightModelPhong()); 00263 } else { //SoLightModel::BASE_COLOR); 00264 separator->addChild 00265 (fStyleCache->getMaterial(SbColor((float)r,(float)g,(float)b),(float)transparency,TRUE)); 00266 separator->addChild(fStyleCache->getLightModelBaseColor()); 00267 } 00268 00269 // The volume is placed and rotated : 00270 SbMatrix mtx; 00271 mtx.makeIdentity(); 00272 {SbMatrix tmp; 00273 tmp.setRotate(SbRotation(SbVec3f((float)v.x(),(float)v.y(),(float)v.z()), 00274 (float)angle)); 00275 mtx.multLeft(tmp);} 00276 {SbMatrix tmp; 00277 tmp.setTranslate(SbVec3f((float)c.x(),(float)c.y(),(float)c.z())); 00278 mtx.multLeft(tmp);} //Applied first. 00279 00280 SoTransform* transform = new SoTransform; 00281 transform->setMatrix(mtx); //will set the SoFields (needed for VRML). 00282 00283 // The volume is placed and rotated : 00284 separator->addChild(transform); 00285 separator->addChild(node); 00286 return separator; 00287 00288 } else { 00289 if(node) node->unref(); 00290 return 0; 00291 } 00292 00293 } else { 00294 00295 SoDetTreeKit* dtk = new SoDetTreeKit(aLVolume,modelingSolid,this); 00296 00297 // Override the default SoEventCallback : 00298 SoEventCallback* evtCbk = 00299 (SoEventCallback*)dtk->getPart("callbackList[0]",FALSE); 00300 if(evtCbk) { 00301 SoEventCallback* eventCallback = new SoEventCallback; 00302 00303 eventCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(), 00304 expand,dtk); 00305 eventCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(), 00306 contract,dtk); 00307 if(dtk->setPart("callbackList[0]",eventCallback)==FALSE) 00308 eventCallback->unref(); 00309 } 00310 00311 // The volume is placed and rotated : 00312 SbMatrix mtx; 00313 mtx.makeIdentity(); 00314 {SbMatrix tmp; 00315 tmp.setRotate(SbRotation(SbVec3f((float)v.x(),(float)v.y(),(float)v.z()), 00316 (float)angle)); 00317 mtx.multLeft(tmp);} 00318 {SbMatrix tmp; 00319 tmp.setTranslate(SbVec3f((float)c.x(),(float)c.y(),(float)c.z())); 00320 mtx.multLeft(tmp);} //Applied first. 00321 00322 SoTransform* transform = (SoTransform*)dtk->getPart("transform",TRUE); 00323 transform->setMatrix(mtx); //will set the SoFields (needed for VRML). 00324 00325 // Only display if a node is present and if the visualization attributes 00326 // are ok (visibility and open status) 00327 00328 SoSeparator* previewSeparator = 00329 (SoSeparator*)dtk->getPart("previewSeparator",TRUE); 00330 00331 bool childOpened = false; 00332 if (node && modelingVisible) { 00333 00334 SoSeparator* separator = new SoSeparator; 00335 separator->setName("sceneGraph"); 00336 00337 if(modelingSolid) { 00338 separator->addChild 00339 (fStyleCache->getMaterial 00340 (SbColor((float)r,(float)g,(float)b),(float)transparency)); 00341 separator->addChild(fStyleCache->getLightModelPhong()); 00342 } else { //SoLightModel::BASE_COLOR); 00343 separator->addChild 00344 (fStyleCache->getMaterial 00345 (SbColor((float)r,(float)g,(float)b),(float)transparency,TRUE)); 00346 separator->addChild(fStyleCache->getLightModelBaseColor()); 00347 } 00348 00349 separator->addChild(new SoTransform); // For manipulators. 00350 separator->addChild(node); 00351 00352 previewSeparator->addChild(separator); 00353 00354 if(modelingOpened) dtk->setPreview(FALSE); 00355 } else { 00356 dtk->setPreview(FALSE); 00357 if(node) node->unref(); 00358 else childOpened = aOpened; 00359 } 00360 00361 SoSeparator* fullSeparator = 00362 (SoSeparator*)dtk->getPart("fullSeparator",TRUE); 00363 00364 // Only display children if no node present or the node is opened 00365 if (!node || modelingOpened) { 00366 // Descend to find a level with something to represent. 00367 for(int count=0;count<childn;count++) { 00368 const IPVolume* pvolume = aLVolume[count]; 00369 if (!pvolume) { 00370 log << MSG::ERROR << "found a null pvolume in " << aLVolume.name() 00371 << " at index " << count 00372 << ". Check the name of the logical volume associated to it" 00373 << endreq; 00374 } else { 00375 if(!pvolume->lvolume()) { 00376 log << MSG::ERROR << "pvolume with a null lvolume." << endreq; 00377 } else { 00378 SoNode* child = volumeToSoDetectorTreeKit(*(pvolume->lvolume()), 00379 pvolume->matrix(), 00380 childOpened); 00381 if (child) fullSeparator->addChild(child); 00382 } 00383 } 00384 } 00385 } 00386 00387 if(fullSeparator->getNumChildren()==0) { 00388 // Nothing to visualize in daughters. 00389 dtk->setPreview(TRUE); 00390 if(previewSeparator->getNumChildren()==0) { 00391 // Nothing to preview too. 00392 // Can't have an SoDetectorTreeKit, else "expanding" it 00393 // will lead to an empty scene. 00394 dtk->unref(); 00395 return 0; 00396 } 00397 } 00398 // Note that we can have a dtk with daughters but 00399 // with nothing to preview. Have to protect the "contract". 00400 00401 return dtk; 00402 } 00403 00404 }
MsgStream * SoDetConverter::out | ( | ) | [inherited] |
friend class CnvFactory< SoLVolumeCnv > [friend] |
Definition at line 9 of file SoLVolumeCnv.h.
ISoConversionSvc* SoDetConverter::fSoCnvSvc [protected, inherited] |
Definition at line 48 of file SoDetConverter.h.
IUserInterfaceSvc* SoDetConverter::fUISvc [protected, inherited] |
Definition at line 49 of file SoDetConverter.h.