#include "vtkKWMainWindow.h" #include "vtkImageData.h" #include "vtkViewImage3D.h" #include "vtkViewImage2D.h" #include #include #include #include "vtkKWToolbar.h" #include "vtkKWToolbarSet.h" #include "vtkKWPushButton.h" #include "vtkKWIcon.h" #include #include "vtkKWApplication.h" #include "vtkKWPageView.h" #include "vtkKWMenu.h" #include "vtkKWMenuButton.h" #include #include "vtkKWNotebook.h" #include #include //---------------------------------------------------------------------------- vtkStandardNewMacro( vtkKWMainWindow ); vtkCxxRevisionMacro( vtkKWMainWindow, "$Revision: 1.7 $"); //---------------------------------------------------------------------------- vtkKWMainWindow::vtkKWMainWindow() { this->OpenToolbar = vtkKWToolbar::New(); this->ViewToolbar = vtkKWToolbar::New(); this->DataSetToolbar = vtkKWToolbar::New(); this->MeshToolbar = vtkKWToolbar::New(); } //---------------------------------------------------------------------------- vtkKWMainWindow::~vtkKWMainWindow() { std::cout<<"deleting mainwindow"<OpenToolbar->Delete(); this->ViewToolbar->Delete(); this->DataSetToolbar->Delete(); this->MeshToolbar->Delete(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::CreateOpenToolbar() { this->OpenToolbar->SetName("Main ToolBar"); this->OpenToolbar->SetParent(this->GetMainToolbarSet()->GetToolbarsFrame()); this->OpenToolbar->Create(); this->GetMainToolbarSet()->AddToolbar(this->OpenToolbar); vtkKWPushButton* button0= vtkKWPushButton::New(); button0->SetParent(this->OpenToolbar->GetFrame()); button0->Create(); button0->SetImageToPixels(image_fileopen, image_fileopen_width, image_fileopen_height, image_fileopen_pixel_size, image_fileopen_length); button0->SetCommand(this, "OnMenuFileOpen"); button0->SetBalloonHelpString("Open file(s)..."); this->OpenToolbar->AddWidget(button0); button0->Delete(); vtkKWPushButton* button00= vtkKWPushButton::New(); button00->SetParent(this->OpenToolbar->GetFrame()); button00->Create(); button00->SetImageToPixels(image_importdicom, image_importdicom_width, image_importdicom_height, image_importdicom_pixel_size, image_importdicom_length); button00->SetCommand(this, "OnMenuFileOpenDICOM"); button00->SetBalloonHelpString("Open DICOM exam..."); this->OpenToolbar->AddWidget(button00); button00->Delete(); vtkKWPushButton* button000= vtkKWPushButton::New(); button000->SetParent(this->OpenToolbar->GetFrame()); button000->Create(); button000->SetImageToPixels(image_mplayer, image_mplayer_width, image_mplayer_height, image_mplayer_pixel_size, image_mplayer_length); button000->SetCommand(this, "OnMenuFileOpen4D"); button000->SetBalloonHelpString("Create Sequence..."); this->OpenToolbar->AddWidget(button000); button000->Delete(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::CreateViewToolbar() { this->ViewToolbar->SetName("View ToolBar"); this->ViewToolbar->SetParent(this->GetMainToolbarSet()->GetToolbarsFrame()); this->ViewToolbar->Create(); this->GetMainToolbarSet()->AddToolbar(this->ViewToolbar); vtkKWPushButton* button1= vtkKWPushButton::New(); button1->SetParent(this->ViewToolbar->GetFrame()); button1->Create(); button1->SetImageToPixels(image_selector, image_selector_width, image_selector_height, image_selector_pixel_size, image_selector_length); button1->SetCommand(this, "OnSelectInteraction"); button1->SetBalloonHelpString("Select Interaction"); this->ViewToolbar->AddWidget(button1); button1->Delete(); vtkKWPushButton* button2= vtkKWPushButton::New(); button2->SetParent(this->ViewToolbar->GetFrame()); button2->Create(); button2->SetImageToPixels(image_greyscale, image_greyscale_width, image_greyscale_height, image_greyscale_pixel_size, image_greyscale_length); button2->SetCommand(this, "OnWindowLevelInteraction"); button2->SetBalloonHelpString("Window-Level Interaction"); this->ViewToolbar->AddWidget(button2); button2->Delete(); vtkKWPushButton* button3= vtkKWPushButton::New(); button3->SetParent(this->ViewToolbar->GetFrame()); button3->Create(); button3->SetImageToPixels(image_zoom, image_zoom_width, image_zoom_height, image_zoom_pixel_size, image_zoom_length); button3->SetCommand(this, "OnZoomInteraction"); button3->SetBalloonHelpString("Zoom Interaction"); this->ViewToolbar->AddWidget(button3); button3->Delete(); vtkKWPushButton* button4= vtkKWPushButton::New(); button4->SetParent(this->ViewToolbar->GetFrame()); button4->Create(); button4->SetImageToPixels(image_configure, image_configure_width, image_configure_height, image_configure_pixel_size, image_configure_length); button4->SetCommand(this, "OnScalarbarVisibility"); button4->SetBalloonHelpString("Display scalar bars"); this->ViewToolbar->AddWidget(button4); button4->Delete(); vtkKWPushButton* button7= vtkKWPushButton::New(); button7->SetParent(this->ViewToolbar->GetFrame()); button7->Create(); button7->SetImageToPixels(image_axial, image_axial_width, image_axial_height, image_axial_pixel_size, image_axial_length); button7->SetCommand(this, "OnFullScreenAxial"); button7->SetBalloonHelpString("Axial full screen"); this->ViewToolbar->AddWidget(button7); button7->Delete(); vtkKWPushButton* button8= vtkKWPushButton::New(); button8->SetParent(this->ViewToolbar->GetFrame()); button8->Create(); button8->SetImageToPixels(image_coronal, image_coronal_width, image_coronal_height, image_coronal_pixel_size, image_coronal_length); button8->SetCommand(this, "OnFullScreenCoronal"); button8->SetBalloonHelpString("Coronal full screen"); this->ViewToolbar->AddWidget(button8); button8->Delete(); vtkKWPushButton* button9= vtkKWPushButton::New(); button9->SetParent(this->ViewToolbar->GetFrame()); button9->Create(); button9->SetImageToPixels(image_sagittal, image_sagittal_width, image_sagittal_height, image_sagittal_pixel_size, image_sagittal_length); button9->SetCommand(this, "OnFullScreenSagittal"); button9->SetBalloonHelpString("Sagittal full screen"); this->ViewToolbar->AddWidget(button9); button9->Delete(); vtkKWPushButton* button6= vtkKWPushButton::New(); button6->SetParent(this->ViewToolbar->GetFrame()); button6->Create(); button6->SetImageToPixels(image_fullscreen, image_fullscreen_width, image_fullscreen_height, image_fullscreen_pixel_size, image_fullscreen_length); button6->SetCommand(this, "OnFullScreenView4"); button6->SetBalloonHelpString("3D full screen"); this->ViewToolbar->AddWidget(button6); button6->Delete(); vtkKWPushButton* button10= vtkKWPushButton::New(); button10->SetParent(this->ViewToolbar->GetFrame()); button10->Create(); button10->SetImageToPixels(image_volumerendering, image_volumerendering_width, image_volumerendering_height, image_volumerendering_pixel_size, image_volumerendering_length); button10->SetCommand(this, "OnRenderingModeToVR"); button10->SetBalloonHelpString("Toggle rendering mode"); this->ViewToolbar->AddWidget(button10); button10->Delete(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::CreateDataSetToolbar() { this->DataSetToolbar->SetName("DataSet ToolBar"); this->DataSetToolbar->SetParent(this->GetMainToolbarSet()->GetToolbarsFrame()); this->DataSetToolbar->Create(); this->GetMainToolbarSet()->AddToolbar(this->DataSetToolbar); vtkKWPushButton* button0= vtkKWPushButton::New(); button0->SetParent(this->DataSetToolbar->GetFrame()); button0->Create(); button0->SetImageToPixels(image_fileopen, image_fileopen_width, image_fileopen_height, image_fileopen_pixel_size, image_fileopen_length); button0->SetCommand(this, "OnDataSetAttributes"); button0->SetBalloonHelpString("Display Attributes \nof the Selected Dataset..."); this->DataSetToolbar->AddWidget(button0); button0->Delete(); vtkKWPushButton* button1= vtkKWPushButton::New(); button1->SetParent(this->DataSetToolbar->GetFrame()); button1->Create(); button1->SetImageToPixels(image_fileopen, image_fileopen_width, image_fileopen_height, image_fileopen_pixel_size, image_fileopen_length); button1->SetCommand(this, "OnDataSetSave"); button1->SetBalloonHelpString("Save the Selected Dataset..."); this->DataSetToolbar->AddWidget(button1); button1->Delete(); vtkKWPushButton* button2= vtkKWPushButton::New(); button2->SetParent(this->DataSetToolbar->GetFrame()); button2->Create(); button2->SetImageToPixels(image_fileopen, image_fileopen_width, image_fileopen_height, image_fileopen_pixel_size, image_fileopen_length); button2->SetCommand(this, "OnDataSetDelete"); button2->SetBalloonHelpString("Delete the Selected Dataset..."); this->DataSetToolbar->AddWidget(button2); button2->Delete(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::CreateMeshToolbar() { this->MeshToolbar->SetName("Mesh ToolBar"); this->MeshToolbar->SetParent(this->GetMainToolbarSet()->GetToolbarsFrame()); this->MeshToolbar->Create(); this->GetMainToolbarSet()->AddToolbar(this->MeshToolbar); vtkKWPushButton* button0= vtkKWPushButton::New(); button0->SetParent(this->MeshToolbar->GetFrame()); button0->Create(); button0->SetImageToPixels(image_fileopen, image_fileopen_width, image_fileopen_height, image_fileopen_pixel_size, image_fileopen_length); button0->SetCommand(this, "OnLightProperties"); button0->SetBalloonHelpString("Light Properties..."); this->MeshToolbar->AddWidget(button0); button0->Delete(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::CreateMenu() { vtkKWMenu *file_menu = this->GetFileMenu() ; file_menu->InsertCommand(0, "Open ...", this, "OnMenuFileOpen"); file_menu->InsertCommand(1, "Open 4D ...", this, "OnMenuFileOpen4D"); file_menu->InsertSeparator (4) ; // vtkKWMenu *custom_menu = vtkKWMenu::New(); // custom_menu->SetParent(this->GetMenu()); // custom_menu->Create(); // this->GetMenu()->InsertCascade(1, "&Data", custom_menu); // int index = custom_menu->AddCommand( "&Soon...", this, "OnFullScreenView4"); // custom_menu->SetItemAccelerator(index, "F8"); // custom_menu->SetBindingForItemAccelerator(index, custom_menu->GetParentTopLevel()); // custom_menu->SetItemHelpString(index, "Soon there will be some setting specific to the selected dataset"); // custom_menu->AddCommand ("&Parameters...", this, "OnDataParameters"); // vtkKWMenu *colorby_menu = vtkKWMenu::New(); // colorby_menu->SetParent(custom_menu); // colorby_menu->Create(); // colorby_menu->AddRadioButton ("Surface"); // custom_menu->AddCascade ("&Color by", colorby_menu); // colorby_menu->Delete(); // custom_menu->AddCommand ("&Duplicate", this, "OnDataDuplicate"); // custom_menu->AddCommand ("&Save...", this, "OnDataSave"); // custom_menu->AddCommand ("&Delete", this, "OnDataDelete"); // custom_menu->Delete(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::CreateWidget() { // Check if already created if (this->IsCreated()) { vtkErrorMacro("class already created"); return; } // Call the superclass to create the whole widget this->Superclass::CreateWidget(); vtkKWApplication *app = this->GetApplication(); if (app->GetSplashScreenVisibility()) { app->GetSplashScreen()->SetProgressMessage("Creating Notebook..."); } if (app->GetSplashScreenVisibility()) { app->GetSplashScreen()->SetProgressMessage("Creating Toolbars..."); } this->CreateOpenToolbar(); this->CreateViewToolbar(); this->CreateDataSetToolbar(); this->CreateMeshToolbar(); if (app->GetSplashScreenVisibility()) { app->GetSplashScreen()->SetProgressMessage("Creating Menus..."); } this->CreateMenu(); if (app->GetSplashScreenVisibility()) { app->GetSplashScreen()->SetProgressMessage("Creating Lateral Panels..."); } if (app->GetSplashScreenVisibility()) { app->GetSplashScreen()->SetProgressMessage("Creating DataManager..."); } if (app->GetSplashScreenVisibility()) { app->GetSplashScreen()->SetProgressMessage("Creating Controler..."); } this->PackSelf(); this->SetDisplayPositionToDefault(); this->GetMainSplitFrame()->SetFrame1Size(250); this->SetPosition (50,50); } void vtkKWMainWindow::PackSelf() { if (!this->IsCreated()) return; } vtkKWPageView* vtkKWMainWindow::GetCurrentPage (void) { vtkKWFrame* page = this->GetViewNotebook()->GetFrame (this->GetViewNotebook()->GetRaisedPageId ()); if (!page) return NULL; vtkKWPageView* res = vtkKWPageView::SafeDownCast(page->GetNthChild (0)); if (res) return res; return NULL; } vtkKWPageView* vtkKWMainWindow::GetPage (const char* title) { vtkKWFrame* page = this->GetViewNotebook()->GetFrame (title); if (!page) return NULL; vtkKWPageView* res = vtkKWPageView::SafeDownCast(page->GetNthChild (0)); if (res) return res; return NULL; } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnMenuFileOpen() { std::cout<<"not implemented yet"<GetCurrentPage()) return; this->GetCurrentPage()->GetView1()->SetInteractionStyle (vtkViewImage2D::SELECT_INTERACTION); this->GetCurrentPage()->GetView2()->SetInteractionStyle (vtkViewImage2D::SELECT_INTERACTION); this->GetCurrentPage()->GetView3()->SetInteractionStyle (vtkViewImage2D::SELECT_INTERACTION); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnWindowLevelInteraction() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->GetView1()->SetInteractionStyle (vtkViewImage2D::WINDOW_LEVEL_INTERACTION); this->GetCurrentPage()->GetView2()->SetInteractionStyle (vtkViewImage2D::WINDOW_LEVEL_INTERACTION); this->GetCurrentPage()->GetView3()->SetInteractionStyle (vtkViewImage2D::WINDOW_LEVEL_INTERACTION); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnZoomInteraction() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->GetView1()->SetInteractionStyle (vtkViewImage2D::ZOOM_INTERACTION); this->GetCurrentPage()->GetView2()->SetInteractionStyle (vtkViewImage2D::ZOOM_INTERACTION); this->GetCurrentPage()->GetView3()->SetInteractionStyle (vtkViewImage2D::ZOOM_INTERACTION); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnRenderingModeToVR() { if (!this->GetCurrentPage()) return; if ( this->GetCurrentPage()->GetView4()->GetRenderingMode() == vtkViewImage3D::VOLUME_RENDERING) this->GetCurrentPage()->GetView4()->SetRenderingModeToPlanar(); else this->GetCurrentPage()->GetView4()->SetRenderingModeToVR(); this->GetCurrentPage()->GetView4()->Render(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnFullScreenView4() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->ToggleFullScreenView4(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnFullScreenAxial() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->ToggleFullScreenAxial(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnFullScreenCoronal() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->ToggleFullScreenCoronal(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnFullScreenSagittal() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->ToggleFullScreenSagittal(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnScalarbarVisibility() { if (!this->GetCurrentPage()) return; this->GetCurrentPage()->SetScalarBarVisibility(!this->GetCurrentPage()->GetScalarBarVisibility()); this->GetCurrentPage()->Render(); } //---------------------------------------------------------------------------- void vtkKWMainWindow::OnDataSetAttributes(void) { std::cout<<"not implemented yet"<