CameraMain::CameraMain() { //Camera information setCamPosition(0.0f, 0.0f, 0.0f, 0.0f); setCamTarget(0.0f, 0.0f, 0.0f, 0.0f); setCamUp(0.0f, 0.0f, 0.0f, 0.0f); //Set the View matrix setCamView(getCamPosition(), getCamTarget(), getCamUp()); //Set the Projection matrix setCamProjection(0.0f, 0.0f, 0.0f, 0.0f); setDefaultForward(0.0f, 0.0f, 0.0f, 0.0f); setDefaultRight(0.0f, 0.0f, 0.0f, 0.0f); setCamForward(0.0f, 0.0f, 0.0f, 0.0f); setCamRight(0.0f, 0.0f, 0.0f, 0.0f); setMoveLeftRight(0.0f); setMoveBackForward(0.0f); setCamYaw(0.0f); setCamPitch(0.0f); }
void ViewerWidget::setCamPose(const octomath::Pose6D& pose){ octomath::Pose6D ahead = pose * octomath::Pose6D(octomath::Vector3(1,0,0), octomath::Quaternion()); setCamPosition(pose.x(), pose.y(), pose.z(), ahead.x(), ahead.y(), ahead.z()); }
void iARenderer::initialize( vtkImageData* ds, vtkPolyData* pd, int e ) { imageData = ds; polyData = pd; cellLocator->SetDataSet(polyData); if(polyData) if( polyData->GetNumberOfCells() ) cellLocator->BuildLocator(); ext = e; double spacing[3]; ds->GetSpacing(spacing); ren->SetLayer(0); ren->UseDepthPeelingOn(); #if (VTK_MAJOR_VERSION >= 8 && defined(VTK_OPENGL2_BACKEND) && QT_VERSION >= 0x050400 ) ren->UseDepthPeelingForVolumesOn(); #endif labelRen->SetLayer(1); labelRen->InteractiveOff(); labelRen->UseDepthPeelingOn(); renWin->SetNumberOfLayers(5); renWin->AddRenderer(ren); renWin->AddRenderer(labelRen); interactor = renWin->GetInteractor(); setPointPicker(); InitObserver(); QImage img; img.load(":/images/fhlogo.png"); logoImage->SetQImage(&img); logoImage->Update(); logoRep->SetImage(logoImage->GetOutput( )); logoWidget->SetInteractor(interactor); logoWidget->SetRepresentation(logoRep); logoWidget->SetResizable(false); logoWidget->SetSelectable(true); logoWidget->On(); interactor->Initialize(); // setup cube source cSource->SetXLength(ext * spacing[0]); cSource->SetYLength(ext * spacing[1]); cSource->SetZLength(ext * spacing[2]); cMapper->SetInputConnection(cSource->GetOutputPort()); cActor->SetMapper(cMapper); cActor->GetProperty()->SetColor(1,0,0); setupCutter(); setupCube(); setupAxes(spacing); setupOrientationMarker(); setupRenderer(); labelRen->SetActiveCamera(cam); ren->SetActiveCamera(cam); setCamPosition( 0,0,1, 1,1,1 ); // +Z m_profileLineMapper->SetInputConnection(m_profileLineSource->GetOutputPort()); m_profileLineActor->SetMapper(m_profileLineMapper); m_profileLineStartPointMapper->SetInputConnection(m_profileLineStartPointSource->GetOutputPort()); m_profileLineStartPointActor->SetMapper(m_profileLineStartPointMapper); m_profileLineEndPointMapper->SetInputConnection(m_profileLineEndPointSource->GetOutputPort()); m_profileLineEndPointActor->SetMapper(m_profileLineEndPointMapper); m_profileLineActor->GetProperty()->SetColor(0.59, 0.73, 0.94);//ffa800//150, 186, 240 m_profileLineActor->GetProperty()->SetLineWidth(2.0); m_profileLineActor->GetProperty()->SetLineStipplePattern(0x00ff);//0xf0f0 m_profileLineActor->GetProperty()->SetLineStippleRepeatFactor(1); m_profileLineActor->GetProperty()->SetPointSize(2); m_profileLineStartPointSource->SetRadius(2 * spacing[0]); m_profileLineEndPointSource->SetRadius(2 * spacing[0]); m_profileLineStartPointActor->GetProperty()->SetColor(1.0, 0.65, 0.0); m_profileLineEndPointActor->GetProperty()->SetColor(0.0, 0.65, 1.0); //slicing cube settings for surface extraction m_sliceCubeMapper->SetInputConnection(m_slicingCube->GetOutputPort()); m_sliceCubeActor->SetMapper(m_sliceCubeMapper); m_sliceCubeActor->GetProperty()->SetColor(1.0, 0, 0); m_sliceCubeActor->GetProperty()->SetRepresentationToWireframe(); m_sliceCubeActor->GetProperty()->SetOpacity(1); m_sliceCubeActor->GetProperty()->SetLineWidth(2.3); m_sliceCubeActor->GetProperty()->SetAmbient(1.0); m_sliceCubeActor->GetProperty()->SetDiffuse(0.0); m_sliceCubeActor->GetProperty()->SetSpecular(0.0); m_sliceCubeActor->SetVisibility(false); this-> setArbitraryProfileOn(false); double center[3], origin[3]; const int * dim = imageData->GetDimensions(); if (dim[0] == 0 || dim[1] == 0 || dim[2] == 0) return; const double * spc = imageData->GetSpacing(); for (int i = 0; i < 3; ++i) { center[i] = dim[i] * spc[i] / 2; origin[i] = 0; } for (int s = 0; s < 3; ++s) { m_slicePlaneSource[s]->SetOrigin(origin); double point1[3], point2[3]; for (int j = 0; j < 3; ++j) { point1[j] = 0; point2[j] = 0; } point1[GetSliceAxis(s, 0)] += 1.1 * dim[GetSliceAxis(s, 0)] * spc[GetSliceAxis(s, 0)]; point2[GetSliceAxis(s, 1)] += 1.1 * dim[GetSliceAxis(s, 1)] * spc[GetSliceAxis(s, 1)]; m_slicePlaneSource[s]->SetPoint1(point1); m_slicePlaneSource[s]->SetPoint2(point2); m_slicePlaneSource[s]->SetCenter(center); m_slicePlaneMapper[s]->SetInputConnection(m_slicePlaneSource[s]->GetOutputPort()); m_slicePlaneActor[s]->SetMapper(m_slicePlaneMapper[s]); m_slicePlaneActor[s]->GetProperty()->SetColor( (s == 0) ? 1:0, (s == 1) ? 1 : 0, (s == 2) ? 1 : 0); m_slicePlaneActor[s]->GetProperty()->SetOpacity(1.0); m_slicePlaneActor[s]->SetVisibility(false); m_slicePlaneMapper[s]->Update(); } }