예제 #1
0
void mitk::BaseRenderer::MouseMoveEvent(mitk::MouseEvent *me)
{
    //if (m_CameraController)
    //{
    //  if((me->GetButtonState()<=512) || (me->GetButtonState()>=516))// provisorisch: Ctrl nicht durchlassen. Bald wird aus m_CameraController eine StateMachine
    //    m_CameraController->MouseMoveEvent(me);
    //}
    if (m_MapperID == 1)
    {
        Point2D p(me->GetDisplayPosition());
        Point2D p_mm;
        Point3D position;
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        GetDisplayGeometry()->DisplayToWorld(p, p_mm);
        GetDisplayGeometry()->Map(p_mm, position);
        mitk::PositionEvent event(this, me->GetType(), me->GetButton(), me->GetButtonState(), mitk::Key_unknown, p, position);
        mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction());
    }
    else if (m_MapperID == 2)
    {
        Point2D p(me->GetDisplayPosition());
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        me->SetDisplayPosition(p);
        mitk::EventMapper::MapEvent(me, m_RenderingManager->GetGlobalInteraction());
    }
}
예제 #2
0
void mitk::BaseRenderer::InitSize(int w, int h)
{
    m_Size[0] = w;
    m_Size[1] = h;
    GetDisplayGeometry()->SetSizeInDisplayUnits(w, h, false);
    GetDisplayGeometry()->Fit();
}
예제 #3
0
void mitk::BaseRenderer::MousePressEvent(mitk::MouseEvent *me)
{
    //set the Focus on the renderer
    /*bool success =*/m_RenderingManager->GetGlobalInteraction()->SetFocus(this);
    /*
     if (! success)
     mitk::StatusBar::GetInstance()->DisplayText("Warning! from mitkBaseRenderer.cpp: Couldn't focus this BaseRenderer!");
     */

    //if (m_CameraController)
    //{
    //  if(me->GetButtonState()!=512) // provisorisch: Ctrl nicht durchlassen. Bald wird aus m_CameraController eine StateMachine
    //    m_CameraController->MousePressEvent(me);
    //}
    if (m_MapperID == 1)
    {
        Point2D p(me->GetDisplayPosition());
        Point2D p_mm;
        Point3D position;
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        GetDisplayGeometry()->DisplayToWorld(p, p_mm);
        GetDisplayGeometry()->Map(p_mm, position);
        mitk::PositionEvent event(this, me->GetType(), me->GetButton(), me->GetButtonState(), mitk::Key_unknown, p, position);
        mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction());
    }
    else if (m_MapperID > 1)  //==2 for 3D and ==5 for stencil
    {
        Point2D p(me->GetDisplayPosition());

        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        me->SetDisplayPosition(p);
        mitk::EventMapper::MapEvent(me, m_RenderingManager->GetGlobalInteraction());
    }
}
예제 #4
0
void mitk::VtkPropRenderer::Update(mitk::DataNode* datatreenode)
{
  if(datatreenode!=NULL)
  {
    mitk::Mapper::Pointer mapper = datatreenode->GetMapper(m_MapperID);
    if(mapper.IsNotNull())
    {
      GLMapper* glmapper=dynamic_cast<GLMapper*>(mapper.GetPointer());

      if(GetDisplayGeometry()->IsValid())
      {
        if(glmapper != NULL)
        {
          glmapper->Update(this);
          m_VtkMapperPresent=false;
        }
        else
        {
          VtkMapper* vtkmapper=dynamic_cast<VtkMapper*>(mapper.GetPointer());
          if(vtkmapper != NULL)
          {
            vtkmapper->Update(this);
            vtkmapper->UpdateVtkTransform(this);
            m_VtkMapperPresent=true;
          }
        }
      }
    }
  }
}
예제 #5
0
mitk::Point3D mitk::BaseRenderer::Map2DRendererPositionTo3DWorldPosition(Point2D* mousePosition) const
{
    Point2D p_mm;
    Point3D position;
    if (m_MapperID == 1)
    {
        GetDisplayGeometry()->ULDisplayToDisplay(*mousePosition, *mousePosition);
        GetDisplayGeometry()->DisplayToWorld(*mousePosition, p_mm);
        GetDisplayGeometry()->Map(p_mm, position);
    }
    else if (m_MapperID == 2)
    {
        GetDisplayGeometry()->ULDisplayToDisplay(*mousePosition, *mousePosition);
        PickWorldPoint(*mousePosition, position);
    }
    return position;
}
예제 #6
0
/*!
\brief PrepareMapperQueue iterates the datatree

PrepareMapperQueue iterates the datatree in order to find mappers which shall be rendered. Also, it sortes the mappers wrt to their layer.
*/
void mitk::VtkPropRenderer::PrepareMapperQueue()
{
  // variable for counting LOD-enabled mappers
  m_NumberOfVisibleLODEnabledMappers = 0;

  // Do we have to update the mappers ?
  if ( m_LastUpdateTime < GetMTime() || m_LastUpdateTime < GetDisplayGeometry()->GetMTime() ) {
    Update();
  }
  else if (m_MapperID>=1 && m_MapperID < 6)
    Update();

  // remove all text properties before mappers will add new ones
  m_TextRenderer->RemoveAllViewProps();

  for ( unsigned int i=0; i<m_TextCollection.size(); i++ )
  {
    m_TextCollection[i]->Delete();
  }
  m_TextCollection.clear();

  // clear priority_queue
  m_MappersMap.clear();

  int mapperNo = 0;

  //DataStorage
  if( m_DataStorage.IsNull() )
    return;

  DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll();

  for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin();  it != allObjects->End(); ++it)
  {
    DataNode::Pointer node = it->Value();
    if ( node.IsNull() )
      continue;
    mitk::Mapper::Pointer mapper = node->GetMapper(m_MapperID);

    if ( mapper.IsNull() )
      continue;

    bool visible = true;
    node->GetVisibility(visible, this, "visible");

    // The information about LOD-enabled mappers is required by RenderingManager
    if ( mapper->IsLODEnabled( this ) && visible )
    {
      ++m_NumberOfVisibleLODEnabledMappers;
    }
    // mapper without a layer property get layer number 1
    int layer = 1;
    node->GetIntProperty("layer", layer, this);
    int nr = (layer<<16) + mapperNo;
    m_MappersMap.insert( std::pair< int, Mapper * >( nr, mapper ) );
    mapperNo++;
  }
}
예제 #7
0
void mitk::BaseRenderer::Resize(int w, int h)
{
    m_Size[0] = w;
    m_Size[1] = h;

    if (m_CameraController)
        m_CameraController->Resize(w, h); //(formerly problematic on windows: vtkSizeBug)

    GetDisplayGeometry()->SetSizeInDisplayUnits(w, h);
}
예제 #8
0
void mitk::BaseRenderer::KeyPressEvent(mitk::KeyEvent *ke)
{
    if (m_MapperID == 1)
    {
        Point2D p(ke->GetDisplayPosition());
        Point2D p_mm;
        Point3D position;
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        GetDisplayGeometry()->DisplayToWorld(p, p_mm);
        GetDisplayGeometry()->Map(p_mm, position);
        mitk::KeyEvent event(this, ke->GetType(), ke->GetButton(), ke->GetButtonState(), ke->GetKey(), ke->GetText(), p);
        mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction());
    }
    else if (m_MapperID == 2)
    {
        Point2D p(ke->GetDisplayPosition());
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        ke->SetDisplayPosition(p);
        mitk::EventMapper::MapEvent(ke, m_RenderingManager->GetGlobalInteraction());
    }
}
예제 #9
0
/**
 * Saves position of the window, if we are not in full-screen mode
 */
