MantisBT - Bender
View Issue Details
0013610BenderArmatures modulepublic2012-10-26 17:342013-04-02 14:28
Julien Finet 
johan andruejol 
lowminorsometimes
closedfixed 
 
1.00.1 
0013610: vtkBoneWidget invokes un-necessary Interaction events
For each mouse move (not necessarily when the buttons are down), the bone widget fires InteractionEvent event.
It shouldn't fire InteractionEvent as there is no interaction happening.
It also adds performance issue.
Only tested using the Armature module:
 - Create a bone
 - Move the mouse over the 3D view
-> it invokes InteractionEvents.
It is fired from vtkBoneWidget::MoveAction, in the Rest pose conditional block.
No tags attached.
child of 0013671closed Julien Finet Task 1.1) Develop an application for specifying rigging for a voxelized anatomical model. 
Issue History
2012-10-26 17:34Julien FinetNew Issue
2012-10-26 17:34Julien FinetStatusnew => assigned
2012-10-26 17:34Julien FinetAssigned To => johan andruejol
2012-10-30 17:05johan andruejolNote Added: 0031353
2012-10-30 17:11johan andruejolStatusassigned => resolved
2012-10-30 17:11johan andruejolResolutionopen => fixed
2012-11-01 11:12Julien FinetNote Added: 0031368
2012-11-01 11:12Julien FinetStatusresolved => assigned
2012-11-01 15:53johan andruejolNote Added: 0031375
2012-11-01 15:54johan andruejolStatusassigned => resolved
2012-11-01 16:55Julien FinetNote Added: 0031377
2012-11-01 16:55Julien FinetStatusresolved => assigned
2012-11-09 13:37Julien FinetRelationship addedchild of 0013671
2012-11-09 15:49Julien FinetPriorityhigh => low
2012-11-25 10:53Julien FinetNote Added: 0031702
2012-11-28 13:44johan andruejolNote Added: 0031747
2012-11-30 20:12Julien FinetNote Added: 0031792
2012-12-06 08:33johan andruejolStatusassigned => resolved
2013-01-17 17:53Julien FinetFixed in Version => 0.1
2013-02-14 14:38Julien FinetStatusresolved => closed
2013-02-14 14:44Julien FinetCategoryvtkBoneWidgets => Armatures module
2013-04-02 14:28Julien FinetTarget Version => 1.0

Notes
(0031353)
johan andruejol   
2012-10-30 17:05   
Fixed in a squashed commit, see: https://github.com/vovythevov/Bender/commit/4514ec4b38495de335763a5b01d6e9864caf8d51 [^]
(0031368)
Julien Finet   
2012-11-01 11:12   
Issue is fixed, InteractionEvent is not fired anytime the mouse is moved.
However, StartInteractionEvent/EndInteractionEvent are fired only when the head and tail are clicked, not when the line is clicked. This can lead to problems in the future.

Side note: The name "vtkBoneWidget::AddPointAction" doesn't fit the behavior of the function.
(0031375)
johan andruejol   
2012-11-01 15:53   
See https://github.com/vovythevov/Bender/commit/f1ce8ebd31ff0da0e4ab74a96152aed5150b2bef [^]
(0031377)
Julien Finet   
2012-11-01 16:55   
I believe vtkBoneWidget::StartSelectAction can be factorized a bit more:
There is code duplication in the following:
    if (state == vtkBoneRepresentation::OnHead)
      {
      self->SetWidgetSelectedState(vtkBoneWidget::HeadSelected);
      self->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
      }
    else if (state == vtkBoneRepresentation::OnTail)
      {
      self->SetWidgetSelectedState(vtkBoneWidget::TailSelected);
      self->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
      }
    else if (state == vtkBoneRepresentation::OnLine)
      {
      if (self->WidgetState == vtkBoneWidget::Rest)
        {
        self->SetWidgetSelectedState(vtkBoneWidget::LineSelected);
        self->WidgetRep->StartWidgetInteraction(e);
        self->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
        }

      self->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);
      }
Maybe self->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL); can be called within SetWidgetSelectedState.

And wouldn't it be cool if vtkBoneRepresentation::OnHead, vtkBoneRepresentation::OnTail, vtkBoneRepresentation::OnLine and vtkBoneRepresentation::Outside were the same than vtkBoneWidget::HeadSelected, vtkBoneWidget::TailSelected, vtkBoneWidget::LineSelected and vtkBoneWidget::NoneSelected? It would make the code in vtkBoneWidget::StartSelectAction() be more like that:
 ...
 int modifier =
   self->Interactor->GetShiftKey() | self->Interactor->GetControlKey();
 int state = self->WidgetRep->ComputeInteractionState(X,Y,modifier);
 self->SetWidgetSelectedState(state);
 ...
//(be careful with the abort flag).
...

and

vtkBoneWidget::SetWidgetSelectedState(int selectionState)
{
  ...
  this->BoneSelected = selectionState;
  this->GetBoneRepresentation(selectionState)->Highlight(selectionState != NoSelected);
  if (selectionState == NoSelected)
    {
    return;
    }
  self->GrabFocus(self->EventCallbackCommand);
  // Explain here why it is different than for head and tail
  // and why we don't do it in Pose state
  if (selectionState == Line && widgetState == Rest)
    {
    self->WidgetRep->StartWidgetInteraction(e);
    }
  this->InvokeEvent(LeftButtonPressEvent);
  // Make sure that the order of the calls (LeftButtonPressEvent, StartInteractionEvent) is the
  // same between Head selected, Tail selected and Line selected.
  if (selectionState == Line)
    {
    self->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);
    }
}
(0031702)
Julien Finet   
2012-11-25 10:53   
Some cleanup work has happened in 13610-cleanup-bone-widget-interaction:
https://github.com/finetjul/bender/commits/13610-cleanup-bone-widget-interaction [^]

Note that it can't be merged as-is. The duplication of invocation of StartInteractionEvent/EndInteractionEvent should be fixed before.
(by getting rid of vtkBoneWidgetCallback ?)

Btw, this->HeadWidgetCallback and this->TailWidgetCallback are doing the same, only 1 can be used on both widgets.
(0031747)
johan andruejol   
2012-11-28 13:44   
https://github.com/vovythevov/Bender/commit/c3fbd1a3153529f4c6402afc0ff996ef4ff6d2c5 [^]
(0031792)
Julien Finet   
2012-11-30 20:12   
13610-cleanup-bone-widget-interaction now contains the most up-to-date code:
https://github.com/finetjul/bender/commits/13610-cleanup-bone-widget-interaction [^]

Johan, can you please try the topic on your machine and let me know if there is some problems with it ? Thanks