fshake3d  0.0.1
FreeformDensity3DSurfaceEditor
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
ui_SceneViewOrtho.cpp
Go to the documentation of this file.
00001 #include "ui_SceneViewOrtho.hpp"
00002 
00003 SceneViewOrtho::SceneViewOrtho()
00004 : SceneView(ProjectionType_ORTHO)
00005 , mRuler()
00006 , mDirectionX(1,0,0)
00007 , mDirectionY(0,1,0)
00008 , mXAxis(0)
00009 , mYAxis(1)
00010 {
00011 }
00012 
00013 /*
00014 void SceneViewOrtho::setAspect(double aspect)
00015 {
00016   mProjection.setAspect(aspect);
00017 }
00018 */
00019 
00020 void SceneViewOrtho::setDirectionX(Vec3d dirx)  {  mDirectionX = dirx;  }
00021 void SceneViewOrtho::setDirectionY(Vec3d diry)  {  mDirectionY = diry;  }
00022 void SceneViewOrtho::setXAxis(int xaxis) { mXAxis = xaxis; }
00023 void SceneViewOrtho::setYAxis(int yaxis) { mYAxis = yaxis; }
00024 
00025 void SceneViewOrtho::setViewport(const Vec4i& vp)
00026 {
00027   SceneView::setViewport(vp);
00028   mRuler.setViewport(vp);
00029 }
00030 
00031 void SceneViewOrtho::dragBegin()
00032 {
00033   switch(mDragButton)
00034   {
00035   case GLUT_RIGHT_BUTTON:
00036     if (mpFocusPoint)
00037     {
00038       mCenterBase = *mpFocusPoint; // mpScene->getViewPoint().getFocusPoint();
00039     }
00040     break;
00041   case GLUT_MIDDLE_BUTTON:
00042     if (mpZoom)
00043     {
00044       mZoomBase = *mpZoom;
00045     }
00046     break;
00047   }
00048 }
00049 
00050 void SceneViewOrtho::dragUpdate(const Vec2i& d)
00051 {
00052   switch(mDragButton)
00053   {
00054   case GLUT_RIGHT_BUTTON:
00055     {
00056     const Vec2d& size = mProjection.getViewSize();
00057     Vec2d unit( size[0]/width() , size[1]/height() );
00058     *mpFocusPoint = mCenterBase - ( mDirectionX*double(d[0])*unit[0] ) - ( mDirectionY*double(d[1])*unit[1] );
00059     }
00060     break;
00061   case GLUT_MIDDLE_BUTTON:
00062     *mpZoom = mZoomBase + d[1];
00063     break;
00064   }
00065 }
00066 
00067 void SceneViewOrtho::updateRuler()
00068 {
00069   const Point3d& focus = *mpFocusPoint; //mpScene->getViewPoint().getFocusPoint();
00070 
00071   mRuler.setLeft( focus[mXAxis] - mProjection.getViewWidth() * 0.5  );
00072   mRuler.setWidth( mProjection.getViewWidth() );
00073   mRuler.setBottom( focus[mYAxis] - mProjection.getViewHeight() * 0.5 );
00074   mRuler.setHeight( mProjection.getViewHeight() );
00075   
00076   double s = Math::Min(mProjection.getViewWidth(),mProjection.getViewHeight());
00077   mRuler.setTick(s/4);
00078 }
00079 
00080 void SceneViewOrtho::display()
00081 {
00082   SceneView::display();
00083   updateRuler();
00084   mRuler.display();
00085 }
00086 
00087 void SceneViewOrtho::setProjectionViewSize(const Vec2d& size)
00088 { 
00089   SceneView::setProjectionViewSize(size);
00090   double s = Math::Min(size[0],size[1]);
00091   mRuler.setTick(s/4);  
00092 }
00093