void mitk::RigidRegistrationObserver::Execute(itk::Object *caller, const itk::EventObject & event)
{
  if (typeid(event) == typeid(itk::IterationEvent))
  {
    OptimizerPointer optimizer = dynamic_cast<OptimizerPointer>(caller);

    if (optimizer != nullptr)
    {
      this->HandleOptimizationIterationEvent(optimizer);

      InvokeEvent( itk::ModifiedEvent() );
    }

  }
  else if (typeid(event) == typeid(itk::FunctionEvaluationIterationEvent))
  {
    OptimizerPointer optimizer = dynamic_cast<OptimizerPointer>(caller);
    itk::AmoebaOptimizer* AmoebaOptimizer = dynamic_cast<itk::AmoebaOptimizer*>(optimizer);
    if (AmoebaOptimizer != nullptr)
    {
      m_OptimizerValue = AmoebaOptimizer->GetCachedValue();
      MITK_INFO << AmoebaOptimizer->GetCachedValue() << "   "
               << AmoebaOptimizer->GetCachedCurrentPosition() << std::endl;
      m_Params = AmoebaOptimizer->GetCachedCurrentPosition();
      if(m_StopOptimization)
      {
        //AmoebaOptimizer->StopOptimization();
        m_StopOptimization = false;
      }
      InvokeEvent(itk::ModifiedEvent());
    }
  }
  mitk::ProgressBar::GetInstance()->AddStepsToDo(1);
  mitk::ProgressBar::GetInstance()->Progress();
}
Пример #2
0
void mitk::LimitedLinearUndo::Clear()
{
  this->ClearList(&m_UndoList);
  InvokeEvent( UndoEmptyEvent() );

  this->ClearList(&m_RedoList);
  InvokeEvent( RedoEmptyEvent() );
}
Пример #3
0
void OverlayImageData::Graft(itkImageType::Pointer dataObject)
{
	m_itkImage->Graft(dataObject);

	updateVTKImage();
	InvokeEvent(vtkCommand::UpdateDataEvent, nullptr);
}
void TBInlineSelect::SetValueInternal(double value, bool update_text)
{
    value = CLAMP(value, m_min, m_max);
    if (value == m_value)
        return;
    m_value = value;

    if (update_text)
    {
        TBStr strval;

        double prec = m_value - floor(m_value);
        if (prec < .001)
        {
            strval.SetFormatted("%.0f", m_value);
        }
        else
            strval.SetFormatted("%.2f", m_value);


        m_editfield.SetText(strval);
    }

    TBWidgetEvent ev(EVENT_TYPE_CHANGED);
    InvokeEvent(ev);

    // Warning: Do nothing here since the event might have deleted us.
    //          If needed, check if we are alive using a safe pointer first.
}
Пример #5
0
bool mitk::LimitedLinearUndo::SetOperationEvent(UndoStackItem* stackItem)
{
  OperationEvent* operationEvent = dynamic_cast<OperationEvent*>(stackItem);
  if (!operationEvent) return false;

  // clear the redolist, if a new operation is saved
  if (!m_RedoList.empty())
  {
    this->ClearList(&m_RedoList);
    InvokeEvent( RedoEmptyEvent() );
  }

  m_UndoList.push_back(operationEvent);

  InvokeEvent( UndoNotEmptyEvent() );

  return true;
}
Пример #6
0
void TBEditField::OnChange()
{
	// Invalidate the layout when the content change and we should adapt our size to it
	if (m_adapt_to_content_size)
		InvalidateLayout(INVALIDATE_LAYOUT_RECURSIVE);

	TBWidgetEvent ev(EVENT_TYPE_CHANGED);
	InvokeEvent(ev);
}
Пример #7
0
    // Updates the FMOD Studio system.
    void Update()
    {
      // Invoke the AudioUpdate event to allow
      //  EventInstance objects to update.
      EventData eventData;
      eventData["Audio"] = this;
      InvokeEvent("AudioUpdate", eventData);

      // Update the FMOD Studio system.
      FmodCall(system->update());
    }
