Skip to content

Commit 8c759f9

Browse files
author
tpat
committed
-created classes for cylinder and cone widget. -created class for linked composite widget
1 parent e6d258c commit 8c759f9

File tree

14 files changed

+818
-177
lines changed

14 files changed

+818
-177
lines changed

Superbuild/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ ENDIF()
3737
PROJECT(Superbuild)
3838

3939
INCLUDE(${CMAKE_SOURCE_DIR}/Superbuild.cmake)
40+

src/Graphics/Glyphs/GlyphGeom.cc

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ void GlyphGeom::addPoint(const Point& p, const ColorRGB& color)
280280
}
281281

282282
void GlyphGeom::generateCylinder(const Point& p1, const Point& p2, double radius1,
283-
double radius2, double resolution, const ColorRGB& color1, const ColorRGB& color2)
283+
double radius2, double resolution, const ColorRGB& color1,
284+
const ColorRGB& color2)
284285
{
285286
double num_strips = resolution;
286287
if (num_strips < 0) num_strips = 20.0;
@@ -292,6 +293,16 @@ void GlyphGeom::generateCylinder(const Point& p1, const Point& p2, double radius
292293
Vector crx = n.getArbitraryTangent();
293294
Vector u = Cross(crx, n).normal();
294295
Vector p;
296+
// points_.push_back(Vector(p1.x(), p1.y(), p1.z()));
297+
// points_.push_back(Vector(p2.x(), p2.y(), p2.z()));
298+
// int p1_index = numVBOElements_;
299+
// colors_.push_back(color1);
300+
// normals_.push_back(n);
301+
// numVBOElements_++;
302+
// int p2_index = numVBOElements_;
303+
// colors_.push_back(color2);
304+
// normals_.push_back(n);
305+
// numVBOElements_++;
295306
for (double strips = 0.; strips <= num_strips; strips += 1.)
296307
{
297308
uint32_t offset = static_cast<uint32_t>(numVBOElements_);
@@ -313,6 +324,22 @@ void GlyphGeom::generateCylinder(const Point& p1, const Point& p2, double radius
313324
indices_.push_back(2 + offset);
314325
indices_.push_back(1 + offset);
315326
indices_.push_back(3 + offset);
327+
328+
// Sides
329+
// points_.push_back(r1 * p + Vector(p1));
330+
// colors_.push_back(color1);
331+
// normals_.push_back(n);
332+
// numVBOElements_++;
333+
// points_.push_back(r2 * p + Vector(p2));
334+
// colors_.push_back(color2);
335+
// normals_.push_back(n);
336+
// numVBOElements_++;
337+
// indices_.push_back(p1_index);
338+
// indices_.push_back(0 + offset);
339+
// indices_.push_back(2 + offset);
340+
// indices_.push_back(p2_index);
341+
// indices_.push_back(1 + offset);
342+
// indices_.push_back(3 + offset);
316343
}
317344
for (int jj = 0; jj < 6; jj++) indices_.pop_back();
318345
}

src/Graphics/Widgets/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ SET(Graphics_Widgets_SRCS
3030
Widget.cc
3131
BoundingBoxWidget.cc
3232
SphereWidget.cc
33+
CylinderWidget.cc
34+
ConeWidget.cc
3335
)
3436

3537
SET(Graphics_Widgets_HEADERS
3638
Widget.h
3739
BoundingBoxWidget.h
3840
SphereWidget.h
41+
CylinderWidget.h
42+
ConeWidget.h
3943
share.h
4044
)
4145

src/Graphics/Widgets/Widget.cc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ DEALINGS IN THE SOFTWARE.
2929
#include <Graphics/Widgets/Widget.h>
3030
#include <Graphics/Widgets/BoundingBoxWidget.h>
3131
#include <Graphics/Widgets/SphereWidget.h>
32+
#include <Graphics/Widgets/CylinderWidget.h>
33+
#include <Graphics/Widgets/ConeWidget.h>
3234

3335
using namespace SCIRun;
3436
using namespace SCIRun::Core::Geometry;
@@ -54,6 +56,28 @@ WidgetHandle WidgetFactory::createSphere(const Core::GeometryIDGenerator& idGene
5456
return boost::make_shared<SphereWidget>(idGenerator, name, scale, defaultColor, point, bbox);
5557
}
5658

59+
WidgetHandle WidgetFactory::createCylinder(const Core::GeometryIDGenerator& idGenerator,
60+
const std::string& name,
61+
double scale,
62+
const std::string& defaultColor,
63+
const Point& p1,
64+
const Point& p2,
65+
const BBox& bbox)
66+
{
67+
return boost::make_shared<CylinderWidget>(idGenerator, name, scale, defaultColor, p1, p2, bbox);
68+
}
69+
70+
WidgetHandle WidgetFactory::createCone(const Core::GeometryIDGenerator& idGenerator,
71+
const std::string& name,
72+
double scale,
73+
const std::string& defaultColor,
74+
const Point& p1,
75+
const Point& p2,
76+
const BBox& bbox)
77+
{
78+
return boost::make_shared<ConeWidget>(idGenerator, name, scale, defaultColor, p1, p2, bbox);
79+
}
80+
5781
CompositeWidget::~CompositeWidget()
5882
{
5983
}
@@ -65,3 +89,15 @@ void CompositeWidget::addToList(GeometryBaseHandle handle, GeomList& list)
6589
list.insert(widgets_.begin(), widgets_.end());
6690
}
6791
}
92+
93+
LinkedCompositeWidget::~LinkedCompositeWidget()
94+
{
95+
}
96+
97+
void LinkedCompositeWidget::addToList(GeometryBaseHandle handle, GeomList& list)
98+
{
99+
if (handle.get() == this)
100+
{
101+
list.insert(widgets_.begin(), widgets_.end());
102+
}
103+
}

