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>
3939#include < Graphics/Glyphs/GlyphGeom.h>
4040
4141// CPM modules.
@@ -144,10 +144,6 @@ namespace SCIRun {
144144 mCore .addStaticComponent (iface);
145145 }
146146
147- std::string filesystemRoot = Core::Application::Instance ().executablePath ().string ();
148- std::string sep;
149- sep += boost::filesystem::path::preferred_separator;
150- Modules::Visualization::TextBuilder::setFSStrings (filesystemRoot, sep);
151147 }
152148
153149 // ------------------------------------------------------------------------------
@@ -247,11 +243,6 @@ namespace SCIRun {
247243 void SRInterface::inputMouseWheel (int32_t delta)
248244 {
249245 mCamera ->mouseWheelEvent (delta, mZoomSpeed );
250- if (scaleBar_.visible )
251- {
252- updateScaleBarLength ();
253- updateGeometryScaleBar ();
254- }
255246 }
256247
257248 // ------------------------------------------------------------------------------
@@ -634,8 +625,20 @@ namespace SCIRun {
634625 updateClippingPlanes ();
635626 }
636627
628+ const glm::mat4& SRInterface::getWorldToProjection () const
629+ { return mCamera ->getWorldToProjection (); }
630+
631+ const glm::mat4& SRInterface::getWorldToView () const
632+ { return mCamera ->getWorldToView (); }
633+
634+ const glm::mat4& SRInterface::getViewToWorld () const
635+ { return mCamera ->getViewToWorld (); }
636+
637+ const glm::mat4& SRInterface::getViewToProjection () const
638+ { return mCamera ->getViewToProjection (); }
639+
637640 // ------------------------------------------------------------------------------
638- void SRInterface::setScaleBar (const ScaleBar &scaleBarData)
641+ /* void SRInterface::setScaleBar(const ScaleBar &scaleBarData)
639642 {
640643 scaleBar_.visible = scaleBarData.visible;
641644 scaleBar_.fontSize = scaleBarData.fontSize;
@@ -650,7 +653,7 @@ namespace SCIRun {
650653 updateScaleBarLength();
651654 updateGeometryScaleBar();
652655 }
653- }
656+ }*/
654657
655658 // ------------------------------------------------------------------------------
656659 void SRInterface::inputMouseUp (const glm::ivec2& /* pos*/ , MouseButton /* btn*/ )
@@ -1399,143 +1402,6 @@ namespace SCIRun {
13991402 handleGeomObject(geom2, 0);*/
14001403 }
14011404
1402- // update scale bar geometries
1403- void SRInterface::updateGeometryScaleBar ()
1404- {
1405- const int numTicks = scaleBar_.numTicks ;
1406- const double mult = scaleBar_.multiplier ;
1407- double length = scaleBar_.projLength ;
1408- const double height = scaleBar_.height ;
1409- glm::vec4 color (1.0 );
1410- glm::vec4 shift (1.9 , 0.1 , 0.0 , 0.0 );
1411-
1412- std::vector<Vector> points;
1413- std::vector<uint32_t > indices;
1414- int32_t numVBOElements = 0 ;
1415- uint32_t index = 0 ;
1416- // base line
1417- points.push_back (Vector (-length, 0.0 , 0.0 ));
1418- points.push_back (Vector (0.0 , 0.0 , 0.0 ));
1419- numVBOElements += 2 ;
1420- indices.push_back (index++);
1421- indices.push_back (index++);
1422- if (numTicks > 1 )
1423- {
1424- for (int i = 0 ; i < numTicks; ++i)
1425- {
1426- double x = -length + i*length / (numTicks-1 );
1427- points.push_back (Vector (x, 0.0 , 0.0 ));
1428- points.push_back (Vector (x, height, 0.0 ));
1429- numVBOElements += 2 ;
1430- indices.push_back (index++);
1431- indices.push_back (index++);
1432- }
1433- }
1434-
1435- // IBO/VBOs and sizes
1436- uint32_t iboSize = sizeof (uint32_t ) * static_cast <uint32_t >(indices.size ());
1437- uint32_t vboSize = sizeof (float ) * 3 * static_cast <uint32_t >(points.size ());
1438-
1439- std::shared_ptr<CPM_VAR_BUFFER_NS::VarBuffer> iboBufferSPtr (
1440- new CPM_VAR_BUFFER_NS::VarBuffer (vboSize));
1441- std::shared_ptr<CPM_VAR_BUFFER_NS::VarBuffer> vboBufferSPtr (
1442- new CPM_VAR_BUFFER_NS::VarBuffer (iboSize));
1443-
1444- CPM_VAR_BUFFER_NS::VarBuffer* iboBuffer = iboBufferSPtr.get ();
1445- CPM_VAR_BUFFER_NS::VarBuffer* vboBuffer = vboBufferSPtr.get ();
1446-
1447- for (auto a : indices) iboBuffer->write (a);
1448-
1449- for (size_t i = 0 ; i < points.size (); i++) {
1450- vboBuffer->write (static_cast <float >(points[i].x ()));
1451- vboBuffer->write (static_cast <float >(points[i].y ()));
1452- vboBuffer->write (static_cast <float >(points[i].z ()));
1453- }
1454-
1455- std::stringstream ss;
1456- ss << " scale_bar" ;
1457- std::string uniqueNodeID = ss.str ();
1458- std::string vboName = uniqueNodeID + " VBO" ;
1459- std::string iboName = uniqueNodeID + " IBO" ;
1460- std::string passName = uniqueNodeID + " Pass" ;
1461-
1462- // Construct VBO.
1463- std::string shader = " Shaders/HudUniform" ;
1464- std::vector<SpireVBO::AttributeData> attribs;
1465- attribs.push_back (SpireVBO::AttributeData (" aPos" , 3 * sizeof (float )));
1466- std::vector<SpireSubPass::Uniform> uniforms;
1467- uniforms.push_back (SpireSubPass::Uniform (" uTrans" , shift));
1468- uniforms.push_back (SpireSubPass::Uniform (" uColor" , color));
1469- SpireVBO geomVBO = SpireVBO (vboName, attribs, vboBufferSPtr,
1470- numVBOElements, BBox (), true );
1471-
1472- // Construct IBO.
1473-
1474- SpireIBO geomIBO (iboName, SpireIBO::LINES, sizeof (uint32_t ), iboBufferSPtr);
1475-
1476- RenderState renState;
1477- renState.set (RenderState::IS_ON, true );
1478- renState.set (RenderState::HAS_DATA, true );
1479- renState.set (RenderState::USE_COLORMAP, false );
1480- renState.set (RenderState::USE_TRANSPARENCY, false );
1481-
1482- SpireText text;
1483-
1484- SpireSubPass pass (passName, vboName, iboName, shader,
1485- COLOR_MAP, renState, RENDER_VBO_IBO, geomVBO, geomIBO, text);
1486-
1487- // Add all uniforms generated above to the pass.
1488- for (const auto & uniform : uniforms) { pass.addUniform (uniform); }
1489-
1490- GeometryHandle geom (new GeometryObjectSpire (uniqueNodeID));
1491-
1492- geom->mIBOs .push_back (geomIBO);
1493- geom->mVBOs .push_back (geomVBO);
1494- geom->mPasses .push_back (pass);
1495-
1496- // text
1497- size_t text_size = size_t (scaleBar_.fontSize );
1498- if (!textBuilder_.isInit ())
1499- textBuilder_.initFreeType (" FreeSans.ttf" , text_size);
1500- else if (!textBuilder_.isValid ())
1501- textBuilder_.loadNewFace (" FreeSans.ttf" , text_size);
1502- if (textBuilder_.isInit () && textBuilder_.isValid ())
1503- {
1504- if (textBuilder_.getFaceSize () != text_size)
1505- textBuilder_.setFaceSize (text_size);
1506- textBuilder_.setColor (glm::vec4 (1.0 , 1.0 , 1.0 , 1.0 ));
1507- std::stringstream ss;
1508- std::string oneline;
1509- ss << length << " " << scaleBar_.unit ;
1510- oneline = ss.str ();
1511- Vector shift (1.9 , 0.1 , 0.0 );
1512- Vector trans (10.0 , 0.0 , 0.0 );
1513- textBuilder_.printString (oneline, shift, trans, uniqueNodeID, geom);
1514- }
1515-
1516- handleGeomObject (geom, 0 );
1517- }
1518-
1519- void SRInterface::updateScaleBarLength ()
1520- {
1521- glm::vec4 p1 (-scaleBar_.length / 2.0 , 0.0 , 0.0 , 1.0 );
1522- glm::vec4 p2 (scaleBar_.length / 2.0 , 0.0 , 0.0 , 1.0 );
1523- glm::mat4 matIV = mCamera ->getWorldToView ();
1524- matIV[0 ][0 ] = 1.0 ; matIV[0 ][1 ] = 0.0 ; matIV[0 ][2 ] = 0.0 ;
1525- matIV[1 ][0 ] = 0.0 ; matIV[1 ][1 ] = 1.0 ; matIV[1 ][2 ] = 0.0 ;
1526- matIV[2 ][0 ] = 0.0 ; matIV[2 ][1 ] = 0.0 ; matIV[2 ][2 ] = 1.0 ;
1527- glm::mat4 matProj = mCamera ->getViewToProjection ();
1528- p1 = matProj * matIV * p1;
1529- p2 = matProj * matIV * p2;
1530- glm::vec2 p (p1.x /p1.w -p2.x /p2.w , p1.y /p1.w -p2.y /p2.w );
1531- glm::vec2 pp (p.x *mScreenWidth / 2.0 ,
1532- p.y *mScreenHeight / 2.0 );
1533- scaleBar_.projLength = glm::length (pp);
1534- // std::cout << "p1:\t" << p1.x << "\t" << p1.y << "\t" << p1.z << "\t" << p1.w << "\n";
1535- // std::cout << "p2:\t" << p2.x << "\t" << p2.y << "\t" << p2.z << "\t" << p2.w << "\n";
1536- // std::cout << "pp:\t" << pp.x << "\t" << pp.y << "\n";
1537- }
1538-
15391405 // ------------------------------------------------------------------------------
15401406 void SRInterface::renderCoordinateAxes ()
15411407 {
0 commit comments