[6] | 1 | // |
---|
| 2 | // All functions here should be OnX callbacks, that is to say |
---|
| 3 | // functions with signature : |
---|
| 4 | // extern "C" { |
---|
| 5 | // void callback_without_arguments(Slash::UI::IUI&); |
---|
| 6 | // void callback_with_arguments(Slash::UI::IUI&, |
---|
| 7 | // const std::vector<std::string>&); |
---|
| 8 | // } |
---|
| 9 | // |
---|
| 10 | |
---|
| 11 | #include <OnX/Helpers/OnX.h> |
---|
| 12 | #include <OnX/Helpers/Inventor.h> |
---|
| 13 | |
---|
| 14 | #include <Inventor/nodes/SoOrthographicCamera.h> |
---|
| 15 | |
---|
| 16 | // HEPVis : |
---|
| 17 | #include <HEPVis/SbMath.h> |
---|
| 18 | #include <HEPVis/nodekits/SoPage.h> |
---|
| 19 | #include <HEPVis/nodekits/SoDisplayRegion.h> |
---|
| 20 | |
---|
| 21 | extern "C" { |
---|
| 22 | |
---|
| 23 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 24 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 25 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 26 | void snovis_scene_default( |
---|
| 27 | Slash::UI::IUI& aUI |
---|
| 28 | ) |
---|
| 29 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 30 | // Visualize same scene as snova_vis_example.mac. |
---|
| 31 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 32 | { |
---|
| 33 | Slash::Core::ISession& session = aUI.session(); |
---|
| 34 | |
---|
| 35 | session.setParameter("modeling.modeling","wire_frame"); |
---|
| 36 | |
---|
| 37 | data_collect(session,"PV","name==\"WORLD\""); |
---|
| 38 | data_visualize(session); |
---|
| 39 | |
---|
| 40 | data_collect(session,"PV","name==\"DETECTOR\""); |
---|
| 41 | data_visualize(session); |
---|
| 42 | |
---|
| 43 | data_collect(session,"PV","name==\"[CALO:0.0.0]\""); |
---|
| 44 | data_visualize(session); |
---|
| 45 | |
---|
| 46 | data_collect(session,"PV","name==\"CHAMBER\""); |
---|
| 47 | data_visualize(session); |
---|
| 48 | |
---|
| 49 | data_collect(session,"PV","name==\"[SOURCE.STRIP:0.0]\""); |
---|
| 50 | data_visualize(session); |
---|
| 51 | |
---|
| 52 | data_collect(session,"PV","name==\"[TC.CELL:0.0.0]\""); |
---|
| 53 | data_visualize(session); |
---|
| 54 | |
---|
| 55 | data_collect(session,"PV","name==\"[TC.LAYER:1.0]\""); |
---|
| 56 | data_visualize(session); |
---|
| 57 | |
---|
| 58 | } |
---|
| 59 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 60 | void snovis_layout_default( |
---|
| 61 | Slash::UI::IUI& aUI |
---|
| 62 | ) |
---|
| 63 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 64 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 65 | { |
---|
| 66 | ////////////////////////////////////////////////////////////////////////// |
---|
| 67 | // Prepare the page : |
---|
| 68 | ////////////////////////////////////////////////////////////////////////// |
---|
| 69 | SoPage* soPage = ui_SoPage(aUI); |
---|
| 70 | if(!soPage) return; |
---|
| 71 | |
---|
| 72 | soPage->deleteRegions(); |
---|
| 73 | soPage->titleVisible.setValue(FALSE); |
---|
| 74 | soPage->createRegions("SoDisplayRegion",1,1,1); |
---|
| 75 | |
---|
| 76 | // Lonely region ; front view : |
---|
| 77 | soPage->setCurrentRegion(0); |
---|
| 78 | SoRegion* soRegion = soPage->currentRegion(); |
---|
| 79 | if(!soRegion) return; |
---|
| 80 | SoRegion* fromRegion = soRegion; |
---|
| 81 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 82 | |
---|
| 83 | SoCamera* soCamera = soRegion->getCamera(); |
---|
| 84 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 85 | ((SoOrthographicCamera*)soCamera)->height.setValue(5000); |
---|
| 86 | soCamera->position.setValue(0,0,5000); |
---|
| 87 | soCamera->orientation.setValue(SbRotation(SbVec3f(0,1,0),0)); |
---|
| 88 | soCamera->nearDistance.setValue(1); |
---|
| 89 | soCamera->farDistance.setValue(100000); |
---|
| 90 | soCamera->focalDistance.setValue(5000); |
---|
| 91 | |
---|
| 92 | ////////////////////////////////////////////////////////////////////////// |
---|
| 93 | // Scene : |
---|
| 94 | ////////////////////////////////////////////////////////////////////////// |
---|
| 95 | soPage->setCurrentRegion(0); |
---|
| 96 | |
---|
| 97 | snovis_scene_default(aUI); |
---|
| 98 | } |
---|
| 99 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 100 | void snovis_layout_front_top( |
---|
| 101 | Slash::UI::IUI& aUI |
---|
| 102 | ) |
---|
| 103 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 104 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 105 | { |
---|
| 106 | ////////////////////////////////////////////////////////////////////////// |
---|
| 107 | // Prepare the page : |
---|
| 108 | ////////////////////////////////////////////////////////////////////////// |
---|
| 109 | SoPage* soPage = ui_SoPage(aUI); |
---|
| 110 | if(!soPage) return; |
---|
| 111 | |
---|
| 112 | soPage->deleteRegions(); |
---|
| 113 | soPage->titleVisible.setValue(FALSE); |
---|
| 114 | soPage->createRegions("SoDisplayRegion",1,2,1); |
---|
| 115 | |
---|
| 116 | // First region ; front view : |
---|
| 117 | soPage->setCurrentRegion(0); |
---|
| 118 | SoRegion* soRegion = soPage->currentRegion(); |
---|
| 119 | if(!soRegion) return; |
---|
| 120 | SoRegion* fromRegion = soRegion; |
---|
| 121 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 122 | |
---|
| 123 | SoCamera* soCamera = soRegion->getCamera(); |
---|
| 124 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 125 | ((SoOrthographicCamera*)soCamera)->height.setValue(5000); |
---|
| 126 | soCamera->position.setValue(0,0,5000); |
---|
| 127 | soCamera->orientation.setValue(SbRotation(SbVec3f(0,1,0),0)); |
---|
| 128 | soCamera->nearDistance.setValue(1); |
---|
| 129 | soCamera->farDistance.setValue(100000); |
---|
| 130 | soCamera->focalDistance.setValue(5000); |
---|
| 131 | |
---|
| 132 | // Second region ; top view : |
---|
| 133 | soPage->setCurrentRegion(1); |
---|
| 134 | soRegion = soPage->currentRegion(); |
---|
| 135 | if(!soRegion) return; |
---|
| 136 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 137 | soRegion->connectFrom(fromRegion); |
---|
| 138 | |
---|
| 139 | soCamera = soRegion->getCamera(); |
---|
| 140 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 141 | ((SoOrthographicCamera*)soCamera)->height.setValue(5000); |
---|
| 142 | soCamera->position.setValue(0,5000,0); |
---|
| 143 | soCamera->orientation.setValue(SbRotation(SbVec3f(1,0,0),-1.57F)); |
---|
| 144 | soCamera->nearDistance.setValue(1); |
---|
| 145 | soCamera->farDistance.setValue(100000); |
---|
| 146 | soCamera->focalDistance.setValue(5000); |
---|
| 147 | |
---|
| 148 | ////////////////////////////////////////////////////////////////////////// |
---|
| 149 | // Scene : |
---|
| 150 | ////////////////////////////////////////////////////////////////////////// |
---|
| 151 | |
---|
| 152 | soPage->setCurrentRegion(0); |
---|
| 153 | |
---|
| 154 | snovis_scene_default(aUI); |
---|
| 155 | } |
---|
| 156 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 157 | void snovis_layout_CAD( |
---|
| 158 | Slash::UI::IUI& aUI |
---|
| 159 | ) |
---|
| 160 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 161 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 162 | { |
---|
| 163 | ////////////////////////////////////////////////////////////////////////// |
---|
| 164 | // Prepare the page : |
---|
| 165 | ////////////////////////////////////////////////////////////////////////// |
---|
| 166 | SoPage* soPage = ui_SoPage(aUI); |
---|
| 167 | if(!soPage) return; |
---|
| 168 | |
---|
| 169 | soPage->deleteRegions(); |
---|
| 170 | soPage->titleVisible.setValue(FALSE); |
---|
| 171 | soPage->createRegions("SoDisplayRegion",2,2,1); |
---|
| 172 | |
---|
| 173 | // Connect the second, third, fourth region to the first one. |
---|
| 174 | |
---|
| 175 | // First region ; side view, +z at right : |
---|
| 176 | soPage->setCurrentRegion(0); |
---|
| 177 | SoRegion* soRegion = soPage->currentRegion(); |
---|
| 178 | if(!soRegion) return; |
---|
| 179 | SoRegion* fromRegion = soRegion; |
---|
| 180 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 181 | |
---|
| 182 | float size = 5500; |
---|
| 183 | |
---|
| 184 | SoCamera* soCamera = soRegion->getCamera(); |
---|
| 185 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 186 | ((SoOrthographicCamera*)soCamera)->height.setValue(size); |
---|
| 187 | soCamera->position.setValue(-size,0,0); |
---|
| 188 | soCamera->orientation.setValue(SbRotation(SbVec3f(0,1,0),-FM_PI_2)); |
---|
| 189 | soCamera->nearDistance.setValue(1); |
---|
| 190 | soCamera->farDistance.setValue(100000); |
---|
| 191 | soCamera->focalDistance.setValue(size); |
---|
| 192 | |
---|
| 193 | // Second region ; front view : |
---|
| 194 | soPage->setCurrentRegion(1); |
---|
| 195 | soRegion = soPage->currentRegion(); |
---|
| 196 | if(!soRegion) return; |
---|
| 197 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 198 | soRegion->connectFrom(fromRegion); |
---|
| 199 | |
---|
| 200 | soCamera = soRegion->getCamera(); |
---|
| 201 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 202 | ((SoOrthographicCamera*)soCamera)->height.setValue(size); |
---|
| 203 | soCamera->position.setValue(0,0,size); |
---|
| 204 | soCamera->orientation.setValue(SbRotation(SbVec3f(0,1,0),0)); |
---|
| 205 | soCamera->nearDistance.setValue(1); |
---|
| 206 | soCamera->farDistance.setValue(100000); |
---|
| 207 | soCamera->focalDistance.setValue(size); |
---|
| 208 | |
---|
| 209 | // Third region ; top view : |
---|
| 210 | soPage->setCurrentRegion(2); |
---|
| 211 | soRegion = soPage->currentRegion(); |
---|
| 212 | if(!soRegion) return; |
---|
| 213 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 214 | soRegion->connectFrom(fromRegion); |
---|
| 215 | |
---|
| 216 | soCamera = soRegion->getCamera(); |
---|
| 217 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 218 | ((SoOrthographicCamera*)soCamera)->height.setValue(size); |
---|
| 219 | soCamera->position.setValue(0,size,9); |
---|
| 220 | soCamera->orientation.setValue(SbRotation(SbVec3f(-1,-1,-1),2*FM_PI/3)); |
---|
| 221 | soCamera->nearDistance.setValue(1); |
---|
| 222 | soCamera->farDistance.setValue(100000); |
---|
| 223 | soCamera->focalDistance.setValue(size); |
---|
| 224 | |
---|
| 225 | // Fourth region ; 3D view : |
---|
| 226 | soPage->setCurrentRegion(3); |
---|
| 227 | soRegion = soPage->currentRegion(); |
---|
| 228 | if(!soRegion) return; |
---|
| 229 | soRegion->color.setValue(SbColor(0,0,0)); |
---|
| 230 | soRegion->connectFrom(fromRegion); |
---|
| 231 | |
---|
| 232 | size = 2*size; |
---|
| 233 | |
---|
| 234 | soCamera = soRegion->getCamera(); |
---|
| 235 | if(soCamera->isOfType(SoOrthographicCamera::getClassTypeId())) |
---|
| 236 | ((SoOrthographicCamera*)soCamera)->height.setValue(size); |
---|
| 237 | soCamera->position.setValue(-10866.0F,12873.0F,-8335.0F); |
---|
| 238 | soCamera->orientation.setValue |
---|
| 239 | (SbRotation(SbVec3f(-0.178F,-0.92F,-0.361F),2.27F)); |
---|
| 240 | soCamera->nearDistance.setValue(1); |
---|
| 241 | soCamera->farDistance.setValue(100000); |
---|
| 242 | soCamera->focalDistance.setValue(size); |
---|
| 243 | |
---|
| 244 | //////////////////////////////////////////////////////////////////////////// |
---|
| 245 | // Scene : |
---|
| 246 | //////////////////////////////////////////////////////////////////////////// |
---|
| 247 | |
---|
| 248 | soPage->setCurrentRegion(0); |
---|
| 249 | |
---|
| 250 | snovis_scene_default(aUI); |
---|
| 251 | } |
---|
| 252 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 253 | void snovis_InputLayout_ok( |
---|
| 254 | Slash::UI::IUI& aUI |
---|
| 255 | ) |
---|
| 256 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 257 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 258 | { |
---|
| 259 | std::string layout; |
---|
| 260 | if(!aUI.parameterValue |
---|
| 261 | ("snovis_InputLayout_input_layout.value",layout)) return; |
---|
| 262 | |
---|
| 263 | aUI.executeScript("DLD","snovis snovis_layout_"+layout); |
---|
| 264 | |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | } |
---|