Пример #8
0
void TBSlider::SetValueDouble(double value)
{
	value = CLAMP(value, m_min, m_max);
	if (value == m_value)
		return;
	m_value = value;

	UpdateHandle();
	TBWidgetEvent ev(EVENT_TYPE_CHANGED);
	InvokeEvent(ev);
}
Пример #9
0
    ~Audio()
    {
      // Invoke the AudioShutdown event. This lets the EventListener objects
      //  release so that they don't try to release after the FMOD Studio
      //  system is released below.
      EventData eventData;
      eventData["Audio"] = this;
      InvokeEvent("AudioShutdown", eventData);

      // Destroy the FMOD Studio system.
      FmodCall(system->release());
    }
Пример #10
0
void OverlayImageData::DeepCopy(vtkDataObject * dataObject)
{

	OverlayImageData* overlayImageData = OverlayImageData::SafeDownCast(dataObject);
	vtkImageData *imageData = vtkImageData::SafeDownCast(dataObject);
	if (imageData)
	{
		vtkImageData::DeepCopy(imageData);
		updateITKImage();
		InvokeEvent(vtkCommand::UpdateDataEvent, nullptr);
	}
}
Пример #11
0
LRESULT CCoFAViewer::FireEventSessionStarted(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY_CATCH
	
	Log.Add(_MESSAGE_,_T("CCoFAViewer::FireEventSessionStarted()"));

	TRACENAME
	
	InvokeEvent(1 /*NotifySessionStart*/); //	The same as call NotifySessionStart() but it's more safe
	m_commandManager->InitRemoteSide(m_stream);

CATCH_LOG()
	return 0;
}
Пример #12
0
void TBSelectDropdown::SetValue(int value)
{
    if (value == m_value || !m_source)
        return;
    m_value = value;

    if (m_value < 0)
        SetText("");
    else if (m_value < m_source->GetNumItems())
        SetText(m_source->GetItemString(m_value));

    TBWidgetEvent ev(EVENT_TYPE_CHANGED);
    InvokeEvent(ev);
}
Пример #13
0
void TBRadioCheckBox::SetValue(int value)
{
	if (m_value == value)
		return;
	m_value = value;

	SetState(WIDGET_STATE_SELECTED, value ? true : false);

	TBWidgetEvent ev(EVENT_TYPE_CHANGED);
	InvokeEvent(ev);

	if (value && GetGroupID())
		UpdateGroupWidgets(this);
}
Пример #14
0
bool mitk::LimitedLinearUndo::Redo(int oeid)
{
  if (m_RedoList.empty()) return false;

  do
  {
    m_RedoList.back()->ReverseAndExecute();

    m_UndoList.push_back(m_RedoList.back());
    m_RedoList.pop_back();
    InvokeEvent( UndoNotEmptyEvent() );

    if (m_RedoList.empty())
    {
      InvokeEvent( RedoEmptyEvent() );
      break;
    }
  }
  while ( m_RedoList.back()->GetObjectEventId() <= oeid );

  //Update. This should belong into the ExecuteOperation() of OperationActors, but it seems not to be used everywhere
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  return true;
}
Пример #15
0
bool mitk::LimitedLinearUndo::Undo(int oeid)
{
  if(m_UndoList.empty()) return false;

  do
  {
    m_UndoList.back()->ReverseAndExecute();

    m_RedoList.push_back(m_UndoList.back());  // move to redo stack
    m_UndoList.pop_back();
    InvokeEvent( RedoNotEmptyEvent() );

    if (m_UndoList.empty())
    {
      InvokeEvent( UndoEmptyEvent() );
      return false;
    }
  }
  while ( m_UndoList.back()->GetObjectEventId() >= oeid );

  //Update. Check Rendering Mechanism where to request updates
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  return true;
}
Пример #16
0
void TBSelectList::SetValue(int value)
{
    if (value == m_value)
        return;

    SelectItem(m_value, false);
    m_value = value;
    SelectItem(m_value, true);
    ScrollToSelectedItem();

    TBWidgetEvent ev(EVENT_TYPE_CHANGED);
    if (TBWidget *widget = GetItemWidget(m_value))
        ev.ref_id = widget->GetID();
    InvokeEvent(ev);
}
Пример #17
0
void TBButton::SetValue(int value)
{
	if (value == GetValue())
		return;
	SetState(WIDGET_STATE_PRESSED, value ? true : false);

	if (CanToggle())
	{
		// Invoke a changed event.
		TBWidgetEvent ev(EVENT_TYPE_CHANGED);
		InvokeEvent(ev);
	}

	if (value && GetGroupID())
		TBRadioCheckBox::UpdateGroupWidgets(this);
}
Пример #18
0
LRESULT CCoFAViewer::FireEventSessionStopped(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY_CATCH

	Log.Add(_MESSAGE_,_T("CCoFAViewer::FireEventSessionStopped()"));

	TRACENAME

	InvokeEvent(2 /*NotifySessionStop*/, static_cast<int>(wParam)); // The same as call NotifySessionStop(wParam) but it's more safe

	m_commandManager->OnRemoteSideDisconnected(static_cast<ESessionStopReason>(wParam));
	m_stream.reset();

	tstring what;
	switch(static_cast<ESessionStopReason>(wParam))	//wParam ? lParam
    {
		case LOCAL_STOP:
			what = _T("LOCAL_STOP");
			break;
        case REMOTE_STOP:
			what = _T("REMOTE_STOP");
			break;
		case STREAM_ERROR:
			what = _T("STREAM_ERROR");
			break;
        case PROTOCOL_ERROR:
 			what = _T("PROTOCOL_ERROR");
			break;
        case CHANGE_DISPLAY_MODE:
			what = _T("CHANGE_DISPLAY_MODE");
			break;
        case CONNECTING_ERROR:
 			what = _T("CONNECTING_ERROR");
			break;
        case OPENFILE_ERROR:
			what = _T("OPENFILE_ERROR");
            break;

       default:
            throw MCException(Format("Unknown reason %d",wParam));
    }
	Log.Add(_MESSAGE_, "Session was stopped: %s", what.c_str());

CATCH_LOG()
	bHandled = TRUE;
	return 0;
}
Пример #19
0
bool TBMenuWindow::OnEvent(const TBWidgetEvent &ev)
{
	if (ev.type == EVENT_TYPE_CLICK && &m_select_list == ev.target)
	{
		TBWidgetSafePointer this_widget(this);

		// Invoke the click on the target
		TBWidgetEvent target_ev(EVENT_TYPE_CLICK);
		target_ev.ref_id = ev.ref_id;
		InvokeEvent(target_ev);

		// If target got deleted, close
		if (this_widget.Get())
			Close();
		return true;
	}
	return TBPopupWindow::OnEvent(ev);
}
Пример #20
0
void OverlayImageData::ShallowCopy(vtkDataObject * dataObject)
{
	OverlayImageData* overlayImageData = OverlayImageData::SafeDownCast(dataObject);
	vtkImageData *imageData = vtkImageData::SafeDownCast(dataObject);

	if (imageData)
	{
		vtkImageData::ShallowCopy(imageData);
		if (overlayImageData) {
			m_itkImage->Graft(overlayImageData->GetItkImage());
		}
		else {
			updateITKImage();
		}
		InvokeEvent(vtkCommand::UpdateDataEvent, nullptr);
	}

}
Пример #21
0
bool InputManager::InvokeActions(Context* context, wxEvent* e, wxWindow* win)
{
    wxEventType eventType(e->GetEventType);

    EventTypeIter i = actions.find(eventType);
    if (i == actions.end()) return;

    ActionMap* actionMap = i->second;

    ActionMapIter j = actionMap->find(context);
    if (j == actionMap.end()) return;

    ActionSet* actionSet = j->second;

    wxString actionname;
    if (actionSet->matchesEvent(e, win, &actionname))
        return InvokeEvent(actionname, win);
    else
        return false;
}
void TBTabContainer::SetValue(int index)
{
    if (index == m_current_page || !GetNumPages())
		return;

	m_current_page = index;

	// Update the pages visibility and tabs pressed value.
	index = 0;
	TBWidget *page = m_content_root.GetFirstChild();
	TBWidget *tab = m_tab_layout.GetFirstChild();
	for (   ; page && tab; page = page->GetNext(), tab = tab->GetNext(), index++)
	{
		bool active = index == m_current_page;
		page->SetVisibilility(active ? WIDGET_VISIBILITY_VISIBLE : WIDGET_VISIBILITY_INVISIBLE);
		tab->SetValue(active ? 1 : 0);
	}

    TBWidgetEvent ev(EVENT_TYPE_TAB_CHANGED);
    InvokeEvent(ev);
}
Пример #23
0
bool TBButton::OnEvent(const TBWidgetEvent &ev)
{
	if (m_toggle_mode && ev.type == EVENT_TYPE_CLICK && ev.target == this)
	{
		TBWidgetSafePointer this_widget(this);
		SetValue(!GetValue());

		if (!this_widget.Get())
			return true; // We got removed so we actually handled this event.

		// Invoke a changed event.
		TBWidgetEvent ev(EVENT_TYPE_CHANGED);
		InvokeEvent(ev);

		if (!this_widget.Get())
			return true; // We got removed so we actually handled this event.

		// Intentionally don't return true for this event. We want it to continue propagating.
	}
	return TBWidget::OnEvent(ev);
}
Пример #24
0
bool TBMessageWindow::OnEvent(const TBWidgetEvent &ev)
{
	if (ev.type == EVENT_TYPE_CLICK && ev.target->IsOfType<TBButton>())
	{
		TBWidgetSafePointer this_widget(this);

		// Invoke the click on the target
		TBWidgetEvent target_ev(EVENT_TYPE_CLICK);
		target_ev.ref_id = ev.target->GetID();
		InvokeEvent(target_ev);

		// If target got deleted, close
		if (this_widget.Get())
			Close();
		return true;
	}
	else if (ev.type == EVENT_TYPE_KEY_DOWN && ev.special_key == TB_KEY_ESC)
	{
		TBWidgetEvent click_ev(EVENT_TYPE_CLICK);
		m_close_button.InvokeEvent(click_ev);
		return true;
	}
	return TBWindow::OnEvent(ev);
}
Пример #25
0
void TBRadioCheckBox::SetValue(int value)
{
	if (m_value == value)
		return;
	m_value = value;

	SetState(WIDGET_STATE_SELECTED, value ? true : false);

	Invalidate();
	TBWidgetEvent ev(EVENT_TYPE_CHANGED);
	InvokeEvent(ev);

	if (!value || !GetGroupID())
		return;
	// Toggle all other widgets in the same group. First get a root widget
	// for the search.
	TBWidget *group = this;
	while (group && !group->GetIsGroupRoot())
		group = group->GetParent();
	if (group)
	{
		ToggleGroup(group, this);
	}
}
Пример #26
0
void NonBlockingAlgorithm::ThreadedUpdateSuccessful()
{
  // notify observers that a result is ready
  InvokeEvent( ResultAvailable(this) );
}
Пример #27
0
void NonBlockingAlgorithm::ThreadedUpdateFailed()
{
  // notify observers that something went wrong
  InvokeEvent( ProcessingError(this) );
}
Пример #28
0
void vtkInteractorStyleQuench::OnMouseMove()
{
  _mouse_moved = true;
	vtkRenderWindowInteractor *rwi = this->Interactor;
	int x = rwi->GetEventPosition()[0];
	int y = rwi->GetEventPosition()[1];
	int dx = rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0];
	int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
	this->FindPokedRenderer(x,y);

	//If we are still drawing a gesture, continue doing so
	if(_interaction_mode == INTERACTION_DRAW_GESTURE)
	{	  
		_GestureInteractor->AddPoint(x,y);
		//NotifyAllListeners(PEvent ( new EventRefreshViz(true) ) );
		//CurrentRenderer->GetRenderWindow()->Render();
		return;
	}

	if (_interaction_mode == INTERACTION_PATHWAYS)
	  {
	    _pathwayViz->OnMouseMove(x, abs(y));
	  }
	  /*	if(_left_button_down && _pathwayViz->OnMouseMove(x,abs(y))) {
	  cerr << "mode selector moved." << endl;
		return; //Mode selector panel moved
		}*/

	if (_interaction_mode == INTERACTION_ROI_EDIT)
	  {
	    _voiEditor->OnMouseMove(x,abs(y));
	  }

	/*	if(_editing_voi && (_left_button_down || _right_button_down) && _voiEditor->OnMouseMove(x,abs(y)))
		return; //ROI editing in process.
	*/
	else {
	  switch (this->State)  
	    {
	    case VTKIS_ROTATE:
	      Rotate();
	      InvokeEvent(vtkCommand::InteractionEvent, NULL);
	      break;
	    case VTKIS_PAN:
	      Pan();
	      InvokeEvent(vtkCommand::InteractionEvent, NULL);
	      break;
	    case VTKIS_DOLLY:
	      {
		double *center = CurrentRenderer->GetCenter();
		double dyf = MotionFactor * (double)(dy) / (double)(center[1]);
		double scale = pow((double)1.1, dyf);
		Dolly(scale);
		_voiViz->Dolly(scale);
		CurrentRenderer->GetRenderWindow()->Render();
	      }
	      InvokeEvent(vtkCommand::InteractionEvent, NULL);
	      break;
	    case VTKIS_SPIN:
	      Spin();
	      InvokeEvent(vtkCommand::InteractionEvent, NULL);
	      //this->frame->RefreshViz ();
	      break;
	      //default:
	      // if(_Scene->GetPathwayViz()->PickManipulationTools(x,y) != -1)
	      //  frame->RefreshViz();
	      // break;
	    }
	}

}
bool mitk::ExtrudedContourInteractor::ExecuteAction(mitk::Action* action, mitk::StateEvent const* stateEvent)
{
  mitk::Point3D eventPoint;
  mitk::Vector3D eventPlaneNormal;

  const mitk::PositionEvent* posEvent = dynamic_cast<const mitk::PositionEvent*>(stateEvent->GetEvent());

  if(posEvent==NULL)
  {
    const mitk::DisplayPositionEvent* displayPosEvent = dynamic_cast<const mitk::DisplayPositionEvent*>(stateEvent->GetEvent());
    mitk::VtkPropRenderer* sender = (mitk::VtkPropRenderer*) stateEvent->GetEvent()->GetSender();

    if((displayPosEvent == NULL) || (sender == NULL))
      return false;

    eventPoint[0] = displayPosEvent->GetDisplayPosition()[0];
    eventPoint[1] = displayPosEvent->GetDisplayPosition()[1];
    eventPoint[2] = 0;

    typedef itk::Point<double,3> DoublePoint3D;
    DoublePoint3D p;
    p.CastFrom(eventPoint);
    sender->GetVtkRenderer()->SetDisplayPoint(p.GetDataPointer());

    sender->GetVtkRenderer()->DisplayToWorld();

    double *vtkwp = sender->GetVtkRenderer()->GetWorldPoint();

    vtk2itk(vtkwp, eventPoint);

    double *vtkvpn = sender->GetVtkRenderer()->GetActiveCamera()->GetViewPlaneNormal();
    vtk2itk(vtkvpn, eventPlaneNormal); eventPlaneNormal = -eventPlaneNormal;
  }
  else
  {
    eventPoint = posEvent->GetWorldPosition();
    mitk::BaseRenderer* sender = (mitk::BaseRenderer*) stateEvent->GetEvent()->GetSender();
    eventPlaneNormal = sender->GetCurrentWorldPlaneGeometry()->GetAxisVector(2);
  }


  bool ok = false;
  switch (action->GetActionId())
  {
  case mitk::AcNEWPOINT:
    {
      Press(eventPoint);
      ok = true;
      m_Started = true;
      break;
    }
  case mitk::AcINITMOVEMENT:
    {
      if (m_Started)
      {
        Move(eventPoint);
        ok = true;
        break;
      }
    }
  case mitk::AcMOVEPOINT:
    {
      if (m_Started)
      {
        Move(eventPoint);
        ok = true;
        break;
      }
    }
  case mitk::AcFINISHMOVEMENT:
    {
      if (m_Started)
      {
        mitk::ExtrudedContour* extrudedcontour = dynamic_cast<mitk::ExtrudedContour*>(m_DataNode->GetData());
        extrudedcontour->SetContour(m_Contour);
        extrudedcontour->SetVector(eventPlaneNormal);
        Release(eventPoint);
        ok = true;
        m_Started = false;
        InvokeEvent(itk::EndEvent());
      }
      break;
    }
  default:
    ok = false;
    break;
  }
  return ok;
}