void SpringApp::SaveWindowPosition()
{
#ifndef HEADLESS
	if (!globalRendering->fullScreen) {
		GetDisplayGeometry();
		configHandler->Set("WindowPosX",  globalRendering->winPosX);
		configHandler->Set("WindowPosY",  globalRendering->winPosY);
		configHandler->Set("WindowState", globalRendering->winState);

	}
#endif
}
예제 #10
0
/**
 * Restores position of the window, if we are not in full-screen mode
 */
void SpringApp::RestoreWindowPosition()
{
	globalRendering->winPosX  = configHandler->GetInt("WindowPosX");
	globalRendering->winPosY  = configHandler->GetInt("WindowPosY");
	globalRendering->winState = configHandler->GetInt("WindowState");

#ifndef HEADLESS
	if (!globalRendering->fullScreen) {
		SDL_SysWMinfo info;
		SDL_VERSION(&info.version);

		if (SDL_GetWMInfo(&info)) {
  #if       defined(WIN32)
			bool stateChanged = false;

			if (globalRendering->winState > 0) {
				WINDOWPLACEMENT wp;
				memset(&wp,0,sizeof(WINDOWPLACEMENT));
				wp.length = sizeof(WINDOWPLACEMENT);
				stateChanged = true;
				int wState;
				switch (globalRendering->winState) {
					case 1: wState = SW_SHOWMAXIMIZED; break;
					//! Setting the main-window minimized breaks initialization
					case 2: // wState = SW_SHOWMINIMIZED; break;
					default: stateChanged = false;
				}
				if (stateChanged) {
					ShowWindow(info.window, wState);
					GetDisplayGeometry();
				}
			}

			if (!stateChanged) {
				MoveWindow(info.window, globalRendering->winPosX, globalRendering->winPosY, globalRendering->viewSizeX, globalRendering->viewSizeY, true);
			}

  #elif     defined(__APPLE__)
			// TODO: implement this function

  #else
			info.info.x11.lock_func();
			{
				XMoveWindow(info.info.x11.display, info.info.x11.wmwindow, globalRendering->winPosX, globalRendering->winPosY);
				MyX11SetWindowState(info.info.x11.display, info.info.x11.wmwindow, globalRendering->winState);
			}
			info.info.x11.unlock_func();

  #endif // defined(WIN32)
		}
	}
#endif // defined(HEADLESS)
}
예제 #11
0
void SpringApp::SetupViewportGeometry()
{
	GetDisplayGeometry();

	globalRendering->SetDualScreenParams();
	globalRendering->UpdateViewPortGeometry();
	globalRendering->UpdatePixelGeometry();

	const int vpx = globalRendering->viewPosX;
	const int vpy = globalRendering->winSizeY - globalRendering->viewSizeY - globalRendering->viewPosY;

	agui::gui->UpdateScreenGeometry(globalRendering->viewSizeX, globalRendering->viewSizeY, vpx, vpy);
}
예제 #12
0
void mitk::BaseRenderer::WheelEvent(mitk::WheelEvent * we)
{
    if (m_MapperID == 1)
    {
        Point2D p(we->GetDisplayPosition());
        Point2D p_mm;
        Point3D position;
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        GetDisplayGeometry()->DisplayToWorld(p, p_mm);
        GetDisplayGeometry()->Map(p_mm, position);
        mitk::PositionEvent event(this, we->GetType(), we->GetButton(), we->GetButtonState(), mitk::Key_unknown, p, position);
        mitk::EventMapper::MapEvent(we, m_RenderingManager->GetGlobalInteraction());
        mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction());
    }
    else if (m_MapperID == 2)
    {
        Point2D p(we->GetDisplayPosition());
        GetDisplayGeometry()->ULDisplayToDisplay(p, p);
        we->SetDisplayPosition(p);
        mitk::EventMapper::MapEvent(we, m_RenderingManager->GetGlobalInteraction());
    }
}
예제 #13
0
void SpringApp::SetupViewportGeometry()
{
	if (!GetDisplayGeometry()) {
		globalRendering->UpdateWindowGeometry();
	}

	globalRendering->SetDualScreenParams();
	globalRendering->UpdateViewPortGeometry();
	globalRendering->UpdatePixelGeometry();

	agui::gui->UpdateScreenGeometry(
			globalRendering->viewSizeX,
			globalRendering->viewSizeY,
			globalRendering->viewPosX,
			(globalRendering->winSizeY - globalRendering->viewSizeY - globalRendering->viewPosY) );
}
예제 #14
0
void SpringApp::SetupViewportGeometry()
{
	if (!GetDisplayGeometry()) {
		gu->screenSizeX = screenWidth;
		gu->screenSizeY = screenHeight;
		gu->winSizeX = screenWidth;
		gu->winSizeY = screenHeight;
		gu->winPosX = 0;
		gu->winPosY = 0;
	}
		
	gu->dualScreenMode = !!configHandler.GetInt("DualScreenMode", 0);
	if (gu->dualScreenMode) {
		gu->dualScreenMiniMapOnLeft =
			!!configHandler.GetInt("DualScreenMiniMapOnLeft", 0);
	} else {
		gu->dualScreenMiniMapOnLeft = false;
	}

	if (!gu->dualScreenMode) {
		gu->viewSizeX = gu->winSizeX;
		gu->viewSizeY = gu->winSizeY;
		gu->viewPosX = 0;
		gu->viewPosY = 0;
	}
	else {
		gu->viewSizeX = gu->winSizeX / 2;
		gu->viewSizeY = gu->winSizeY;
		if (gu->dualScreenMiniMapOnLeft) {
			gu->viewPosX = gu->winSizeX / 2;
			gu->viewPosY = 0;
		} else {
			gu->viewPosX = 0;
			gu->viewPosY = 0;
		}
	}
	
	// NOTE:  gu->viewPosY is not currently used
	
	gu->aspectRatio = (float)gu->viewSizeX / (float)gu->viewSizeY;
}
예제 #15
0
/**
 * Saves position of the window, if we are not in full-screen mode
 */