src/Graphics/Widgets/Widget.h

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,53 @@ namespace SCIRun
7171
std::vector<WidgetHandle> widgets_;
7272
};
7373

74-
class SCISHARE WidgetFactory
74+
class SCISHARE LinkedCompositeWidget : public WidgetBase
7575
{
7676
public:
77-
static WidgetHandle createBox(const Core::GeometryIDGenerator& idGenerator, double scale,
78-
const BoxPosition& pos, const Core::Geometry::BBox& bbox);
79-
static WidgetHandle createSphere(const Core::GeometryIDGenerator& idGenerator,
80-
const std::string& name,
81-
double radius, const std::string& defaultColor,
82-
const Core::Geometry::Point& point, const Core::Geometry::BBox& bbox);
8377
template <typename WidgetIter>
78+
LinkedCompositeWidget(const Core::GeometryIDGenerator& idGenerator, const std::string& tag, WidgetIter begin, WidgetIter end)
79+
: WidgetBase(idGenerator, tag, true), widgets_(begin, end)
80+
{}
81+
~LinkedCompositeWidget();
82+
void addToList(Core::Datatypes::GeometryBaseHandle handle, Core::Datatypes::GeomList& list) override;
83+
private:
84+
std::vector<WidgetHandle> widgets_;
85+
};
86+
87+
class SCISHARE WidgetFactory
88+
{
89+
public:
90+
static WidgetHandle createBox(const Core::GeometryIDGenerator& idGenerator, double scale,
91+
const BoxPosition& pos, const Core::Geometry::BBox& bbox);
92+
static WidgetHandle createSphere(const Core::GeometryIDGenerator& idGenerator,
93+
const std::string& name,
94+
double radius, const std::string& defaultColor,
95+
const Core::Geometry::Point& point, const Core::Geometry::BBox& bbox);
96+
static WidgetHandle createCylinder(const Core::GeometryIDGenerator& idGenerator,
97+
const std::string& name,
98+
double scale,
99+
const std::string& defaultColor,
100+
const Core::Geometry::Point& p1,
101+
const Core::Geometry::Point& p2,
102+
const Core::Geometry::BBox& bbox);
103+
static WidgetHandle createCone(const Core::GeometryIDGenerator& idGenerator,
104+
const std::string& name,
105+
double scale,
106+
const std::string& defaultColor,
107+
const Core::Geometry::Point& p1,
108+
const Core::Geometry::Point& p2,
109+
const Core::Geometry::BBox& bbox);
110+
template <typename WidgetIter>
84111
static WidgetHandle createComposite(const Core::GeometryIDGenerator& idGenerator, const std::string& tag, WidgetIter begin, WidgetIter end)
85112
{
86113
return boost::make_shared<CompositeWidget>(idGenerator, tag, begin, end);
87114
}
115+
116+
template <typename WidgetIter>
117+
static WidgetHandle createLinkedComposite(const Core::GeometryIDGenerator& idGenerator, const std::string& tag, WidgetIter begin, WidgetIter end)
118+
{
119+
return boost::make_shared<LinkedCompositeWidget>(idGenerator, tag, begin, end);
120+
}
88121
};
89122
}
90123
}

src/Interface/Modules/Visualization/ShowAndEditDipolesDialog.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929
#include <Interface/Modules/Visualization/ShowAndEditDipolesDialog.h>
30-
#include <Modules/Visualization/ShowAndEditDipoles.h>
30+
#include <Modules/Legacy/Visualization/ShowAndEditDipoles.h>
3131
#include <Dataflow/Network/ModuleStateInterface.h>
3232

3333
using namespace SCIRun::Gui;

src/Modules/Factory/Config/ShowAndEditDipoles.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"namespace": "Visualization",
55
"status": "...",
66
"description": "...",
7-
"header": "Modules/Visualization/ShowAndEditDipoles.h"
7+
"header": "Modules/Legacy/Visualization/ShowAndEditDipoles.h"
88
},
99
"algorithm": {
1010
"name": "N/A",

src/Modules/Legacy/Visualization/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ TARGET_LINK_LIBRARIES(Modules_Legacy_Visualization
8989
#Core_Persistent
9090
#Core_Thread
9191
Core_Util_Legacy
92+
Graphics_Widgets
93+
Graphics_Datatypes
9294
#${SCI_TEEM_LIBRARY}
9395
)
9496

0 commit comments

Comments
 (0)