Skip to content

Commit c38dced

Browse files
author
tpat
committed
Arrow widgets functioning. Updated to new arrow widget class
1 parent 3cdc6f0 commit c38dced

File tree

14 files changed

+285
-318
lines changed

14 files changed

+285
-318
lines changed

src/Core/GeometryPrimitives/Transform.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ Transform::operator=(const Transform& copy)
840840
}
841841

842842
Point
843-
SCIRun::Core::Geometry::operator*(Transform &t, const Point &d)
843+
SCIRun::Core::Geometry::operator*(const Transform &t, const Point &d)
844844
{
845845
double result[4], tmp[4];
846846
result[0] = result[1] = result[2] = result[3] = 0;
@@ -864,7 +864,7 @@ SCIRun::Core::Geometry::operator*(Transform &t, const Point &d)
864864
}
865865

866866
Vector
867-
SCIRun::Core::Geometry::operator*(Transform &t, const Vector &d)
867+
SCIRun::Core::Geometry::operator*(const Transform &t, const Vector &d)
868868
{
869869
double result[4], tmp[4];
870870
result[0] = result[1] = result[2] = result[3] = 0;

src/Core/GeometryPrimitives/Transform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ namespace SCIRun {
149149
virtual void io(Piostream &stream);
150150
};
151151

152-
SCISHARE Point operator*(Transform &t, const Point &d);
153-
SCISHARE Vector operator*(Transform &t, const Vector &d);
152+
SCISHARE Point operator*(const Transform &t, const Point &d);
153+
SCISHARE Vector operator*(const Transform &t, const Vector &d);
154154

155155
SCISHARE Tensor operator*(const Transform &t, const Tensor &d);
156156
SCISHARE Tensor operator*(const Tensor &d, const Transform &t);

src/Graphics/Widgets/ArrowWidget.cc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
#include <Graphics/Widgets/ArrowWidget.h>
30-
#include <Graphics/Glyphs/GlyphGeom.h>
3129
#include <Core/Datatypes/Color.h>
30+
#include <Graphics/Glyphs/GlyphGeom.h>
31+
#include <Graphics/Widgets/ArrowWidget.h>
32+
#include <Graphics/Widgets/WidgetFactory.h>
3233

3334
using namespace SCIRun;
3435
using namespace SCIRun::Core;
@@ -41,14 +42,11 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
4142
const Point &pos, const Vector &dir, int resolution,
4243
bool show_as_vector, size_t widget_num, size_t widget_iter,
4344
const BBox &bbox)
44-
: WidgetBase(idGenerator, "SphereWidget::" + name, true, pos, pos)
45-
// : CompositeWidget(idGenerator, name) {
46-
/**
45+
: CompositeWidget(idGenerator, name) {
4746
static const ColorRGB deflPointCol_ = ColorRGB(0.54, 0.6, 1.0);
4847
static const ColorRGB deflCol_ = ColorRGB(0.5, 0.5, 0.5);
49-
static const ColorRGB greenCol_ = ColorRGB(0.2, 0.8, 0.2);
5048
static const ColorRGB resizeCol_ = ColorRGB(0.54, 1.0, 0.60);
51-
static const ColorRGB lineCol_ = ColorRGB(0.8, 0.8, 0.2);
49+
ColorRGB sphereCol = (show_as_vector) ? deflPointCol_ : resizeCol_;
5250

5351
static const double sphereRadius_ = 0.25;
5452
static const double cylinderRadius_ = 0.12;
@@ -59,6 +57,7 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
5957

6058
if (resolution < 3) resolution = 10;
6159

60+
isVector_ = show_as_vector;
6261
auto colorScheme = ColorScheme::COLOR_UNIFORM;
6362
std::stringstream ss;
6463
ss << pos << dir << static_cast<int>(colorScheme);
@@ -93,11 +92,8 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
9392

9493
Point center = bmin + dir/2.0 * scale;
9594

96-
ColorRGB sphereCol = (show_as_vector) ? deflPointCol_ : resizeCol_;
97-
std::vector<WidgetHandle> widget_handles;
98-
9995
// Create glyphs
100-
widget_handles.emplace_back(WidgetFactory::createSphere(
96+
widgets_.push_back(WidgetFactory::createSphere(
10197
idGenerator,
10298
widgetName(ArrowWidgetSection::SPHERE, widget_num, widget_iter),
10399
sphereRadius_ * scale,
@@ -106,14 +102,14 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
106102
bmin,
107103
bbox,
108104
resolution));
109-
widget_handles[0]->setToTranslate();
105+
widgets_[0]->setToTranslate();
110106

111107
if(show_as_vector)
112108
{
113109
// Starts the cylinder position closer to the surface of the sphere
114110
Point cylinderStart = bmin + 0.75 * (dir * scale * sphereRadius_);
115111

116-
widget_handles.emplace_back(WidgetFactory::createCylinder(
112+
widgets_.push_back(WidgetFactory::createCylinder(
117113
idGenerator,
118114
widgetName(ArrowWidgetSection::CYLINDER, widget_num, widget_iter),
119115
cylinderRadius_ * scale,
@@ -123,9 +119,9 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
123119
bmin,
124120
bbox,
125121
resolution));
126-
widget_handles[1]->setToTranslate();
122+
widgets_[1]->setToTranslate();
127123

128-
widget_handles.emplace_back(WidgetFactory::createCone(
124+
widgets_.push_back(WidgetFactory::createCone(
129125
idGenerator,
130126
widgetName(ArrowWidgetSection::CONE, widget_num, widget_iter),
131127
coneRadius_ * scale,
@@ -136,12 +132,12 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
136132
bbox,
137133
true,
138134
resolution));
139-
widget_handles[2]->setToRotate();
135+
widgets_[2]->setToRotate();
140136

141137
Point diskPos = bmin + dir * scale * diskDistFromCenter_;
142138
Point dp1 = diskPos - diskWidth_ * dir * scale;
143139
Point dp2 = diskPos + diskWidth_ * dir * scale;
144-
widget_handles.emplace_back(WidgetFactory::createDisk(
140+
widgets_.push_back(WidgetFactory::createDisk(
145141
idGenerator,
146142
widgetName(ArrowWidgetSection::DISK, widget_num, widget_iter),
147143
diskRadius_ * scale,
@@ -152,19 +148,23 @@ ArrowWidget::ArrowWidget(const GeometryIDGenerator &idGenerator,
152148
bbox,
153149
resolution));
154150
Vector flipVec = dir.getArbitraryTangent().normal();
155-
widget_handles[3]->setToScale(flipVec);
151+
widgets_[3]->setToScale(flipVec);
156152
}
157153

158154
std::vector<std::string> geom_ids;
159155
for(int i = 0; i < 1 + 3*show_as_vector; i++)
160-
geom_ids.push_back(widget_handles[i]->uniqueID());
156+
geom_ids.push_back(widgets_[i]->uniqueID());
161157

162158
for(int i = 0; i < 1 + 3*show_as_vector; i++)
163159
{
164-
widget_handles[i]->connectedIds_ = geom_ids;
165-
addToList(widget_handles[i]);
160+
widgets_[i]->connectedIds_ = geom_ids;
161+
addToList(widgets_[i]);
166162
}
167-
**/
163+
}
164+
165+
bool ArrowWidget::isVector()
166+
{
167+
return isVector_;
168168
}
169169

