#include #include "vtkObjectFactory.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //---------------------------------------------------------------------------- vtkStandardNewMacro( vtkKWDataManagerWidget ); vtkCxxRevisionMacro( vtkKWDataManagerWidget, "$Revision: 1.2 $"); //---------------------------------------------------------------------------- vtkKWDataManagerWidget::vtkKWDataManagerWidget() { this->DataSetList = vtkKWMultiColumnList::New(); this->ParentObject = NULL; this->Update(); } //---------------------------------------------------------------------------- vtkKWDataManagerWidget::~vtkKWDataManagerWidget() { this->DataSetList->Delete(); } //---------------------------------------------------------------------------- void vtkKWDataManagerWidget::CreateWidget() { // Check if already created if (this->IsCreated()) { vtkErrorMacro("class already created"); return; } // Call the superclass to create the whole widget this->Superclass::CreateWidget(); this->SetBorderWidth(2); this->SetReliefToFlat(); this->DataSetList->SetParent(this); this->DataSetList->Create(); this->DataSetList->MovableColumnsOn(); this->DataSetList->SetSelectionForegroundColor (0,0,0); this->DataSetList->SetWidth(60); int col_index; // Add the columns (make some of them editable) col_index = this->DataSetList->AddColumn("Name"); this->DataSetList->SetColumnEditable(col_index, 0); col_index = this->DataSetList->AddColumn("Type"); this->DataSetList->SetColumnEditable(col_index, 0); this->DataSetList->SetColumnAlignmentToCenter(col_index); col_index = this->DataSetList->AddColumn(NULL); this->DataSetList->SetColumnEditable(col_index, 0); this->DataSetList->SetColumnFormatCommandToEmptyOutput(col_index); this->DataSetList->SetColumnLabelImageToPredefinedIcon(col_index, vtkKWIcon::IconEye); this->DataSetList->SetColumnAlignmentToCenter(col_index); this->DataSetList->SetSelectionChangedCommand (this, "SelectionChangedCallback"); this->DataSetList->SetCellUpdatedCommand (this, "VisibilityChangedCallback"); this->DataSetList->SetUneditableCellDoubleClickCommand(this, "DoubleClickCallback"); this->Pack(); } //---------------------------------------------------------------------------- void vtkKWDataManagerWidget::Update() { // if (this->Lock) // return; if (!this->ParentObject || !this->ParentObject->GetDataManager() ) return; this->DataSetList->DeleteAllRows(); std::vector metadatasetlist = this->ParentObject->GetDataManager()->GetMetaDataSetList(); for (unsigned int i=0; iDataSetList->InsertCellText(i, 0, metadataset->GetName()); this->DataSetList->InsertCellText(i, 1, metadataset->GetDataSetType()); bool visible = false; if (this->ParentObject->GetPage(metadataset->GetTag())) visible = (bool)(this->ParentObject->GetPage(metadataset->GetTag())->GetVisibility (metadataset->GetDataSet())); this->DataSetList->InsertCellTextAsInt(i, 2, visible); this->DataSetList->SetCellWindowCommandToCheckButton(i, 2); } std::vector tblist = this->ParentObject->GetToolBoxList(); for (unsigned int j=0; jUpdate(); } } //---------------------------------------------------------------------------- void vtkKWDataManagerWidget::Pack (void) { if (this->DataSetList) { this->Script("pack %s -fill both -side top -expand t", this->DataSetList->GetWidgetName()); } } //---------------------------------------------------------------------------- void vtkKWDataManagerWidget::SelectionChangedCallback() { unsigned int t_id = this->DataSetList->GetIndexOfFirstSelectedRow (); vtkMetaDataSet* metadataset = this->ParentObject->GetDataManager()->GetMetaDataSet(t_id); if (!metadataset) { return; } this->ParentObject->GetViewNotebook()->RaisePage(metadataset->GetTag()); vtkKWPageView* page = this->ParentObject->GetPage(metadataset->GetTag()); std::vector tblist = this->ParentObject->GetToolBoxList(); for (unsigned int j=0; jSetMetaDataSet (metadataset); if (page) tblist[j]->SetMetaDataSetModifiedCommand(page, "Render"); } } //---------------------------------------------------------------------------- void vtkKWDataManagerWidget::VisibilityChangedCallback(int row, int col, int state) { if (col != 2) return; vtkMetaDataSet* metadataset = this->ParentObject->GetDataManager()->GetMetaDataSet(row); if (!metadataset) return; metadataset->SetVisibility(static_cast(state)); vtkKWPageView* page = this->ParentObject->GetPage(metadataset->GetTag()); if (!page) return; page->SetVisibility (metadataset->GetDataSet(), static_cast(state)); page->Render(); } //---------------------------------------------------------------------------- void vtkKWDataManagerWidget::DoubleClickCallback() { int row = this->DataSetList->GetIndexOfFirstSelectedRow(); if (!this->ParentObject) return; vtkMetaDataSet* metadataset = this->ParentObject->GetDataManager()->GetMetaDataSet(row); if (!metadataset) return; vtkKWDialog* dialog = vtkKWDialog::New(); dialog->SetApplication(this->GetApplication()); dialog->Create(); dialog->SetDisplayPositionToDefault(); dialog->SetPosition (100,100); dialog->SetTitle(metadataset->GetName()); vtkKWMetaInfoWidget* infowidget = vtkKWMetaInfoWidget::New(); infowidget->SetParent(dialog->GetFrame()); infowidget->Create(); infowidget->SetMetaDataSet(metadataset); this->Script("pack %s -side top -anchor nw -expand y -padx 10 -pady 10", infowidget->GetWidgetName()); dialog->Invoke(); infowidget->Delete(); dialog->Delete(); } //---------------------------------------------------------------------------- vtkMetaDataSet* vtkKWDataManagerWidget::GetSelectedMetaDataSet (void) { int row = this->DataSetList->GetIndexOfFirstSelectedRow(); if (!this->ParentObject) return NULL; vtkMetaDataSet* metadataset = this->ParentObject->GetDataManager()->GetMetaDataSet(row); return metadataset; }