void PanelSurface::OnChoiceOverlay( wxCommandEvent& event ) { LayerSurface* surf = ( LayerSurface* )MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" )->GetActiveLayer(); if ( surf ) { int nSel = event.GetSelection() - 1; if ( nSel < surf->GetNumberOfOverlays() ) { surf->SetActiveOverlay( nSel ); } else { // load new overlay map MainWindow::GetMainWindowPointer()->LoadSurfaceOverlay(); } UpdateUI(); } }
void PanelSurface::DoUpdateUI() { if ( !IsShown() ) return; bool bHasSurface = ( m_listBoxLayers->GetSelection() != wxNOT_FOUND ); wxWindowList children = XRCCTRL( *this, "ID_SCROLL_WINDOW", wxScrolledWindow )->GetChildren(); wxWindowList::iterator it = children.begin(), end = children.end(); for (; it != end; it++) { if ( !(*it)->IsKindOf(CLASSINFO(wxToolBar) ) && *it != m_listBoxLayers ) (*it)->Enable( bHasSurface ); } LayerSurface* layer = NULL; FSSurface* surf = NULL; if ( bHasSurface ) { LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( "Surface" ); for ( int i = 0; i < (int)m_listBoxLayers->GetCount() && i < lc->GetNumberOfLayers(); i++ ) m_listBoxLayers->Check( i, lc->GetLayer( i )->IsVisible() ); layer = ( LayerSurface* )( void* )m_listBoxLayers->GetClientData( m_listBoxLayers->GetSelection() ); if ( layer ) { m_sliderOpacity->SetValue( (int)( layer->GetProperties()->GetOpacity() * 100 ) ); UpdateTextValue( m_textOpacity, layer->GetProperties()->GetOpacity() ); double* rgb = layer->GetProperties()->GetBinaryColor(); m_colorPicker->SetColour( wxColour( (int)(rgb[0]*255), (int)(rgb[1]*255), (int)(rgb[2]*255) ) ); rgb = layer->GetProperties()->GetEdgeColor(); m_colorPickerEdge->SetColour( wxColour( (int)(rgb[0]*255), (int)(rgb[1]*255), (int)(rgb[2]*255) ) ); rgb = layer->GetProperties()->GetVectorColor(); m_colorPickerVector->SetColour( wxColour( (int)(rgb[0]*255), (int)(rgb[1]*255), (int)(rgb[2]*255) ) ); m_textFileName->ChangeValue( wxString::FromAscii( layer->GetFileName() ) ); m_textFileName->SetInsertionPointEnd(); m_textFileName->ShowPosition( m_textFileName->GetLastPosition() ); m_spinEdgeThickness->SetValue( layer->GetProperties()->GetEdgeThickness() ); m_spinVectorPointSize->SetValue( layer->GetProperties()->GetVectorPointSize() ); m_choiceCurvatureMap->SetSelection( layer->GetProperties()->GetCurvatureMap() ); UpdateTextValue( m_textMidPoint, layer->GetProperties()->GetThresholdMidPoint() ); UpdateTextValue( m_textSlope, layer->GetProperties()->GetThresholdSlope() ); double range[2]; layer->GetCurvatureRange( range ); m_sliderMidPoint->SetValue( (int) ( ( layer->GetProperties()->GetThresholdMidPoint() - range[0] ) / ( range[1] - range[0] ) * 100 ) ); m_sliderSlope->SetValue( (int) ( layer->GetProperties()->GetThresholdSlope() ) ); surf = layer->GetSourceSurface(); m_choiceRenderMode->SetSelection( layer->GetProperties()->GetSurfaceRenderMode() ); m_choiceMeshColorMap->SetSelection( layer->GetProperties()->GetMeshColorMap() ); m_checkShowVertices->SetValue( layer->GetProperties()->GetShowVertices() ); rgb = layer->GetProperties()->GetVertexColor(); m_colorPickerVertex->SetColour( wxColour( (int)(rgb[0]*255), (int)(rgb[1]*255), (int)(rgb[2]*255) ) ); m_spinVertexPointSize->SetValue( layer->GetProperties()->GetVertexPointSize() ); double* dPos = layer->GetProperties()->GetPosition(); wxString value_strg = ( (wxString)_("") << dPos [0] << _(" ") << dPos[1] << _(" ") << dPos[2] ); m_textPosition->ChangeValue( value_strg ); m_checkHideInfo->SetValue( !layer->GetProperties()->GetShowInfo() ); } lc->SetActiveLayer( ( Layer* )m_listBoxLayers->GetClientData( m_listBoxLayers->GetSelection() ) ); } m_choiceVector->Clear(); m_choiceVector->Append( _("Off") ); if ( surf ) { for ( int i = 0; i < surf->GetNumberOfVectorSets(); i++ ) { m_choiceVector->Append( wxString::FromAscii( surf->GetVectorSetName( i ) ) ); } } m_choiceVector->Append( _("Load vector data...") ); m_choiceVector->SetSelection( surf ? 1 + surf->GetActiveVector() : 0 ); // update overlay controls m_choiceOverlay->Clear(); m_choiceOverlay->Append( _("Off") ); if ( layer ) { for ( int i = 0; i < layer->GetNumberOfOverlays(); i++ ) { m_choiceOverlay->Append( wxString::FromAscii( layer->GetOverlay( i )->GetName() ) ); } } m_choiceOverlay->Append( _("Load from file...") ); m_choiceOverlay->SetSelection( layer ? 1 + layer->GetActiveOverlayIndex() : 0 ); m_btnOverlayConfiguration->Show( layer && layer->GetActiveOverlayIndex() >= 0 ); // update annotation controls m_choiceAnnotation->Clear(); m_choiceAnnotation->Append( _("Off") ); if ( layer ) { for ( int i = 0; i < layer->GetNumberOfAnnotations(); i++ ) { m_choiceAnnotation->Append( wxString::FromAscii( layer->GetAnnotation( i )->GetName() ) ); } } m_choiceAnnotation->Append( _("Load from file...") ); m_choiceAnnotation->SetSelection( layer ? 1 + layer->GetActiveAnnotationIndex() : 0 ); // update label controls m_choiceLabel->Clear(); if ( layer ) { if ( layer->GetNumberOfLabels() > 0 ) { for ( int i = 0; i < layer->GetNumberOfLabels(); i++ ) { m_choiceLabel->Append( wxString::FromAscii( layer->GetLabel( i )->GetName() ) ); } } else m_choiceLabel->Append( _("None") ); } m_choiceLabel->Append( _("Load from file...") ); if ( layer && layer->GetActiveLabelIndex() >= 0 ) m_choiceLabel->SetSelection( layer->GetActiveLabelIndex() ); else m_choiceLabel->SetSelection( 0 ); if ( layer && layer->GetActiveLabel() ) { double* rgb = layer->GetActiveLabel()->GetColor(); m_colorPickerLabel->SetColour( wxColour( (int)(rgb[0]*255), (int)(rgb[1]*255), (int)(rgb[2]*255) ) ); } int nCurvatureMap = layer ? layer->GetProperties()->GetCurvatureMap() : 0; for ( size_t i = 0; i < m_widgetsMidPoint.size(); i++ ) { m_widgetsMidPoint[i]->Show( nCurvatureMap != LayerPropertiesSurface::CM_Off ); } for ( size_t i = 0; i < m_widgetsSlope.size(); i++ ) { m_widgetsSlope[i]->Show( nCurvatureMap == LayerPropertiesSurface::CM_Threshold ); } for ( size_t i = 0; i < m_widgetsVector.size(); i++ ) { m_widgetsVector[i]->Show( m_choiceVector->GetSelection() > 0 ); } for ( size_t i = 0; i < m_widgetsVertex.size(); i++ ) { m_widgetsVertex[i]->Show( m_checkShowVertices->GetValue() ); } for ( size_t i = 0; i < m_widgetsMesh.size(); i++ ) { m_widgetsMesh[i]->Show( layer && layer->GetProperties()->GetSurfaceRenderMode() != LayerPropertiesSurface::SM_Surface ); } for ( size_t i = 0; i < m_widgetsLabel.size(); i++ ) { m_widgetsLabel[i]->Show( layer && layer->GetActiveLabelIndex() >= 0 ); } m_colorPicker->Enable( layer ); // && nCurvatureMap != LayerPropertiesSurface::CM_Threshold ); // hack to force resize of these controls in scrolled window for ( size_t i = 0; i < m_widgetsResize.size(); i++ ) { wxSize sz = m_widgetsResize[i]->GetMinSize(); m_widgetsResize[i]->SetMinSize( wxSize( 100, sz.GetHeight() ) ); } Layout(); }
void InfoTreeWidget::UpdateAll() { this->clear(); m_editor->hide(); LayerCollection* lc_mri = MainWindow::GetMainWindow()->GetLayerCollection( "MRI" ); LayerCollection* lc_surf = MainWindow::GetMainWindow()->GetLayerCollection( "Surface" ); if ( lc_mri->IsEmpty() && lc_surf->IsEmpty()) { return; } QTreeWidgetItem* item = new QTreeWidgetItem(this); item->setText(0, "RAS"); double ras[3] = {m_dRAS[0], m_dRAS[1], m_dRAS[2]}; if (!lc_mri->IsEmpty()) { qobject_cast<LayerMRI*>(lc_mri->GetLayer(0))->RemapPositionToRealRAS(m_dRAS, ras); } QVariantMap map; item->setText(1, QString("%1, %2, %3") .arg(ras[0], 0, 'f', 2) .arg(ras[1], 0, 'f', 2) .arg(ras[2], 0, 'f', 2)); map["Type"] = "RAS"; map["EditableText"] = item->text(1); item->setData(1, Qt::UserRole, map); for (int i = 0; i < lc_mri->GetNumberOfLayers(); i++) { LayerMRI* layer = (LayerMRI*)lc_mri->GetLayer(i); int nIndex[3]; if ( layer->GetProperty()->GetShowInfo() ) { QTreeWidgetItem* item = new QTreeWidgetItem(this); item->setText(0, layer->GetName()); layer->RASToOriginalIndex( ras, nIndex ); double dvalue = layer->GetVoxelValue( m_dRAS ); QString editable = QString("%1, %2, %3").arg(nIndex[0]).arg(nIndex[1]).arg(nIndex[2]); QString strg = QString("%1 \t[%2]").arg(dvalue).arg(editable); QString labelStrg; if (layer->IsTypeOf("PLabel")) { labelStrg = ((LayerPLabel*)layer)->GetLabelName(m_dRAS); } else { labelStrg = layer->GetLabelName( dvalue ); } if (!labelStrg.isEmpty()) { strg += " " + labelStrg; } item->setText(1, strg); map.clear(); map["Type"] = "MRI"; map["EditableText"] = editable; map["Object"] = QVariant::fromValue((QObject*)layer); item->setData(1, Qt::UserRole, map); } } for (int i = 0; i < lc_surf->GetNumberOfLayers(); i++) { LayerSurface* surf = (LayerSurface*)lc_surf->GetLayer(i); if ( surf->GetProperty()->GetShowInfo() ) { QTreeWidgetItem* item = new QTreeWidgetItem(this); item->setText(0, surf->GetName()); double sf_pos[3]; surf->GetSurfaceRASAtTarget( m_dRAS, sf_pos ); QString editable = QString("%1, %2, %3") .arg(sf_pos[0], 0, 'f', 2) .arg(sf_pos[1], 0, 'f', 2) .arg(sf_pos[2], 0, 'f', 2); item->setText(1, QString("SurfaceRAS\t[%1]").arg(editable)); map.clear(); map["Type"] = "SurfaceRAS"; map["EditableText"] = editable; map["Object"] = QVariant::fromValue((QObject*)surf); item->setData(1, Qt::UserRole, map); int nVertex = surf->GetVertexIndexAtTarget( m_dRAS, NULL ); if ( nVertex >= 0 ) { surf->GetSurfaceRASAtVertex( nVertex, sf_pos ); QTreeWidgetItem* item = new QTreeWidgetItem(this); item->setText(1, QString("Vertex \t%1 [%2, %3, %4]") .arg(nVertex) .arg(sf_pos[0], 0, 'f', 2) .arg(sf_pos[1], 0, 'f', 2) .arg(sf_pos[2], 0, 'f', 2)); map.clear(); map["Type"] = "SurfaceVertex"; map["EditableText"] = QString::number(nVertex); map["Object"] = QVariant::fromValue((QObject*)surf); item->setData(1, Qt::UserRole, map); double vec[3]; surf->GetNormalAtVertex( nVertex, vec ); item = new QTreeWidgetItem(this); item->setText(1, QString("Normal \t[%1, %2, %3]") .arg(vec[0], 0, 'f', 2) .arg(vec[1], 0, 'f', 2) .arg(vec[2], 0, 'f', 2)); if ( surf->GetActiveVector() >= 0 ) { surf->GetVectorAtVertex( nVertex, vec ); item = new QTreeWidgetItem(this); item->setText(1, QString("Vector \t[%1, %2, %3]") .arg(vec[0], 0, 'f', 2) .arg(vec[1], 0, 'f', 2) .arg(vec[2], 0, 'f', 2)); } if ( surf->HasCurvature() ) { item = new QTreeWidgetItem(this); item->setText(1, QString("Curvature \t%1").arg(surf->GetCurvatureValue(nVertex))); } int nOverlays = surf->GetNumberOfOverlays(); for ( int i = 0; i < nOverlays; i++ ) { SurfaceOverlay* overlay = surf->GetOverlay( i ); item = new QTreeWidgetItem(this); item->setText(1, QString("%1 \t%2").arg(overlay->GetName()).arg(overlay->GetDataAtVertex( nVertex ))); } int nAnnotations = surf->GetNumberOfAnnotations(); for ( int i = 0; i < nAnnotations; i++ ) { SurfaceAnnotation* annot = surf->GetAnnotation( i ); item = new QTreeWidgetItem(this); item->setText(1, QString("%1 \t%2").arg(annot->GetName()).arg(annot->GetAnnotationNameAtVertex( nVertex ))); } } } } }