From ba1cc70dcdd708b3de57e6e41b3263c1baa5ea58 Mon Sep 17 00:00:00 2001 From: guigues Date: Tue, 2 Dec 2008 10:21:38 +0000 Subject: [PATCH] *** empty log message *** --- kernel/cmake/BBTKConfigurePackage.cmake | 3 + kernel/cmake/BBTKConfigurePackage_src.cmake | 16 +++ kernel/src/bbtkKWBlackBox.cxx | 21 ++-- kernel/src/vtkKWBlackBoxDialog.cxx | 107 +++++++++++++------- kernel/src/vtkKWBlackBoxDialog.h | 6 ++ packages/kw/src/CMakeLists.txt | 2 + packages/kw/src/bbkwLayoutSplit.cxx | 31 +----- packages/kw/src/vtkKWSlicer.cxx | 89 ++++++++-------- packages/kw/src/vtkKWSlicer.h | 4 +- 9 files changed, 165 insertions(+), 114 deletions(-) diff --git a/kernel/cmake/BBTKConfigurePackage.cmake b/kernel/cmake/BBTKConfigurePackage.cmake index ea783e7..92c7d53 100644 --- a/kernel/cmake/BBTKConfigurePackage.cmake +++ b/kernel/cmake/BBTKConfigurePackage.cmake @@ -1,4 +1,7 @@ +MESSAGE(STATUS "=======================================") +MESSAGE(STATUS "CONFIGURING BBTK PACKAGE ${BBTK_PACKAGE_NAME}") + #--------------------------------------------------------------------------- SET(${BBTK_PACKAGE_NAME}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #--------------------------------------------------------------------------- diff --git a/kernel/cmake/BBTKConfigurePackage_src.cmake b/kernel/cmake/BBTKConfigurePackage_src.cmake index 58583e3..ffc6f79 100644 --- a/kernel/cmake/BBTKConfigurePackage_src.cmake +++ b/kernel/cmake/BBTKConfigurePackage_src.cmake @@ -121,6 +121,22 @@ ENDFOREACH(xmlfile) #---------------------------------------------------------------------------- # CREATES LIBRARY +#---------------------------------------------------------------------------- +# TCL WRAPPING FOR KWWIDGETS +IF(BBTK_USE_KWWIDGETS) +#MESSAGE(STATUS "****TCL=${${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL}") +IF(${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL ) +#MESSAGE(STATUS "****TCL OK") +include("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake") +kwwidgets_wrap_tcl(bb${BBTK_PACKAGE_NAME} LIB_TCL_SRCS ${${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL} "") +SET(${BBTK_PACKAGE_NAME}_CXX_SOURCES + ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} + ${LIB_TCL_SRCS}) +ENDIF(${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL) +ENDIF(BBTK_USE_KWWIDGETS) +#---------------------------------------------------------------------------- +#MESSAGE(STATUS ${${BBTK_PACKAGE_NAME}_CXX_SOURCES}) + ADD_LIBRARY(bb${BBTK_PACKAGE_NAME} SHARED ${${BBTK_PACKAGE_NAME}_CXX_SOURCES} ${${BBTK_PACKAGE_NAME}_H_SOURCES} ) diff --git a/kernel/src/bbtkKWBlackBox.cxx b/kernel/src/bbtkKWBlackBox.cxx index d661598..501ebef 100644 --- a/kernel/src/bbtkKWBlackBox.cxx +++ b/kernel/src/bbtkKWBlackBox.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkKWBlackBox.cxx,v $ Language: C++ - Date: $Date: 2008/12/02 08:38:08 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008/12/02 10:21:40 $ + Version: $Revision: 1.3 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -346,17 +346,16 @@ namespace bbtk vtkKWBlackBoxDialog* win = vtkKWBlackBoxDialog::New(); show = (Window*) win; win->bbSetBlackBox( GetThisPointer()); - //bbGetOutputWidget()->GetWidgetName()); - // win->SetName( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN" ); - // win->SetWidth( bbGetInputWinWidth() ); - // win->SetHeight( bbGetInputWinHeight() ); KW::GetApplication()->AddWindow((vtkKWWindowBase*)win); win->Create(); - // std::cout << "TclName='"<GetTclName()<<"'"<Script("pack %s -side top -expand yes", - bbGetOutputWidget()->GetWidgetName()); + win->SetResizable(0,0); + bbUserCreateWidget(win->GetFrame()); + + KW::GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d", + bbGetOutputWidget()->GetWidgetName(), + bbGetInputWinWidth(), + bbGetInputWinHeight()); + /* bbGetOutputWidget()->SetParent(win); bbGetOutputWidget()->Create(); diff --git a/kernel/src/vtkKWBlackBoxDialog.cxx b/kernel/src/vtkKWBlackBoxDialog.cxx index d7ca41b..8d26092 100644 --- a/kernel/src/vtkKWBlackBoxDialog.cxx +++ b/kernel/src/vtkKWBlackBoxDialog.cxx @@ -70,20 +70,85 @@ //------------------------------------------------------------------------- vtkStandardNewMacro( vtkKWBlackBoxDialog ); - vtkCxxRevisionMacro( vtkKWBlackBoxDialog, "$Revision: 1.1 $"); + vtkCxxRevisionMacro( vtkKWBlackBoxDialog, "$Revision: 1.2 $"); //------------------------------------------------------------------------- //========================================================================= - vtkKWBlackBoxDialog::vtkKWBlackBoxDialog() - : mShown(false) +vtkKWBlackBoxDialog::vtkKWBlackBoxDialog() + : mShown(false) +{ + bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::vtkKWBlackBoxDialog()" + <mFrame = vtkKWFrame::New(); +} +//========================================================================= + //========================================================================= + vtkKWBlackBoxDialog::~vtkKWBlackBoxDialog() { - bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::vtkKWBlackBoxDialog()" - <mFrame->Delete(); + bbHide(); + bbtk::KW::DecNbWindowsAlive(); + if (!mBox.expired()) + { + mBox.lock()->bbSetWindow(0); + } } //========================================================================= + +//========================================================================= +void vtkKWBlackBoxDialog::CreateWidget() +{ + bbtkDebugMessage("kw",5,"vtkKWBlackBoxDialog::CreateWidget() [" + <bbGetFullName()<<"]"<IsCreated()) + { + vtkErrorMacro("vtkKWBlackBoxDialog already created"); + return; + } + + this->Superclass::CreateWidget(); + this->SetTitle((bbGetBlackBox()->bbGetInputWinTitle()+" - bbtk (c) CREATIS-LRMN").c_str()); + + this->mFrame->SetParent(this); + this->mFrame->Create(); + this->mFrame->SetWidth ( bbGetBlackBox()->bbGetInputWinWidth() ); + this->mFrame->SetHeight ( bbGetBlackBox()->bbGetInputWinHeight() ); + + this->Script("pack %s -side top -expand true", + this->mFrame->GetWidgetName()); +} +//========================================================================= + +/* +//========================================================================= +void vtkKWBlackBoxDialog::Pack() +{ + this->Script("pack %s -side top -expand true", + this->mFrame->GetWidgetName()); +} +//========================================================================= +*/ + //========================================================================= + void vtkKWBlackBoxDialog::Cancel() + { + bbtkDebugMessage("kw",9,"vtkKWBlackBoxDialog::Cancel()"<Delete(); + + // this->Withdraw(); + bbHide(); + this->Done = vtkKWDialog::StatusCanceled; + // std::cout << "REFS= "<GetReferenceCount()<Delete(); - - // this->Withdraw(); - bbHide(); - this->Done = vtkKWDialog::StatusCanceled; - // std::cout << "REFS= "<GetReferenceCount()<bbSetWindow(0); - } - } - //========================================================================= /* @@ -159,7 +196,7 @@ //------------------------------------------------------------------------- vtkStandardNewMacro( vtkKWBlackBoxFrame ); - vtkCxxRevisionMacro(vtkKWBlackBoxFrame, "$Revision: 1.1 $"); + vtkCxxRevisionMacro(vtkKWBlackBoxFrame, "$Revision: 1.2 $"); //------------------------------------------------------------------------- //========================================================================= vtkKWBlackBoxFrame::vtkKWBlackBoxFrame() diff --git a/kernel/src/vtkKWBlackBoxDialog.h b/kernel/src/vtkKWBlackBoxDialog.h index f47f89f..aa951e7 100644 --- a/kernel/src/vtkKWBlackBoxDialog.h +++ b/kernel/src/vtkKWBlackBoxDialog.h @@ -5,6 +5,8 @@ #include "bbtkKWBlackBox.h" #include "vtkKWDialog.h" +#include "vtkKWFrame.h" + typedef bbtk::KWBlackBox::Pointer BBPointer; typedef bbtk::KWBlackBox::WeakPointer BBWeakPointer; @@ -30,6 +32,9 @@ public: mBox.lock()->bbSetWindow(this); } virtual BBPointer bbGetBlackBox() { return mBox.lock(); } + vtkKWWidget* GetFrame() { return mFrame; } + void CreateWidget(); + // void Pack(); protected: vtkKWBlackBoxDialog(); ~vtkKWBlackBoxDialog(); @@ -38,6 +43,7 @@ private: void operator=(const vtkKWBlackBoxDialog&); // Not implemented. BBWeakPointer mBox; bool mShown; + vtkKWFrame* mFrame; }; //================================================================== diff --git a/packages/kw/src/CMakeLists.txt b/packages/kw/src/CMakeLists.txt index f165f0d..97061d0 100644 --- a/packages/kw/src/CMakeLists.txt +++ b/packages/kw/src/CMakeLists.txt @@ -1,3 +1,5 @@ +SET( ${BBTK_PACKAGE_NAME}_CXX_SOURCES_WRAP_TCL vtkKWSlicer.cxx ) + #--------------------------------------------------------------------------- # Include src configuration cmake script INCLUDE(${BBTK_CMAKE_DIR}/BBTKConfigurePackage_src.cmake) diff --git a/packages/kw/src/bbkwLayoutSplit.cxx b/packages/kw/src/bbkwLayoutSplit.cxx index 243b53e..b35f7f1 100644 --- a/packages/kw/src/bbkwLayoutSplit.cxx +++ b/packages/kw/src/bbkwLayoutSplit.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbkwLayoutSplit.cxx,v $ Language: C++ - Date: $Date: 2008/11/29 21:41:58 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008/12/02 10:21:42 $ + Version: $Revision: 1.2 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -70,35 +70,15 @@ namespace bbkw splitframe->SetFrame1MinimumSize(5); splitframe->SetFrame2MinimumSize(5); - splitframe->GetApplication()->Script("pack %s -side left -anchor c -expand y", + splitframe->GetApplication()->Script("pack %s -side top -expand y", splitframe->GetWidgetName()); /* - splitframe->SetParent(parent); - splitframe->Create(); - splitframe->SetWidth(400); - splitframe->SetHeight(200); splitframe->SetReliefToGroove(); splitframe->SetBorderWidth(2); splitframe->SetExpandableFrameToBothFrames(); - - w->SetName( bbtk::std2kw( bbGetInputWinTitle() ) ); - */ - bbCreateWidgetOfInput("Widget1",splitframe); - bbCreateWidgetOfInput("Widget2",splitframe); - /* - vtkKWWidget* w1 = bbGetInputWidget1(); - if (w1) - { - w1->SetParent(splitframe); - w1->Create(); - } - vtkKWWidget* w2 = bbGetInputWidget2(); - if (w2) - { - w2->SetParent(splitframe); - w2->Create(); - } */ + bbCreateWidgetOfInput("Widget1",splitframe->GetFrame1()); + bbCreateWidgetOfInput("Widget2",splitframe->GetFrame2()); /* int orientation=0; @@ -109,7 +89,6 @@ namespace bbkw if (orientation==1) { w->SplitHorizontally( w1, w2, 100); } else { w->SplitVertically( w1, w2, 100); } - bbSetOutputWidget( w ); */ } diff --git a/packages/kw/src/vtkKWSlicer.cxx b/packages/kw/src/vtkKWSlicer.cxx index adc9bf9..3de69e8 100644 --- a/packages/kw/src/vtkKWSlicer.cxx +++ b/packages/kw/src/vtkKWSlicer.cxx @@ -24,20 +24,27 @@ #include "vtkRenderWindowInteractor.h" #include "vtkXMLImageDataReader.h" +#include "vtkKWCornerAnnotationEditor.h" + //#include "vtkKWWidgetsPaths.h" #include "vtkToolkits.h" #include +extern "C" int Bbkw_Init(Tcl_Interp *interp); + //namespace bbkw { //---------------------------------------------------------------------------- vtkStandardNewMacro( vtkKWSlicer ); -vtkCxxRevisionMacro(vtkKWSlicer, "$Revision: 1.2 $"); +vtkCxxRevisionMacro(vtkKWSlicer, "$Revision: 1.3 $"); //---------------------------------------------------------------------------- vtkKWSlicer::vtkKWSlicer() { + + Bbkw_Init(vtkKWApplication::GetMainInterp ()); + this->Frame = NULL; this->RenderWidget = NULL; this->Image = NULL; @@ -70,6 +77,10 @@ vtkKWSlicer::~vtkKWSlicer() { this->WindowLevelPresetSelector->Delete(); } + if (this->AnnotationEditor) + { + this->AnnotationEditor->Delete(); + } if (this->AnimationWidget) { this->AnimationWidget->Delete(); @@ -94,6 +105,7 @@ void vtkKWSlicer::CreateWidget() vtkKWApplication *app = this->GetApplication(); // Add a SplitFrame + /* Frame = vtkKWSplitFrame::New(); Frame->SetFrame1MinimumSize(150); Frame->SetFrame2MinimumSize(250); @@ -104,12 +116,13 @@ void vtkKWSlicer::CreateWidget() app->Script("pack %s -side top -expand yes",// -fill both", this->Frame->GetWidgetName()); // Add a render widget, attach it to the view frame, and pack + */ if (!this->RenderWidget) { this->RenderWidget = vtkKWRenderWidget::New(); } - this->RenderWidget->SetParent(Frame->GetFrame2()); + this->RenderWidget->SetParent(this); //Frame->GetFrame2()); this->RenderWidget->Create(); this->RenderWidget->CornerAnnotationVisibilityOn(); @@ -120,20 +133,7 @@ void vtkKWSlicer::CreateWidget() // this->Script("grid rowconfigure %s 1 -weight 1 -minsize 100", // this->RenderWidget->GetWidgetName()); - // Create a volume reader - /* - vtkXMLImageDataReader *reader = vtkXMLImageDataReader::New(); - - char data_path[2048]; - sprintf(data_path, "%s/Data/head100x100x47.vti", KWWidgets_EXAMPLES_DIR); - if (!vtksys::SystemTools::FileExists(data_path)) - { - sprintf(data_path, - "%s/..%s/Examples/Data/head100x100x47.vti", - app->GetInstallationDirectory(), KWWidgets_INSTALL_DATA_DIR); - } - reader->SetFileName(data_path); - */ + // Create an image viewer // Use the render window and renderer of the renderwidget @@ -148,15 +148,6 @@ void vtkKWSlicer::CreateWidget() this->RenderWidget->GetRenderWindow()->GetInteractor()); - // Reset the window/level and the camera - /* - reader->Update(); - double *range = reader->GetOutput()->GetScalarRange(); - this->ImageViewer->SetColorWindow(range[1] - range[0]); - this->ImageViewer->SetColorLevel(0.5 * (range[1] + range[0])); - - this->RenderWidget->ResetCamera(); - */ // The corner annotation has the ability to parse "tags" and fill // them with information gathered from other objects. // For example, let's display the slice and window/level in one corner @@ -169,13 +160,15 @@ void vtkKWSlicer::CreateWidget() ca->SetText(2, ""); ca->SetText(3, "\n"); + + // Create a scale to control the slice if (!this->SliceScale) { this->SliceScale = vtkKWScale::New(); } - this->SliceScale->SetParent(Frame->GetFrame1()); + this->SliceScale->SetParent(this); //Frame->GetFrame1()); this->SliceScale->Create(); // this->SliceScale->SetCommand(this, "SetSliceFromScaleCallback"); @@ -192,7 +185,7 @@ void vtkKWSlicer::CreateWidget() vtkKWMenuButtonWithSpinButtonsWithLabel *orientation_menubutton = vtkKWMenuButtonWithSpinButtonsWithLabel::New(); - orientation_menubutton->SetParent(Frame->GetFrame1()); + orientation_menubutton->SetParent(this); //Frame->GetFrame1()); orientation_menubutton->Create(); orientation_menubutton->SetLabelText("Orientation:"); orientation_menubutton->SetPadX(2); @@ -221,12 +214,11 @@ void vtkKWSlicer::CreateWidget() // Create a window/level preset selector - /* vtkKWFrameWithLabel *wl_frame = vtkKWFrameWithLabel::New(); - wl_frame->SetParent(this); //->GetMainPanelFrame()); + wl_frame->SetParent(this); //Frame->GetFrame1()); wl_frame->Create(); wl_frame->SetLabelText("Window/Level Presets"); - + wl_frame->CollapseFrame (); app->Script("pack %s -side top -anchor nw -expand n -fill x -pady 2", wl_frame->GetWidgetName()); @@ -237,22 +229,24 @@ void vtkKWSlicer::CreateWidget() this->WindowLevelPresetSelector->SetParent(wl_frame->GetFrame()); this->WindowLevelPresetSelector->Create(); this->WindowLevelPresetSelector->ThumbnailColumnVisibilityOn(); - - this->WindowLevelPresetSelector->SetPresetAddCommand( - this, "WindowLevelPresetAddCallback"); - this->WindowLevelPresetSelector->SetPresetApplyCommand( - this, "WindowLevelPresetApplyCallback"); - this->WindowLevelPresetSelector->SetPresetUpdateCommand( - this, "WindowLevelPresetUpdateCallback"); - this->WindowLevelPresetSelector->SetPresetHasChangedCommand( - this, "WindowLevelPresetHasChangedCallback"); - + + app->Script("pack %s -side top -anchor nw -expand n -fill x", this->WindowLevelPresetSelector->GetWidgetName()); - // Create a simple animation widget + // Create a corner annotation editor + this->AnnotationEditor = vtkKWCornerAnnotationEditor::New(); + this->AnnotationEditor->SetParent(this); + this->AnnotationEditor->Create(); + this->AnnotationEditor->SetRenderWidget(this->RenderWidget); + this->AnnotationEditor->GetFrame()->CollapseFrame (); + app->Script("pack %s -side top -anchor nw -expand n -fill x", + this->AnnotationEditor->GetWidgetName()); + + // Create a simple animation widget + /* vtkKWFrameWithLabel *animation_frame = vtkKWFrameWithLabel::New(); animation_frame->SetParent(this); //->GetMainPanelFrame()); animation_frame->Create(); @@ -275,6 +269,7 @@ void vtkKWSlicer::CreateWidget() app->Script("pack %s -side top -anchor nw -expand n -fill x", this->AnimationWidget->GetWidgetName()); */ + this->UpdateSliceRanges(); // Callbacks @@ -283,6 +278,18 @@ void vtkKWSlicer::CreateWidget() this->AddCallbackCommandObserver( menu, vtkKWMenu::MenuItemInvokedEvent); + // this->AddCallbackCommandObserver( this->WindowLevelPresetSelector, + + this->WindowLevelPresetSelector->SetPresetAddCommand(this, + "WindowLevelPresetAddCallback"); + this->WindowLevelPresetSelector->SetPresetApplyCommand(this, + "WindowLevelPresetApplyCallback"); + this->WindowLevelPresetSelector->SetPresetUpdateCommand( + this, "WindowLevelPresetUpdateCallback"); + this->WindowLevelPresetSelector->SetPresetHasChangedCommand( + this, "WindowLevelPresetHasChangedCallback"); + + // Deallocate local objects diff --git a/packages/kw/src/vtkKWSlicer.h b/packages/kw/src/vtkKWSlicer.h index 74a0368..4f537a1 100644 --- a/packages/kw/src/vtkKWSlicer.h +++ b/packages/kw/src/vtkKWSlicer.h @@ -14,7 +14,7 @@ class vtkKWWindowLevelPresetSelector; class vtkKWSimpleAnimationWidget; class vtkKWMenu; class vtkKWSplitFrame; - +class vtkKWCornerAnnotationEditor; //namespace bbkw { class vtkKWSlicer : public vtkKWCompositeWidget @@ -59,6 +59,8 @@ protected: vtkKWRenderWidget *RenderWidget; vtkKWSimpleAnimationWidget *AnimationWidget; vtkKWMenu *OrientationMenu; + vtkKWCornerAnnotationEditor *AnnotationEditor; + virtual void UpdateSliceRanges(); private: -- 2.45.1