00001 #include "Iguana/GLBrowsers/interface/IgLegoBrowser.h"
00002 #include "Iguana/GLModels/interface/Ig3DBaseRep.h"
00003 #include "Iguana/GLModels/interface/IgLegoModel.h"
00004 #include <Inventor/nodes/SoGroup.h>
00005 #include <Inventor/nodes/SoOrthographicCamera.h>
00006 #include <Inventor/SbLinear.h>
00007 #include <Inventor/nodes/SoCamera.h>
00008 #include <Inventor/fields/SoSFVec3f.h>
00009 #include <iostream>
00010 #include <qpopupmenu.h>
00011 #include <cmath>
00012
00013 const char *
00014 IgLegoBrowser::catalogLabel (void)
00015 { return "Lego"; }
00016
00017 IgLegoBrowser::IgLegoBrowser (IgState *state,
00018 IgSite *site,
00019 IgLegoModel *model)
00020 : Ig3DBaseBrowser (state,
00021 site,
00022 model ? model : new IgLegoModel (state))
00023 {
00024 init ();
00025 }
00026
00027 void
00028 IgLegoBrowser::init (void)
00029 {
00030 SoQtExaminerViewer::setCameraType (SoOrthographicCamera::getClassTypeId ());
00031 SoOrthographicCamera * const camera = dynamic_cast <SoOrthographicCamera *> (this->getCamera ());
00032 if (!camera) return;
00033
00034 camera->position.setValue (7.2122893, 4.4723949, 2.5151112);
00035 camera->orientation.setValue (-0.53453183, 0.81074113, 0.23869397, 1.1617218);
00036 camera->aspectRatio = 1.0;
00037 camera->focalDistance = 6.5153651;
00038 camera->height = 13.03073;
00039 camera->nearDistance = 0.1;
00040 camera->farDistance = 32767;
00041
00042 setBackgroundColor (SbColor (1.0, 1.0, 1.0));
00043 }
00044
00045 QWidget *
00046 IgLegoBrowser::buildLeftTrim (QWidget *parent)
00047 {
00048 QWidget *result = new QWidget (parent);
00049 result->setFixedWidth (0);
00050 return result;
00051 }
00052
00053 QWidget *
00054 IgLegoBrowser::buildBottomTrim (QWidget *parent)
00055 {
00056 QWidget *result = new QWidget (parent);
00057 result->setFixedHeight (0);
00058 return result;
00059 }
00060
00061 QWidget *
00062 IgLegoBrowser::buildRightTrim (QWidget *parent)
00063 {
00064 QWidget *result = new QWidget (parent);
00065 result->setFixedWidth (0);
00066 return result;
00067 }
00068
00069 void
00070 IgLegoBrowser::buildDecoration (QWidget *parent)
00071 {
00072 Ig3DBaseBrowser::buildDecoration (parent);
00073 return;
00074 }
00075
00076 void
00077 IgLegoBrowser::toggleCameraType (void)
00078 {
00079 SoQtExaminerViewer::toggleCameraType ();
00080 Ig3DBaseBrowser::toggleCameraType ();
00081 }
00082
00083 void
00084 IgLegoBrowser::invertCamera (void)
00085 {
00086 SoCamera * const camera = this->getCamera ();
00087 if (!camera) return;
00088
00089 camera->position = camera->position.getValue () * -1.0F;
00090 }
00091
00092 void
00093 IgLegoBrowser::viewPlaneX (void)
00094 {
00095 SoCamera * const camera = this->getCamera ();
00096 if (!camera) return;
00097
00098 camera->position = SbVec3f (-1, 0, 0) * camera->position.getValue ().length ();
00099 camera->orientation = SbRotation (SbVec3f (0, 1, 0), -M_PI / 2.f);
00100 }
00101
00102 void
00103 IgLegoBrowser::viewPlaneY (void)
00104 {
00105 SoCamera * const camera = this->getCamera ();
00106 if (!camera) return;
00107
00108 SbVec3f norient = SbVec3f (0, -1, 0);
00109 camera->position = -norient * camera->position.getValue().length();
00110 camera->orientation = SbRotation (SbVec3f (0, 0, 1), -M_PI / 2.f) *
00111 SbRotation (SbVec3f (0, 0, -1), norient);
00112 }
00113
00114 void
00115 IgLegoBrowser::viewPlaneZ (void)
00116 {
00117 SoCamera * const camera = this->getCamera ();
00118 if (!camera) return;
00119
00120 camera->position = SbVec3f (0, 0, 1) * camera->position.getValue ().length ();
00121 camera->orientation = SbRotation::identity ();
00122 }