00001
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "VP1GuideLineSystems/VP1GuideLineSystem.h"
00013 #include "VP1GuideLineSystems/GuideSysController.h"
00014 #include "VP1GuideLineSystems/ProjectionSurfacesHelper.h"
00015 #include "VP1GuideLineSystems/VP1CoordinateAxes.h"
00016 #include "VP1GuideLineSystems/VP1Floor.h"
00017 #include "VP1GuideLineSystems/VP1Letters.h"
00018 #include "VP1GuideLineSystems/VP1EtaCone.h"
00019 #include "VP1GuideLineSystems/VP1CartesianGrid.h"
00020 #include "VP1GuideLineSystems/VP1CylindricalGrid.h"
00021
00022 #include "VP1Base/VP1Serialise.h"
00023 #include "VP1Base/VP1Deserialise.h"
00024
00025 #include <Inventor/nodes/SoSeparator.h>
00026 #include <Inventor/nodes/SoPickStyle.h>
00027 #include <Inventor/nodes/SoComplexity.h>
00028 #include <Inventor/SbVec3f.h>
00029
00030 #include <map>
00031
00032 class VP1GuideLineSystem::Imp {
00033 public:
00034 Imp(VP1GuideLineSystem*tc) : theclass(tc),
00035 controller(0),
00036 coordinateaxes(0),
00037 floor(0),
00038 cartesiangrid(0),
00039 cylindricalgrid(0),
00040 letters(0),
00041 etacone1(0),
00042 etacone2(0),
00043 etacone3(0),
00044 projsurfhelper_pixel(0),
00045 projsurfhelper_sct(0),
00046 projsurfhelper_trt(0),
00047 lastemit_pixel(InDetProjFlags::NoProjections),
00048 lastemit_sct(InDetProjFlags::NoProjections),
00049 lastemit_trt(InDetProjFlags::NoProjections) {}
00050 VP1GuideLineSystem *theclass;
00051 GuideSysController * controller;
00052 VP1CoordinateAxes * coordinateaxes;
00053 VP1Floor * floor;
00054 VP1CartesianGrid * cartesiangrid;
00055 VP1CylindricalGrid * cylindricalgrid;
00056 VP1Letters * letters;
00057 VP1EtaCone * etacone1;
00058 VP1EtaCone * etacone2;
00059 VP1EtaCone * etacone3;
00060
00061 ProjectionSurfacesHelper * projsurfhelper_pixel;
00062 ProjectionSurfacesHelper * projsurfhelper_sct;
00063 ProjectionSurfacesHelper * projsurfhelper_trt;
00064 InDetProjFlags::InDetProjPartsFlags lastemit_pixel;
00065 InDetProjFlags::InDetProjPartsFlags lastemit_sct;
00066 InDetProjFlags::InDetProjPartsFlags lastemit_trt;
00067
00068
00069 std::map<QObject*,InDetProjFlags::DetTypeFlags> sender2iddettypeswithprojs;
00070 };
00071
00072
00073 VP1GuideLineSystem::VP1GuideLineSystem()
00074 : IVP13DSystemSimple("Guides",
00075 "System providing visual guides",
00076 "Thomas.Kittelmann@cern.ch"), d(new Imp(this))
00077 {
00078 }
00079
00080
00081
00082 VP1GuideLineSystem::~VP1GuideLineSystem()
00083 {
00084 delete d;
00085 }
00086
00087
00088 QWidget * VP1GuideLineSystem::buildController()
00089 {
00090 d->controller = new GuideSysController(this);
00091 return d->controller;
00092 }
00093
00094
00095 void VP1GuideLineSystem::buildEventSceneGraph(StoreGateSvc*, SoSeparator *)
00096 {
00097 }
00098
00099
00100 void VP1GuideLineSystem::buildPermanentSceneGraph(StoreGateSvc* , SoSeparator *root)
00101 {
00102 messageVerbose("buildPermanentSceneGraph");
00103
00104 SoPickStyle *pickStyle = new SoPickStyle;
00105 pickStyle->style=SoPickStyle::UNPICKABLE;
00106 root->addChild(pickStyle);
00107
00108
00109 SoComplexity * complexity = new SoComplexity;
00110 complexity->value.setValue(2.0f);
00111 root->addChild(complexity);
00112
00113
00114 d->floor = new VP1Floor(root,this);
00115 connect(d->controller,SIGNAL(floorExtentChanged(const double&)),d->floor,SLOT(setExtent(const double&)));
00116 d->floor->setExtent(d->controller->floorExtent());
00117 connect(d->controller,SIGNAL(floorSpacingChanged(const double&)),d->floor,SLOT(setSpacing(const double&)));
00118 d->floor->setSpacing(d->controller->floorSpacing());
00119 connect(d->controller,SIGNAL(floorHeightChanged(const double&)),d->floor,SLOT(setVerticalPosition(const double&)));
00120 d->floor->setVerticalPosition(d->controller->floorHeight());
00121 connect(d->controller,SIGNAL(floorColourAndTranspChanged( const SbColor4f&)),d->floor,SLOT(setColourAndTransp(const SbColor4f&)));
00122 d->floor->setColourAndTransp(d->controller->floorColourAndTransp());
00123 connect(d->controller,SIGNAL(showFloorChanged(bool)),d->floor,SLOT(setShown(bool)));
00124 d->floor->setShown(d->controller->showFloor());
00125
00126
00127 d->cartesiangrid = new VP1CartesianGrid(root,this);
00128 connect(d->controller,SIGNAL(gridExtentChanged(const double&)),d->cartesiangrid,SLOT(setExtent(const double&)));
00129 d->cartesiangrid->setExtent(d->controller->gridExtent());
00130 connect(d->controller,SIGNAL(gridSpacingChanged(const double&)),d->cartesiangrid,SLOT(setSpacing(const double&)));
00131 d->cartesiangrid->setSpacing(d->controller->gridSpacing());
00132 connect(d->controller,SIGNAL(gridColourAndTranspChanged( const SbColor4f&)),d->cartesiangrid,SLOT(setColourAndTransp(const SbColor4f&)));
00133 d->cartesiangrid->setColourAndTransp(d->controller->gridColourAndTransp());
00134 connect(d->controller,SIGNAL(showCartesianGridChanged(bool)),d->cartesiangrid,SLOT(setShown(bool)));
00135 d->cartesiangrid->setShown(d->controller->showCartesianGrid());
00136
00137
00138 d->cylindricalgrid = new VP1CylindricalGrid(root,this);
00139 connect(d->controller,SIGNAL(gridExtentChanged(const double&)),d->cylindricalgrid,SLOT(setExtent(const double&)));
00140 d->cylindricalgrid->setExtent(d->controller->gridExtent());
00141 connect(d->controller,SIGNAL(gridSpacingChanged(const double&)),d->cylindricalgrid,SLOT(setSpacing(const double&)));
00142 d->cylindricalgrid->setSpacing(d->controller->gridSpacing());
00143 connect(d->controller,SIGNAL(gridColourAndTranspChanged( const SbColor4f&)),d->cylindricalgrid,SLOT(setColourAndTransp(const SbColor4f&)));
00144 d->cylindricalgrid->setColourAndTransp(d->controller->gridColourAndTransp());
00145 connect(d->controller,SIGNAL(showCylindricalGridChanged(bool)),d->cylindricalgrid,SLOT(setShown(bool)));
00146 d->cylindricalgrid->setShown(d->controller->showCylindricalGrid());
00147
00148
00149 d->letters = new VP1Letters(d->controller->lettersMaterial(),root,this);
00150 connect(d->controller,SIGNAL(lettersZPosChanged(const double&)),d->letters,SLOT(setZPos(const double&)));
00151 d->letters->setZPos(d->controller->lettersZPos());
00152 connect(d->controller,SIGNAL(lettersVerticalPosChanged(const double&)),d->letters,SLOT(setVerticalPosition(const double&)));
00153 d->letters->setVerticalPosition(d->controller->lettersVerticalPos());
00154 connect(d->controller,SIGNAL(showLettersChanged(bool)),d->letters,SLOT(setShown(bool)));
00155 d->letters->setShown(d->controller->showLetters());
00156
00157
00158 d->coordinateaxes = new VP1CoordinateAxes(d->controller->xAxisMaterial(),
00159 d->controller->yAxisMaterial(),
00160 d->controller->zAxisMaterial(),
00161 root,this);
00162 connect(d->controller,SIGNAL(axesLengthChanged(const double&)),d->coordinateaxes,SLOT(setLength(const double&)));
00163 d->coordinateaxes->setLength(d->controller->axesLength());
00164 connect(d->controller,SIGNAL(axesPositionChanged(const SbVec3f&)),d->coordinateaxes,SLOT(setPosition(const SbVec3f&)));
00165 d->coordinateaxes->setPosition(d->controller->axesPosition());
00166 connect(d->controller,SIGNAL(relAxesThicknessChanged(const double&)),d->coordinateaxes,SLOT(setRelativeAxisThickness(const double&)));
00167 d->coordinateaxes->setRelativeAxisThickness(d->controller->relAxesThickness());
00168 connect(d->controller,SIGNAL(showAxesChanged(bool)),d->coordinateaxes,SLOT(setShown(bool)));
00169 d->coordinateaxes->setShown(d->controller->showAxes());
00170
00171
00172 d->etacone1 = new VP1EtaCone(d->controller->etaCone1Material(),root,this);
00173 connect(d->controller,SIGNAL(etaExtentChanged(const double&)),d->etacone1,SLOT(setExtent(const double&)));
00174 d->etacone1->setExtent(d->controller->etaExtent());
00175 connect(d->controller,SIGNAL(etaConeValue1Changed(const double&)),d->etacone1,SLOT(setEtaValue(const double&)));
00176 d->etacone1->setEtaValue(d->controller->etaConeValue1());
00177 connect(d->controller,SIGNAL(showEtaCone1Changed(bool)),d->etacone1,SLOT(setShown(bool)));
00178 d->etacone1->setShown(d->controller->showEtaCone1());
00179
00180 d->etacone2 = new VP1EtaCone(d->controller->etaCone2Material(),root,this);
00181 connect(d->controller,SIGNAL(etaExtentChanged(const double&)),d->etacone2,SLOT(setExtent(const double&)));
00182 d->etacone2->setExtent(d->controller->etaExtent());
00183 connect(d->controller,SIGNAL(etaConeValue2Changed(const double&)),d->etacone2,SLOT(setEtaValue(const double&)));
00184 d->etacone2->setEtaValue(d->controller->etaConeValue2());
00185 connect(d->controller,SIGNAL(showEtaCone2Changed(bool)),d->etacone2,SLOT(setShown(bool)));
00186 d->etacone2->setShown(d->controller->showEtaCone2());
00187
00188 d->etacone3 = new VP1EtaCone(d->controller->etaCone3Material(),root,this);
00189 connect(d->controller,SIGNAL(etaExtentChanged(const double&)),d->etacone3,SLOT(setExtent(const double&)));
00190 d->etacone3->setExtent(d->controller->etaExtent());
00191 connect(d->controller,SIGNAL(etaConeValue3Changed(const double&)),d->etacone3,SLOT(setEtaValue(const double&)));
00192 d->etacone3->setEtaValue(d->controller->etaConeValue3());
00193 connect(d->controller,SIGNAL(showEtaCone3Changed(bool)),d->etacone3,SLOT(setShown(bool)));
00194 d->etacone3->setShown(d->controller->showEtaCone3());
00195
00196 SoSeparator * projsep = new SoSeparator;
00197 root->addChild(projsep);
00198
00199 d->projsurfhelper_pixel = ProjectionSurfacesHelper::createPixelHelper(d->controller->pixelProjSurfMaterial(),projsep,this,this);
00200 d->projsurfhelper_sct = ProjectionSurfacesHelper::createSCTHelper(d->controller->sctProjSurfMaterial(),projsep,this,this);
00201 d->projsurfhelper_trt = ProjectionSurfacesHelper::createTRTHelper(d->controller->trtProjSurfMaterial(),projsep,this,this);
00202
00203 connect(d->controller,SIGNAL(shownPixelProjSurfacesChanged(InDetProjFlags::InDetProjPartsFlags)),
00204 d->projsurfhelper_pixel,SLOT(setSurfaces(InDetProjFlags::InDetProjPartsFlags)));
00205 d->projsurfhelper_pixel->setSurfaces(d->controller->shownPixelProjSurfaces());
00206
00207 connect(d->controller,SIGNAL(shownSCTProjSurfacesChanged(InDetProjFlags::InDetProjPartsFlags)),
00208 d->projsurfhelper_sct,SLOT(setSurfaces(InDetProjFlags::InDetProjPartsFlags)));
00209 d->projsurfhelper_sct->setSurfaces(d->controller->shownSCTProjSurfaces());
00210
00211 connect(d->controller,SIGNAL(shownTRTProjSurfacesChanged(InDetProjFlags::InDetProjPartsFlags)),
00212 d->projsurfhelper_trt,SLOT(setSurfaces(InDetProjFlags::InDetProjPartsFlags)));
00213 d->projsurfhelper_trt->setSurfaces(d->controller->shownTRTProjSurfaces());
00214
00215 connect(d->controller,SIGNAL(applicablePixelProjPartsChanged(InDetProjFlags::InDetProjPartsFlags)),this,SLOT(possiblyEmit_ApplicableProjectionsChanged()));
00216 connect(d->controller,SIGNAL(applicableSCTProjPartsChanged(InDetProjFlags::InDetProjPartsFlags)),this,SLOT(possiblyEmit_ApplicableProjectionsChanged()));
00217 connect(d->controller,SIGNAL(applicableTRTProjPartsChanged(InDetProjFlags::InDetProjPartsFlags)),this,SLOT(possiblyEmit_ApplicableProjectionsChanged()));
00218
00219 possiblyEmit_ApplicableProjectionsChanged();
00220
00221 }
00222
00223
00224 void VP1GuideLineSystem::systemuncreate()
00225 {
00226 delete d->coordinateaxes; d->coordinateaxes = 0;
00227 delete d->floor; d->floor = 0;
00228 delete d->cartesiangrid; d->cartesiangrid = 0;
00229 delete d->cylindricalgrid; d->cylindricalgrid = 0;
00230 delete d->letters; d->letters = 0;
00231 delete d->etacone1; d->etacone1 = 0;
00232 delete d->etacone2; d->etacone2 = 0;
00233 delete d->etacone3; d->etacone3 = 0;
00234 delete d->projsurfhelper_pixel; d->projsurfhelper_pixel = 0;
00235 delete d->projsurfhelper_sct; d->projsurfhelper_sct = 0;
00236 delete d->projsurfhelper_trt; d->projsurfhelper_trt = 0;
00237 d->controller=0;
00238 }
00239
00240
00241
00242 QByteArray VP1GuideLineSystem::saveState() {
00243
00244 ensureBuildController();
00245
00246 VP1Serialise serialise(4,this);
00247 serialise.save(IVP13DSystemSimple::saveState());
00248 serialise.save(d->controller->saveSettings());
00249 serialise.disableUnsavedChecks();
00250 return serialise.result();
00251 }
00252
00253
00254 void VP1GuideLineSystem::restoreFromState(QByteArray ba) {
00255
00256 VP1Deserialise state(ba,this);
00257 if (state.version()<0||state.version()>4) {
00258 message("Warning: State data in .vp1 file is in wrong format - ignoring!");
00259 state.disableUnrestoredChecks();
00260 return;
00261 }
00262 if (state.version()>=0&&state.version()<=3) {
00263 message("Warning: State data in .vp1 file is in obsolete format - ignoring!");
00264 state.disableUnrestoredChecks();
00265 return;
00266 }
00267 ensureBuildController();
00268
00269 IVP13DSystemSimple::restoreFromState(state.restoreByteArray());
00270 d->controller->restoreSettings(state.restoreByteArray());
00271 state.disableUnrestoredChecks();
00272 }
00273
00274
00275
00276
00277 void VP1GuideLineSystem::setIDDetTypesUsingProjections( InDetProjFlags::DetTypeFlags f )
00278 {
00279 ensureBuildController();
00280 if (!d->controller)
00281 return;
00282 messageVerbose("Signal received in setIDDetTypesUsingProjections("+str(f)+") slot (from "
00283 +QString(sender()?sender()->objectName():"NULL sender")+")");
00284 d->sender2iddettypeswithprojs[sender()] = f;
00285 InDetProjFlags::DetTypeFlags used(InDetProjFlags::NoDet);
00286 std::map<QObject*,InDetProjFlags::DetTypeFlags>::iterator it, itE = d->sender2iddettypeswithprojs.end();
00287 for (it=d->sender2iddettypeswithprojs.begin();it!=itE;++it)
00288 used |= it->second;
00289 d->controller->setInDetDetTypesUsingProjections(used);
00290 }
00291
00292
00293 void VP1GuideLineSystem::possiblyEmit_ApplicableProjectionsChanged()
00294 {
00295 ensureBuildController();
00296 if (!d->controller)
00297 return;
00298 InDetProjFlags::InDetProjPartsFlags new_pixel = d->controller->applicablePixelProjParts();
00299 InDetProjFlags::InDetProjPartsFlags new_sct = d->controller->applicableSCTProjParts();
00300 InDetProjFlags::InDetProjPartsFlags new_trt = d->controller->applicableTRTProjParts();
00301 if (d->lastemit_pixel==new_pixel&&d->lastemit_sct==new_sct&&d->lastemit_trt==new_trt)
00302 return;
00303 d->lastemit_pixel=new_pixel;
00304 d->lastemit_sct=new_sct;
00305 d->lastemit_trt=new_trt;
00306 if (verbose())
00307 messageVerbose("Emitting applicableProjectionsChanged("+str(d->lastemit_pixel)+", "+str(d->lastemit_sct)+", "+str(d->lastemit_trt)+")");
00308 emit applicableProjectionsChanged( d->lastemit_pixel,d->lastemit_sct,d->lastemit_trt );
00309 }