void SpringApp::SaveWindowPosition()
{
#ifndef HEADLESS
	configHandler->Set("Fullscreen", globalRendering->fullScreen);
	if (globalRendering->fullScreen) {
		return;
	}

	GetDisplayGeometry();
	if (globalRendering->winState == CGlobalRendering::WINSTATE_DEFAULT) {
		configHandler->Set("WindowPosX",  globalRendering->winPosX);
		configHandler->Set("WindowPosY",  globalRendering->winPosY);
		configHandler->Set("WindowState", globalRendering->winState);
		configHandler->Set("XResolutionWindowed", globalRendering->winSizeX);
		configHandler->Set("YResolutionWindowed", globalRendering->winSizeY);
	} else
	if (globalRendering->winState == CGlobalRendering::WINSTATE_MINIMIZED) {
		// don't automatically save minimized states
	} else {
		configHandler->Set("WindowState", globalRendering->winState);
	}
#endif
}
예제 #16
0
void mitk::BaseRenderer::PickWorldPoint(const mitk::Point2D& displayPoint, mitk::Point3D& worldPoint) const
{
    mitk::Point2D worldPoint2D;
    GetDisplayGeometry()->DisplayToWorld(displayPoint, worldPoint2D);
    GetDisplayGeometry()->Map(worldPoint2D, worldPoint);
}