@@ -166,15 +166,10 @@ EditMeshBoundingBox::EditMeshBoundingBox()
166166
167167void EditMeshBoundingBox::processWidgetFeedback (const ModuleFeedback& var)
168168{
169- static int callCount = 0 ;
170- std::cout << " callback count: " << callCount++ << std::endl;
171169 auto vsf = static_cast <const ViewSceneFeedback&>(var);
172170 if (vsf.selectionName .find (get_id ()) != std::string::npos)// && impl_->previousTransform_ != vsf.transform)
173171 {
174- std::cout << " EditMeshBoundingBox::processWidgetFeedback transform from ViewSceneDialog:" << std::endl;
175- // vsf.transform.print();
176172 impl_->userWidgetTransform_ = vsf.transform ;
177- // adjustPositionFromTransform(vsf.transform);
178173 enqueueExecuteAgain ();
179174 }
180175
@@ -249,9 +244,6 @@ void EditMeshBoundingBox::clear_vals()
249244
250245void EditMeshBoundingBox::update_input_attributes (FieldHandle f)
251246{
252- Point center;
253- Vector size;
254-
255247 bbox_ = f->vmesh ()->get_bounding_box ();
256248
257249 if (!bbox_.valid ())
@@ -260,35 +252,41 @@ void EditMeshBoundingBox::update_input_attributes(FieldHandle f)
260252 bbox_.extend (Point (0 , 0 , 0 ));
261253 bbox_.extend (Point (1 , 1 , 1 ));
262254 }
263- size = bbox_.diagonal ();
264- center = bbox_.center ();
255+ auto size = bbox_.diagonal ();
256+ auto center = bbox_.center ();
265257 box_->setPosition (center,
266258 center + Vector (size.x () / 2 ., 0 , 0 ),
267259 center + Vector (0 , size.y () / 2 ., 0 ),
268260 center + Vector (0 , 0 , size.z () / 2 .));
261+ updateOutputAttributes (bbox_);
262+ }
269263
264+ void EditMeshBoundingBox::updateOutputAttributes (const BBox& box)
265+ {
266+ auto size = box.diagonal ();
267+ auto center = box.center ();
270268 auto state = get_state ();
271269 const bool useOutputSize = state->getValue (UseOutputSize).toBool ();
272270 const bool useOutputCenter = state->getValue (UseOutputCenter).toBool ();
273- char s[32 ];
274- sprintf (s, " %8.4f" ,center.x ());
275- state->setValue (InputCenterX, boost::lexical_cast<std::string>(s));
276- if (!useOutputCenter) state->setValue (OutputCenterX, center.x ());
277- sprintf (s, " %8.4f" ,center.y ());
278- state->setValue (InputCenterY, boost::lexical_cast<std::string>(s));
279- if (!useOutputCenter) state->setValue (OutputCenterY, center.y ());
280- sprintf (s, " %8.4f" ,center.z ());
281- state->setValue (InputCenterZ, boost::lexical_cast<std::string>(s));
282- if (!useOutputCenter) state->setValue (OutputCenterZ, center.z ());
283- sprintf (s, " %8.4f" ,size.x ());
284- state->setValue (InputSizeX, boost::lexical_cast<std::string>(s));
285- if (!useOutputSize) state->setValue (OutputSizeX, size.x ());
286- sprintf (s, " %8.4f" ,size.y ());
287- state->setValue (InputSizeY, boost::lexical_cast<std::string>(s));
288- if (!useOutputSize) state->setValue (OutputSizeY, size.y ());
289- sprintf (s, " %8.4f" ,size.z ());
290- state->setValue (InputSizeZ, boost::lexical_cast<std::string>(s));
291- if (!useOutputSize) state->setValue (OutputSizeZ, size.z ());
271+ char s[32 ];
272+ sprintf (s, " %8.4f" , center.x ());
273+ state->setValue (InputCenterX, boost::lexical_cast<std::string>(s));
274+ if (!useOutputCenter) state->setValue (OutputCenterX, center.x ());
275+ sprintf (s, " %8.4f" , center.y ());
276+ state->setValue (InputCenterY, boost::lexical_cast<std::string>(s));
277+ if (!useOutputCenter) state->setValue (OutputCenterY, center.y ());
278+ sprintf (s, " %8.4f" , center.z ());
279+ state->setValue (InputCenterZ, boost::lexical_cast<std::string>(s));
280+ if (!useOutputCenter) state->setValue (OutputCenterZ, center.z ());
281+ sprintf (s, " %8.4f" , size.x ());
282+ state->setValue (InputSizeX, boost::lexical_cast<std::string>(s));
283+ if (!useOutputSize) state->setValue (OutputSizeX, size.x ());
284+ sprintf (s, " %8.4f" , size.y ());
285+ state->setValue (InputSizeY, boost::lexical_cast<std::string>(s));
286+ if (!useOutputSize) state->setValue (OutputSizeY, size.y ());
287+ sprintf (s, " %8.4f" , size.z ());
288+ state->setValue (InputSizeZ, boost::lexical_cast<std::string>(s));
289+ if (!useOutputSize) state->setValue (OutputSizeZ, size.z ());
292290}
293291
294292bool EditMeshBoundingBox::isBoxEmpty () const
@@ -559,26 +557,25 @@ void EditMeshBoundingBox::executeImpl(FieldHandle fh)
559557 t.pre_trans (r);
560558 t.pre_translate (Vector (center));
561559
562- // std::cout << ">>>3" << std::endl;
563- // impl_->field_initial_transform_.print();
564- Transform inv (impl_->field_initial_transform_ );
560+ auto inv (impl_->field_initial_transform_ );
565561 inv.invert ();
566562 t.post_trans (inv);
567- t.post_trans (impl_->userWidgetTransform_ );
568-
569- impl_->userWidgetTransform_ .project_inplace (center);
570- impl_->userWidgetTransform_ .project_inplace (right);
571- impl_->userWidgetTransform_ .project_inplace (down);
572- impl_->userWidgetTransform_ .project_inplace (in);
573- box_->setPosition (center, right, down, in);
563+ const auto widgetMoved = impl_->userWidgetTransform_ != Transform::Identity ();
564+ if (widgetMoved)
565+ {
566+ t.post_trans (impl_->userWidgetTransform_ );
567+ impl_->userWidgetTransform_ .project_inplace (center);
568+ impl_->userWidgetTransform_ .project_inplace (right);
569+ impl_->userWidgetTransform_ .project_inplace (down);
570+ impl_->userWidgetTransform_ .project_inplace (in);
571+ box_->setPosition (center, right, down, in);
572+ }
574573
575574 // Change the input field handle here.
576575 FieldHandle output (fh->deep_clone ());
577576 output->vmesh ()->transform (t);
578-
579577
580- // std::cout << ">>>4" << std::endl;
581- // output->vmesh()->get_transform().print();
578+ widget_moved (widgetMoved);
582579
583580 sendOutput (OutputField, output);
584581
0 commit comments