3232#include < Core/Datatypes/DenseMatrix.h>
3333#include < Graphics/Glyphs/GlyphGeom.h>
3434#include < Core/Datatypes/Color.h>
35+ #include < boost/format.hpp>
3536
3637using namespace SCIRun ;
3738using namespace Modules ::Fields;
@@ -167,17 +168,16 @@ EditMeshBoundingBox::EditMeshBoundingBox()
167168void EditMeshBoundingBox::processWidgetFeedback (const ModuleFeedback& var)
168169{
169170 auto vsf = static_cast <const ViewSceneFeedback&>(var);
170- if (vsf.selectionName .find (get_id ()) != std::string::npos)// && impl_->previousTransform_ != vsf.transform)
171+ if (vsf.selectionName .find (get_id ()) != std::string::npos)
171172 {
172173 impl_->userWidgetTransform_ = vsf.transform ;
173174 enqueueExecuteAgain ();
174175 }
175-
176176}
177177
178178void EditMeshBoundingBox::createBoxWidget ()
179179{
180- box_ = WidgetFactory::createBox (); // new BoxWidget(this, &widget_lock_, 1.0, false, false);
180+ box_ = WidgetFactory::createBox ();
181181 box_->connect (getOutputPort (Transformation_Widget));
182182}
183183
@@ -204,8 +204,8 @@ void EditMeshBoundingBox::setStateDefaults()
204204 state->setValue (XYZTranslation, false );
205205 state->setValue (RDITranslation, false );
206206 state->setValue (Resetting, false );
207-
208- // TODO
207+ state-> setValue (BoxRealScale, 0.0 );
208+ state-> setValue (BoxMode, 0 );
209209
210210 createBoxWidget ();
211211 setBoxRestrictions ();
@@ -242,6 +242,14 @@ void EditMeshBoundingBox::clear_vals()
242242 state->setValue (InputSizeZ, cleared);
243243}
244244
245+ namespace
246+ {
247+ std::string convertForLabel (double coord)
248+ {
249+ return str (boost::format (" %8.4f" ) % coord);
250+ }
251+ }
252+
245253void EditMeshBoundingBox::update_input_attributes (FieldHandle f)
246254{
247255 bbox_ = f->vmesh ()->get_bounding_box ();
@@ -254,11 +262,14 @@ void EditMeshBoundingBox::update_input_attributes(FieldHandle f)
254262 }
255263 auto size = bbox_.diagonal ();
256264 auto center = bbox_.center ();
257- box_->setPosition (center,
258- center + Vector (size.x () / 2 ., 0 , 0 ),
259- center + Vector (0 , size.y () / 2 ., 0 ),
260- center + Vector (0 , 0 , size.z () / 2 .));
261- updateOutputAttributes (bbox_);
265+
266+ auto state = get_state ();
267+ state->setValue (InputCenterX, convertForLabel (center.x ()));
268+ state->setValue (InputCenterY, convertForLabel (center.y ()));
269+ state->setValue (InputCenterZ, convertForLabel (center.z ()));
270+ state->setValue (InputSizeX, convertForLabel (size.x ()));
271+ state->setValue (InputSizeY, convertForLabel (size.y ()));
272+ state->setValue (InputSizeZ, convertForLabel (size.z ()));
262273}
263274
264275void EditMeshBoundingBox::updateOutputAttributes (const BBox& box)
@@ -268,24 +279,23 @@ void EditMeshBoundingBox::updateOutputAttributes(const BBox& box)
268279 auto state = get_state ();
269280 const bool useOutputSize = state->getValue (UseOutputSize).toBool ();
270281 const bool useOutputCenter = state->getValue (UseOutputCenter).toBool ();
271- char s[32 ];
272- sprintf (s, " %8.4f" , center.x ());
273- state->setValue (InputCenterX, boost::lexical_cast<std::string>(s));
282+
283+ state->setValue (OutputCenterX, convertForLabel (center.x ()));
274284 if (!useOutputCenter) state->setValue (OutputCenterX, center.x ());
275- sprintf (s, " %8.4f " , center. y ());
276- state->setValue (InputCenterY, boost::lexical_cast<std::string>(s ));
285+
286+ state->setValue (OutputCenterY, convertForLabel (center. y () ));
277287 if (!useOutputCenter) state->setValue (OutputCenterY, center.y ());
278- sprintf (s, " %8.4f " , center. z ());
279- state->setValue (InputCenterZ, boost::lexical_cast<std::string>(s ));
288+
289+ state->setValue (OutputCenterZ, convertForLabel (center. z () ));
280290 if (!useOutputCenter) state->setValue (OutputCenterZ, center.z ());
281- sprintf (s, " %8.4f " , size. x ());
282- state->setValue (InputSizeX, boost::lexical_cast<std::string>(s ));
291+
292+ state->setValue (OutputSizeX, convertForLabel (size. x () ));
283293 if (!useOutputSize) state->setValue (OutputSizeX, size.x ());
284- sprintf (s, " %8.4f " , size. y ());
285- state->setValue (InputSizeY, boost::lexical_cast<std::string>(s ));
294+
295+ state->setValue (OutputSizeY, convertForLabel (size. y () ));
286296 if (!useOutputSize) state->setValue (OutputSizeY, size.y ());
287- sprintf (s, " %8.4f " , size. z ());
288- state->setValue (InputSizeZ, boost::lexical_cast<std::string>(s ));
297+
298+ state->setValue (OutputSizeZ, convertForLabel (size. z () ));
289299 if (!useOutputSize) state->setValue (OutputSizeZ, size.z ());
290300}
291301
0 commit comments