170170
std::string ArrowWidget::widgetName(size_t i, size_t id, size_t iter)

src/Graphics/Widgets/ArrowWidget.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace SCIRun {
3939
namespace Datatypes {
4040
enum ArrowWidgetSection { SPHERE, CYLINDER, CONE, DISK };
4141

42-
class SCISHARE ArrowWidget : public WidgetBase
42+
class SCISHARE ArrowWidget : public CompositeWidget
4343
{
4444
public:
4545
ArrowWidget(const Core::GeometryIDGenerator &idGenerator,
@@ -49,11 +49,14 @@ namespace SCIRun {
4949
bool show_as_vector, size_t widget_num, size_t widget_iter,
5050
const Core::Geometry::BBox &bbox);
5151

52+
bool isVector();
53+
5254
private:
55+
bool isVector_;
5356
std::string widgetName(size_t i, size_t id, size_t iter);
5457
};
5558

56-
/* using ArrowWidgetHandle = SharedPointer<ArrowWidget>; */
59+
using ArrowWidgetHandle = SharedPointer<ArrowWidget>;
5760
}
5861
}
5962
}

src/Graphics/Widgets/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@
2828

2929
SET(Graphics_Widgets_SRCS
3030
Widget.cc
31+
WidgetFactory.cc
3132
BoundingBoxWidget.cc
3233
SphereWidget.cc
3334
CylinderWidget.cc
3435
ConeWidget.cc
3536
DiskWidget.cc
37+
ArrowWidget.cc
3638
)
3739

3840
SET(Graphics_Widgets_HEADERS
3941
Widget.h
42+
WidgetFactory.h
4043
BoundingBoxWidget.h
4144
SphereWidget.h
4245
CylinderWidget.h
4346
ConeWidget.h
47+
ArrowWidget.h
4448
share.h
4549
)
4650

src/Graphics/Widgets/Widget.cc

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2525
DEALINGS IN THE SOFTWARE.
2626
*/
2727

28-
#include <Graphics/Widgets/ArrowWidget.h>
29-
#include <Graphics/Widgets/BoundingBoxWidget.h>
30-
#include <Graphics/Widgets/ConeWidget.h>
31-
#include <Graphics/Widgets/CylinderWidget.h>
32-
#include <Graphics/Widgets/DiskWidget.h>
33-
#include <Graphics/Widgets/SphereWidget.h>
3428
#include <Graphics/Widgets/Widget.h>
29+
#include <Graphics/Widgets/share.h>
3530

