@@ -37,6 +37,8 @@ DEALINGS IN THE SOFTWARE.
3737#include < Modules/Render/ViewScene.h>
3838#include < Interface/Modules/Render/Screenshot.h>
3939#include < boost/thread.hpp>
40+ #include < Graphics/Glyphs/GlyphGeom.h>
41+ #include < Graphics/Datatypes/GeometryImpl.h>
4042
4143using namespace SCIRun ::Gui;
4244using namespace SCIRun ::Dataflow::Networks;
@@ -383,18 +385,33 @@ void ViewSceneDialog::newGeometryValue()
383385 }
384386 // add objects of its own
385387 // scale bar
388+ ++port;
386389 if (scaleBar_.visible && scaleBarGeom_)
387390 {
388391 auto name = scaleBarGeom_->uniqueID ();
389392 auto displayName = QString::fromStdString (name).split (' _' ).at (1 );
390- objectNames.push_back (displayName.toStdString ());
393+ objectNames.push_back (name /* displayName.toStdString()*/ );
391394 auto realObj = boost::dynamic_pointer_cast<Graphics::Datatypes::GeometryObjectSpire>(scaleBarGeom_);
392395 if (realObj)
393396 {
394397 spire->handleGeomObject (realObj, port);
395398 validObjects.push_back (name);
396399 }
397400 }
401+ ++port;
402+ // clippingplanes
403+ for (auto i : clippingPlaneGeoms_)
404+ {
405+ auto name = i->uniqueID ();
406+ auto displayName = QString::fromStdString (name).split (' _' ).at (1 );
407+ objectNames.push_back (name/* displayName.toStdString()*/ );
408+ auto realObj = boost::dynamic_pointer_cast<Graphics::Datatypes::GeometryObjectSpire>(i);
409+ if (realObj)
410+ {
411+ spire->handleGeomObject (realObj, port);
412+ validObjects.push_back (name);
413+ }
414+ }
398415 spire->gcInvalidObjects (validObjects);
399416
400417 sort (objectNames.begin (), objectNames.end ());
@@ -817,6 +834,7 @@ void ViewSceneDialog::setClippingPlaneVisible(bool value)
817834 auto spire = mSpire .lock ();
818835 if (spire)
819836 spire->setClippingPlaneVisible (clippingPlanes_[clippingPlaneIndex_].visible );
837+ updatClippingPlaneDisplay ();
820838}
821839
822840void ViewSceneDialog::setClippingPlaneFrameOn (bool value)
@@ -826,6 +844,7 @@ void ViewSceneDialog::setClippingPlaneFrameOn(bool value)
826844 auto spire = mSpire .lock ();
827845 if (spire)
828846 spire->setClippingPlaneFrameOn (clippingPlanes_[clippingPlaneIndex_].showFrame );
847+ updatClippingPlaneDisplay ();
829848}
830849
831850void ViewSceneDialog::reverseClippingPlaneNormal (bool value)
@@ -834,6 +853,7 @@ void ViewSceneDialog::reverseClippingPlaneNormal(bool value)
834853 auto spire = mSpire .lock ();
835854 if (spire)
836855 spire->reverseClippingPlaneNormal (clippingPlanes_[clippingPlaneIndex_].reverseNormal );
856+ updatClippingPlaneDisplay ();
837857}
838858
839859void ViewSceneDialog::setClippingPlaneX (int index)
@@ -879,6 +899,10 @@ void ViewSceneDialog::updatClippingPlaneDisplay()
879899 clippingPlanes_[clippingPlaneIndex_].y ,
880900 clippingPlanes_[clippingPlaneIndex_].z ,
881901 clippingPlanes_[clippingPlaneIndex_].d );
902+
903+ // geometry
904+ buildGeomClippingPlanes ();
905+ newGeometryValue ();
882906}
883907
884908// ------------------------------------------------------------------------------
@@ -1167,6 +1191,98 @@ void ViewSceneDialog::updateScaleBarLength()
11671191 }
11681192}
11691193
1194+ void ViewSceneDialog::buildGeomClippingPlanes ()
1195+ {
1196+ auto spire = mSpire .lock ();
1197+ if (!spire)
1198+ return ;
1199+ StaticClippingPlanes* clippingPlanes = spire->getClippingPlanes ();
1200+
1201+ clippingPlaneGeoms_.clear ();
1202+ int index = 0 ;
1203+ for (auto i : clippingPlanes->clippingPlanes )
1204+ {
1205+ if (clippingPlanes_[index].showFrame )
1206+ buildGeometryClippingPlane (index, i, spire->getSceneBox ());
1207+ index++;
1208+ }
1209+ }
1210+
1211+ //
1212+ void ViewSceneDialog::buildGeometryClippingPlane (
1213+ int index, glm::vec4 plane, SCIRun::Core::Geometry::BBox bbox)
1214+ {
1215+ Core::Geometry::Vector diag (bbox.diagonal ());
1216+ Core::Geometry::Point c (bbox.center ());
1217+ Core::Geometry::Vector n (plane.x , plane.y , plane.z );
1218+ n.normalize ();
1219+ Core::Geometry::Point p (c + (n * diag.length () / 2.0 ) * plane.w );
1220+ if (clippingPlanes_[index].reverseNormal )
1221+ n = -n;
1222+ double w, h; w = h = diag.length () / 2.0 ;
1223+ Core::Geometry::Vector axis1, axis2;
1224+ Point intersect;
1225+ n.find_orthogonal (axis1, axis2);
1226+ if (bbox.intersect (c, axis1, intersect))
1227+ w = std::max (w, 2.1 * (intersect - c).length ());
1228+ if (bbox.intersect (c, axis2, intersect))
1229+ h = std::max (h, 2.1 * (intersect - c).length ());
1230+ if (clippingPlanes_[index].reverseNormal )
1231+ p = Core::Geometry::Point (n * plane.w );
1232+ else
1233+ p = Core::Geometry::Point (-n * plane.w );
1234+ Core::Geometry::Point p1 = p - axis1 * w / 2.0 - axis2 * h / 2.0 ;
1235+ Core::Geometry::Point p2 = p + axis1 * w / 2.0 - axis2 * h / 2.0 ;
1236+ Core::Geometry::Point p3 = p + axis1 * w / 2.0 + axis2 * h / 2.0 ;
1237+ Core::Geometry::Point p4 = p - axis1 * w / 2.0 + axis2 * h / 2.0 ;
1238+
1239+ std::stringstream ss;
1240+ std::string uniqueNodeID;
1241+
1242+ Graphics::GlyphGeom glyphs;
1243+ glyphs.addClippingPlane (p1, p2, p3, p4, 0.01 * std::min (w, h),
1244+ 50 , ColorRGB (), ColorRGB ());
1245+ ss << " clipping_plane" << index <<
1246+ p1.x () << p1.y () << p1.z () <<
1247+ p2.x () << p2.y () << p2.z () <<
1248+ p3.x () << p3.y () << p3.z () <<
1249+ p4.x () << p4.y () << p4.z ();
1250+ uniqueNodeID = ss.str ();
1251+ Graphics::Datatypes::ColorScheme colorScheme (Graphics::Datatypes::ColorScheme::COLOR_UNIFORM);
1252+ RenderState renState;
1253+ renState.set (RenderState::IS_ON, true );
1254+ renState.set (RenderState::USE_TRANSPARENCY, false );
1255+ renState.defaultColor = ColorRGB (0.4 , 0.4 , 1 );
1256+ renState.set (RenderState::USE_DEFAULT_COLOR, true );
1257+ renState.set (RenderState::USE_NORMALS, true );
1258+ renState.set (RenderState::IS_WIDGET, true );
1259+ SCIRun::Graphics::Datatypes::GeometryHandle geom (
1260+ new SCIRun::Graphics::Datatypes::GeometryObjectSpire (uniqueNodeID));
1261+ glyphs.buildObject (geom, uniqueNodeID, renState.get (RenderState::USE_TRANSPARENCY), 1.0 ,
1262+ colorScheme, renState, SCIRun::Graphics::Datatypes::SpireIBO::TRIANGLES, bbox);
1263+ // handleGeomObject(geom, 0);
1264+
1265+ Graphics::GlyphGeom glyphs2;
1266+ glyphs2.addPlane (p1, p2, p3, p4, ColorRGB ());
1267+ ss.str (" " );
1268+ ss << " clipping_plane_trans" << index <<
1269+ p1.x () << p1.y () << p1.z () <<
1270+ p2.x () << p2.y () << p2.z () <<
1271+ p3.x () << p3.y () << p3.z () <<
1272+ p4.x () << p4.y () << p4.z ();
1273+ uniqueNodeID = ss.str ();
1274+ renState.set (RenderState::USE_TRANSPARENCY, true );
1275+ renState.defaultColor = ColorRGB (1 , 1 , 1 , 0.2 );
1276+ SCIRun::Graphics::Datatypes::GeometryHandle geom2 (
1277+ new SCIRun::Graphics::Datatypes::GeometryObjectSpire (ss.str ()));
1278+ glyphs2.buildObject (geom2, uniqueNodeID, renState.get (RenderState::USE_TRANSPARENCY), 0.2 ,
1279+ colorScheme, renState, SCIRun::Graphics::Datatypes::SpireIBO::TRIANGLES, bbox);
1280+ // handleGeomObject(geom2, 0);
1281+
1282+ clippingPlaneGeoms_.push_back (geom);
1283+ clippingPlaneGeoms_.push_back (geom2);
1284+ }
1285+
11701286// ------------------------------------------------------------------------------
11711287// -------------------Render Settings--------------------------------------------
11721288void ViewSceneDialog::lightingChecked (bool value)
0 commit comments