void PolyDataObject::SetScalarSource( ImageObject * im ) { if( this->ScalarSource == im ) return; if( this->ScalarSource ) { this->ScalarSource->UnRegister( this ); disconnect( this->ScalarSource, SIGNAL(RemovingFromScene()), this, SLOT(OnScalarSourceDeleted()) ); disconnect( this->ScalarSource, SIGNAL(ObjectModified()), this, SLOT(OnScalarSourceModified()) ); } this->ScalarSource = im; if( this->ScalarSource ) { this->ScalarSource->Register( this ); this->ProbeFilter->SetSourceData( this->ScalarSource->GetImage() ); this->LutBackup->DeepCopy( this->ScalarSource->GetLut() ); connect( this->ScalarSource, SIGNAL(RemovingFromScene()), this, SLOT(OnScalarSourceDeleted()) ); connect( this->ScalarSource, SIGNAL(ObjectModified()), this, SLOT(OnScalarSourceModified()) ); } else { this->ProbeFilter->SetSourceData( 0 ); } UpdatePipeline(); emit ObjectModified(); }
void OpenIGTLinkExample::CreateQtPartControl( QWidget *parent ) { //setup measurements this->m_Measurement = mitk::IGTLMeasurements::GetInstance(); // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); // connect the widget items with the methods connect( m_Controls.butStart, SIGNAL(clicked()), this, SLOT(Start()) ); connect( &m_Timer, SIGNAL(timeout()), this, SLOT(UpdatePipeline())); //create a new OpenIGTLinkExample Client m_IGTLClient = mitk::IGTLClient::New(false); m_IGTLClient->SetName("OIGTL Example Client Device"); //create a new OpenIGTLinkExample Device source m_IGTLDeviceSource = mitk::IGTLDeviceSource::New(); //set the client as the source for the device source m_IGTLDeviceSource->SetIGTLDevice(m_IGTLClient); m_IGTLDeviceSource->RegisterAsMicroservice(); }
void PolyDataObject::OnScalarSourceModified() { vtkScalarsToColors * newLut = this->ScalarSource->GetLut(); if( this->LutBackup != newLut ) { this->LutBackup->DeepCopy( newLut ); UpdatePipeline(); } emit ObjectModified(); }
void PolyDataObject::SetLutIndex( int index ) { this->LutIndex = index; if( this->CurrentLut ) { this->CurrentLut = 0; } UpdatePipeline(); emit ObjectModified(); }
void OpenIGTLinkPlugin::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); connect(m_Controls.buttonConnect, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked())); connect(m_Controls.buttonReceive, SIGNAL(clicked()), this, SLOT(ReceivingButtonClicked())); connect(&m_Timer, SIGNAL(timeout()), this, SLOT(UpdatePipeline())); m_Image2dNode = mitk::DataNode::New(); m_State = IDLE; StateChanged(m_State); }
void PolyDataObject::SetPolyData(vtkPolyData *poly ) { if( poly == this->PolyData ) return; if( this->PolyData ) this->PolyData->UnRegister( this ); this->PolyData = poly; if( this->PolyData ) { this->PolyData->Register( this ); } UpdatePipeline(); emit ObjectModified(); }
bool StateTracker::Bind(bool rebind_all /*= false*/) { // Check the render area if we were in a clear pass. if (m_current_render_pass == m_clear_render_pass && !IsViewportWithinRenderArea()) EndRenderPass(); // Get new pipeline object if any parts have changed if (m_dirty_flags & DIRTY_FLAG_PIPELINE && !UpdatePipeline()) { ERROR_LOG(VIDEO, "Failed to get pipeline object, skipping draw"); return false; } // Get a new descriptor set if any parts have changed if (m_dirty_flags & DIRTY_FLAG_ALL_DESCRIPTOR_SETS && !UpdateDescriptorSet()) { // We can fail to allocate descriptors if we exhaust the pool for this command buffer. WARN_LOG(VIDEO, "Failed to get a descriptor set, executing buffer"); Util::ExecuteCurrentCommandsAndRestoreState(false, false); if (!UpdateDescriptorSet()) { // Something strange going on. ERROR_LOG(VIDEO, "Failed to get descriptor set, skipping draw"); return false; } } // Start render pass if not already started if (!InRenderPass()) BeginRenderPass(); // Re-bind parts of the pipeline VkCommandBuffer command_buffer = g_command_buffer_mgr->GetCurrentCommandBuffer(); if (m_dirty_flags & DIRTY_FLAG_PIPELINE_BINDING || rebind_all) vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_object); if (m_dirty_flags & DIRTY_FLAG_VERTEX_BUFFER || rebind_all) vkCmdBindVertexBuffers(command_buffer, 0, 1, &m_vertex_buffer, &m_vertex_buffer_offset); if (m_dirty_flags & DIRTY_FLAG_INDEX_BUFFER || rebind_all) vkCmdBindIndexBuffer(command_buffer, m_index_buffer, m_index_buffer_offset, m_index_type); if (m_dirty_flags & DIRTY_FLAG_DESCRIPTOR_SET_BINDING || rebind_all) { vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_state.pipeline_layout, 0, m_num_active_descriptor_sets, m_descriptor_sets.data(), NUM_UBO_DESCRIPTOR_SET_BINDINGS, m_bindings.uniform_buffer_offsets.data()); } else if (m_dirty_flags & DIRTY_FLAG_DYNAMIC_OFFSETS) { vkCmdBindDescriptorSets( command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline_state.pipeline_layout, DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS, 1, &m_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_UNIFORM_BUFFERS], NUM_UBO_DESCRIPTOR_SET_BINDINGS, m_bindings.uniform_buffer_offsets.data()); } if (m_dirty_flags & DIRTY_FLAG_VIEWPORT || rebind_all) vkCmdSetViewport(command_buffer, 0, 1, &m_viewport); if (m_dirty_flags & DIRTY_FLAG_SCISSOR || rebind_all) vkCmdSetScissor(command_buffer, 0, 1, &m_scissor); m_dirty_flags = 0; return true; }
//---------------------------------------------------------------------------- void medPipeDensityDistance::OnEvent(mafEventBase *maf_event) //---------------------------------------------------------------------------- { if (mafEvent *e = mafEvent::SafeDownCast(maf_event)) { switch(e->GetId()) { case ID_DENSITY_DISTANCE: { if(m_DensityDistance==0) { m_Gui->Enable(ID_SECOND_THRESHOLD,false); m_Gui->Enable(ID_MAX_DISTANCE,true); m_Gui->Enable(ID_NUM_SECTIONS,true); m_Gui->Enable(ID_BAR_TIPOLOGY,false); m_Area[0]=0; m_Area[1]=0; m_Area[2]=0; m_Gui->Update(); UpdatePipeline(); } else if(m_DensityDistance==1) { m_Gui->Enable(ID_SECOND_THRESHOLD,true); m_Gui->Enable(ID_MAX_DISTANCE,false); m_Gui->Enable(ID_NUM_SECTIONS,false); m_Gui->Enable(ID_BAR_TIPOLOGY,true); m_AreaDistance[0]=0; m_AreaDistance[1]=0; m_AreaDistance[2]=0; m_Gui->Update(); m_ScalarBar->SetMaximumNumberOfColors(m_NumSections); m_ScalarBar->Modified(); UpdatePipeline(); } } break; case ID_MAX_DISTANCE: { UpdatePipeline(); } break; case ID_FIRST_THRESHOLD: { if(m_DensityDistance==1) { if(m_FirstThreshold>=m_SecondThreshold) UpdatePipeline(); else mafMessage(_("Invalid Thresholds")); } else { UpdatePipeline(); } } break; case ID_SECOND_THRESHOLD: { if(m_DensityDistance==1) { if(m_FirstThreshold>=m_SecondThreshold) UpdatePipeline(); else mafMessage(_("Invalid Thresholds")); } else { UpdatePipeline(); } } break; case ID_SELECT_VOLUME: { mafString title = _("Choose Volume"); e->SetArg((long)&medPipeDensityDistance::VolumeAccept); e->SetString(&title); e->SetId(VME_CHOOSE); mafEventMacro(*e); mafNode *NewVolume = e->GetVme(); if(NewVolume == NULL) return; else { m_Volume=NewVolume; mafVMEOutputSurface *surface_output = mafVMEOutputSurface::SafeDownCast(m_Vme->GetOutput()); m_DistanceFilter->SetSource(((mafVME*)m_Volume)->GetOutput()->GetVTKData()); m_DistanceFilter->SetInput((vtkDataSet *)m_Normals->GetOutput()); m_DistanceFilter->SetMaxDistance(m_MaxDistance); m_DistanceFilter->SetThreshold(m_FirstThreshold); m_DistanceFilter->SetDistanceModeToScalar(); m_DistanceFilter->SetInputMatrix(surface_output->GetAbsMatrix()->GetVTKMatrix()); m_DistanceFilter->Modified(); int i; for (i=-4*m_MaxDistance;i<-m_MaxDistance;i++) m_Table->AddRGBPoint(i,m_LowColour.Red()/255.0, m_LowColour.Green()/255.0, m_LowColour.Blue()/255.0); for (i=-m_MaxDistance;i<m_MaxDistance;i++) m_Table->AddRGBPoint(i,1.0,1.0,1.0); for (i=m_MaxDistance;i<=4*m_MaxDistance;i++) m_Table->AddRGBPoint(i,m_HiColour.Red()/255.0, m_HiColour.Green()/255.0, m_HiColour.Blue()/255.0); m_Mapper->SetInput((vtkPolyData*)m_DistanceFilter->GetOutput()); m_Mapper->Modified(); //Calculate the areas vtkMAFSmartPointer<vtkMassProperties> mass_all; mass_all->SetInput(m_DistanceFilter->GetPolyDataOutput()); mass_all->Update(); double total_area = mass_all->GetSurfaceArea(); vtkMAFSmartPointer<vtkClipPolyData> clipHigh; clipHigh->SetInput(m_DistanceFilter->GetPolyDataOutput()); clipHigh->SetValue(m_MaxDistance); clipHigh->GenerateClippedOutputOn(); clipHigh->Update(); vtkMAFSmartPointer<vtkClipPolyData> clipMidLow; clipMidLow->SetInput(clipHigh->GetClippedOutput()); clipMidLow->SetValue(-m_MaxDistance); clipMidLow->GenerateClippedOutputOn(); clipMidLow->Update(); vtkMAFSmartPointer<vtkMassProperties> mass_high; mass_high->SetInput(clipHigh->GetOutput()); mass_high->Update(); vtkMAFSmartPointer<vtkMassProperties> mass_mid; mass_mid->SetInput(clipMidLow->GetOutput()); mass_mid->Update(); vtkMAFSmartPointer<vtkMassProperties> mass_low; mass_low->SetInput(clipMidLow->GetClippedOutput()); mass_low->Update(); m_AreaDistance[0] = (mass_low->GetSurfaceArea() / total_area) * 100.0; m_AreaDistance[1] = (mass_mid->GetSurfaceArea() / total_area) * 100.0; m_AreaDistance[2] = (mass_high->GetSurfaceArea() / total_area) * 100.0; m_ScalarBar->SetMaximumNumberOfColors(3); m_ScalarBar->Modified(); m_Gui->Enable(ID_DENSITY_DISTANCE,true); m_Gui->Enable(ID_FIRST_THRESHOLD,true); m_Gui->Enable(ID_SECOND_THRESHOLD,true); m_Gui->Enable(ID_MAX_DISTANCE,true); m_Gui->Enable(ID_NUM_SECTIONS,true); m_Gui->Update(); UpdatePipeline(); } } break; case ID_NUM_SECTIONS: { if(m_DensityDistance==0) { m_ScalarBar->SetMaximumNumberOfColors(m_NumSections); m_ScalarBar->Modified(); UpdatePipeline(); } } break; case ID_BAR_TIPOLOGY: { UpdatePipeline(); } break; default: mafEventMacro(*e); break; } } else if (maf_event->GetId() == VME_ABSMATRIX_UPDATE) { UpdatePipeline(); } }
void PolyDataObject::SetVertexColorMode( int mode ) { this->VertexColorMode = mode; UpdatePipeline(); emit ObjectModified(); }