3631
using namespace SCIRun;
3732
using namespace SCIRun::Core::Geometry;
@@ -92,110 +87,6 @@ WidgetMovement WidgetBase::getMovementType()
9287
return movementType_;
9388
}
9489

95-
CompositeWidgetHandle WidgetFactory::createArrowWidget(const Core::GeometryIDGenerator &idGenerator,
96-
const std::string& name,
97-
double scale,
98-
const Point &pos,
99-
const Vector &dir,
100-
int resolution,
101-
bool show_as_vector,
102-
int widget_num,
103-
int widget_iter,
104-
const BBox &bbox)
105-
{
106-
// ArrowWidget wid();
107-
// ArrowWidgetHandle widget = boost::make_shared);
108-
// return boost::make_shared<ArrowWidget>(idGenerator, name, scale, pos, dir,
109-
// resolution, show_as_vector,
110-
// widget_num, widget_iter, bbox);
111-
}
112-
113-
WidgetHandle WidgetFactory::createBox(const Core::GeometryIDGenerator& idGenerator,
114-
double scale,
115-
const BoxPosition& pos,
116-
const Point& origin,
117-
const BBox& bbox)
118-
{
119-
WidgetHandle widget = boost::make_shared<BoundingBoxWidget>(idGenerator, scale, pos, origin, bbox);
120-
std::vector<std::string> ids = std::vector<std::string>(1);
121-
ids.push_back(widget->uniqueID());
122-
widget->connectedIds_ = ids;
123-
widget->setToTranslate();
124-
return widget;
125-
}
126-
127-
WidgetHandle WidgetFactory::createSphere(const Core::GeometryIDGenerator& idGenerator,
128-
const std::string& name,
129-
double radius,
130-
const std::string& defaultColor,
131-
const Point& point,
132-
const Core::Geometry::Point& origin,
133-
const BBox& bbox,
134-
int resolution)
135-
{
136-
WidgetHandle widget = boost::make_shared<SphereWidget>(idGenerator, name, radius, defaultColor, point, origin, bbox, resolution);
137-
std::vector<std::string> ids = std::vector<std::string>(1);
138-
ids.push_back(widget->uniqueID());
139-
widget->connectedIds_ = ids;
140-
widget->setToTranslate();
141-
return widget;
142-
}
143-
144-
WidgetHandle WidgetFactory::createCylinder(const Core::GeometryIDGenerator& idGenerator,
145-
const std::string& name,
146-
double radius,
147-
const std::string& defaultColor,
148-
const Point& p1,
149-
const Point& p2,
150-
const Core::Geometry::Point& origin,
151-
const BBox& bbox,
152-
int resolution)
153-
{
154-
WidgetHandle widget = boost::make_shared<CylinderWidget>(idGenerator, name, radius, defaultColor, p1, p2, origin, bbox, resolution);
155-
std::vector<std::string> ids = std::vector<std::string>(1);
156-
ids.push_back(widget->uniqueID());
157-
widget->connectedIds_ = ids;
158-
widget->setToTranslate();
159-
return widget;
160-
}
161-
162-
WidgetHandle WidgetFactory::createCone(const Core::GeometryIDGenerator& idGenerator,
163-
const std::string& name,
164-
double radius,
165-
const std::string& defaultColor,
166-
const Point& p1,
167-
const Point& p2,
168-
const Core::Geometry::Point& origin,
169-
const BBox& bbox,
170-
bool renderBase,
171-
int resolution)
172-
{
173-
WidgetHandle widget = boost::make_shared<ConeWidget>(idGenerator, name, radius, defaultColor, p1, p2, origin, bbox, renderBase, resolution);
174-
std::vector<std::string> ids = std::vector<std::string>(1);
175-
ids.push_back(widget->uniqueID());
176-
widget->connectedIds_ = ids;
177-
widget->setToTranslate();
178-
return widget;
179-
}
180-
181-
WidgetHandle WidgetFactory::createDisk(const Core::GeometryIDGenerator& idGenerator,
182-
const std::string& name,
183-
double radius,
184-
const std::string& defaultColor,
185-
const Point& p1,
186-
const Point& p2,
187-
const Core::Geometry::Point& origin,
188-
const BBox& bbox,
189-
int resolution)
190-
{
191-
WidgetHandle widget = boost::make_shared<DiskWidget>(idGenerator, name, radius, defaultColor, p1, p2, origin, bbox, resolution);
192-
std::vector<std::string> ids = std::vector<std::string>(1);
193-
ids.push_back(widget->uniqueID());
194-
widget->connectedIds_ = ids;
195-
widget->setToTranslate();
196-
return widget;
197-
}
198-
19990
void CompositeWidget::addToList(GeometryBaseHandle handle, GeomList& list)
20091
{
20192
if (handle.get() == this)

0 commit comments

Comments
 (0)