3535#include < Interface/Modules/Render/ES/SRCamera.h>
3636
3737#include < Core/Application/Application.h>
38- #include < Modules/Visualization/ShowColorMapModule.h>
38+ // #include <Modules/Visualization/ShowColorMapModule.h>
39+ #include < Graphics/Glyphs/GlyphGeom.h>
3940
4041// CPM modules.
4142#include < es-general/comp/StaticScreenDims.hpp>
6061#include " comp/SRRenderState.h"
6162#include " comp/RenderList.h"
6263#include " comp/StaticWorldLight.h"
63- #include " comp/StaticClippingPlanes.h"
6464#include " comp/LightingUniforms.h"
6565#include " comp/ClippingPlaneUniforms.h"
6666
@@ -75,8 +75,6 @@ namespace fs = CPM_ES_FS_NS;
7575namespace SCIRun {
7676 namespace Render {
7777
78- std::string SRInterface::mFSRoot ;
79- std::string SRInterface::mFSSeparator ;
8078 // ------------------------------------------------------------------------------
8179 SRInterface::SRInterface (std::shared_ptr<Gui::GLContext> context,
8280 int frameInitLimit) :
@@ -145,10 +143,6 @@ namespace SCIRun {
145143 mCore .addStaticComponent (iface);
146144 }
147145
148- std::string filesystemRoot = Core::Application::Instance ().executablePath ().string ();
149- std::string sep;
150- sep += boost::filesystem::path::preferred_separator;
151- Modules::Visualization::ShowColorMapModule::setFSStrings (filesystemRoot, sep);
152146 }
153147
154148 // ------------------------------------------------------------------------------
@@ -558,16 +552,6 @@ namespace SCIRun {
558552 return mWidgetTransform ;
559553 }
560554
561- std::string &SRInterface::getFSRoot ()
562- {
563- return mFSRoot ;
564- }
565-
566- std::string &SRInterface::getFSSeparator ()
567- {
568- return mFSSeparator ;
569- }
570-
571555 // ------------------------------------------------------------------------------
572556 // --------------Clipping Plane Tools--------------------------------------------
573557 void SRInterface::checkClippingPlanes (int n)
@@ -602,6 +586,7 @@ namespace SCIRun {
602586 {
603587 checkClippingPlanes (clippingPlaneIndex_);
604588 clippingPlanes_[clippingPlaneIndex_].showFrame = value;
589+ updateClippingPlanes ();
605590 }
606591
607592 void SRInterface::reverseClippingPlaneNormal (bool value)
@@ -639,6 +624,36 @@ namespace SCIRun {
639624 updateClippingPlanes ();
640625 }
641626
627+ const glm::mat4& SRInterface::getWorldToProjection () const
628+ { return mCamera ->getWorldToProjection (); }
629+
630+ const glm::mat4& SRInterface::getWorldToView () const
631+ { return mCamera ->getWorldToView (); }
632+
633+ const glm::mat4& SRInterface::getViewToWorld () const
634+ { return mCamera ->getViewToWorld (); }
635+
636+ const glm::mat4& SRInterface::getViewToProjection () const
637+ { return mCamera ->getViewToProjection (); }
638+
639+ // ------------------------------------------------------------------------------
640+ /* void SRInterface::setScaleBar(const ScaleBar &scaleBarData)
641+ {
642+ scaleBar_.visible = scaleBarData.visible;
643+ scaleBar_.fontSize = scaleBarData.fontSize;
644+ scaleBar_.length = scaleBarData.length;
645+ scaleBar_.height = scaleBarData.height;
646+ scaleBar_.multiplier = scaleBarData.multiplier;
647+ scaleBar_.numTicks = scaleBarData.numTicks;
648+ scaleBar_.lineWidth = scaleBarData.lineWidth;
649+ scaleBar_.unit = scaleBarData.unit;
650+ if (scaleBar_.visible)
651+ {
652+ updateScaleBarLength();
653+ updateGeometryScaleBar();
654+ }
655+ }*/
656+
642657 // ------------------------------------------------------------------------------
643658 void SRInterface::inputMouseUp (const glm::ivec2& /* pos*/ , MouseButton /* btn*/ )
644659 {
@@ -1267,22 +1282,77 @@ namespace SCIRun {
12671282 }
12681283
12691284 //
1285+ double SRInterface::getMaxProjLength (const glm::vec3 &n)
1286+ {
1287+ glm::vec3 a1 (-1.0 , 1.0 , -1.0 );
1288+ glm::vec3 a2 (-1.0 , 1.0 , 1.0 );
1289+ glm::vec3 a3 (1.0 , 1.0 , -1.0 );
1290+ glm::vec3 a4 (1.0 , 1.0 , 1.0 );
1291+ return std::max (
1292+ std::max (
1293+ std::abs (glm::dot (n, a1)),
1294+ std::abs (glm::dot (n, a2))),
1295+ std::max (
1296+ std::abs (glm::dot (n, a3)),
1297+ std::abs (glm::dot (n, a4))));
1298+ }
1299+
12701300 void SRInterface::updateClippingPlanes ()
12711301 {
12721302 StaticClippingPlanes* clippingPlanes = mCore .getStaticComponent <StaticClippingPlanes>();
12731303 if (clippingPlanes)
12741304 {
12751305 clippingPlanes->clippingPlanes .clear ();
12761306 clippingPlanes->clippingPlaneCtrls .clear ();
1307+ // boundbox transformation
1308+ glm::mat4 trans_bb;
1309+ glm::vec3 scale_bb (mSceneBBox .x_length () / 2.0 , mSceneBBox .y_length () / 2.0 , mSceneBBox .z_length () / 2.0 );
1310+ glm::vec3 center_bb (mSceneBBox .center ().x (), mSceneBBox .center ().y (), mSceneBBox .center ().z ());
1311+ trans_bb = glm::scale (trans_bb, scale_bb);
1312+ trans_bb = glm::translate (trans_bb, center_bb);
1313+ int index = 0 ;
12771314 for (auto i : clippingPlanes_)
12781315 {
1279- clippingPlanes->clippingPlanes .push_back (glm::vec4 (i.x , i.y , i.z , i.d ));
1280- clippingPlanes->clippingPlaneCtrls .push_back (
1281- glm::vec4 (i.visible ?1.0 :0.0 , i.showFrame ?1.0 :0.0 , i.reverseNormal ?1.0 :0.0 , 0.0 ));
1316+ glm::vec3 n3 (i.x , i.y , i.z );
1317+ double d = i.d ;
1318+ glm::vec4 n (0.0 );
1319+ if (glm::length (n3) > 0.0 )
1320+ {
1321+ n3 = glm::normalize (n3);
1322+ n = glm::vec4 (n3, 0.0 );
1323+ d *= getMaxProjLength (n3);
1324+ }
1325+ glm::vec4 o = glm::vec4 (n.x , n.y , n.z , 1.0 ) * d;
1326+ o.w = 1 ;
1327+ o = trans_bb * o;
1328+ n = glm::inverseTranspose (trans_bb) * n;
1329+ o.w = 0 ;
1330+ n.w = 0 ;
1331+ n.w = glm::dot (o, n);
1332+ clippingPlanes->clippingPlanes .push_back (n);
1333+ glm::vec4 control (i.visible ? 1.0 : 0.0 ,
1334+ i.showFrame ? 1.0 : 0.0 ,
1335+ i.reverseNormal ? 1.0 : 0.0 , 0.0 );
1336+ clippingPlanes->clippingPlaneCtrls .push_back (control);
1337+ // if (i.showFrame)
1338+ // updateGeometryClippingPlane(index, n);
1339+ index++;
12821340 }
12831341 }
12841342 }
12851343
1344+ StaticClippingPlanes* SRInterface::getClippingPlanes ()
1345+ {
1346+ StaticClippingPlanes* clippingPlanes = mCore .getStaticComponent <StaticClippingPlanes>();
1347+ return clippingPlanes;
1348+ }
1349+
1350+ // get scenenox
1351+ Core::Geometry::BBox SRInterface::getSceneBox ()
1352+ {
1353+ return mSceneBBox ;
1354+ }
1355+
12861356 // ------------------------------------------------------------------------------
12871357 void SRInterface::renderCoordinateAxes ()
12881358 {
0 commit comments