Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 10:01:14 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2008/03/10 12:28:43 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
mBox->bbGetFullName()<<")"<<std::endl);
mBox->bbSetWindow(this);
Wx::IncNbWindowsAlive();
- bbtkDebugMessage("Wx",9," -> Number of windows alive = "
+ bbtkDebugMessage("Wx",5," -> Number of windows alive = "
<<Wx::GetNbWindowsAlive()<<std::endl);
}
//=========================================================================
bbHide();
mBox->bbSetWindow(0);
Wx::DecNbWindowsAlive();
- bbtkDebugMessage("Wx",9," -> Number of windows alive = "
+ bbtkDebugMessage("Wx",5," -> Number of windows alive = "
<<Wx::GetNbWindowsAlive()<<std::endl);
mBox->bbGetFullName()<<"]"<<std::endl);
Wx::IncNbWindowsShown();
mShown = true;
- bbtkDebugMessage("Wx",9," -> Number of windows shown = "
+ bbtkDebugMessage("Wx",5," -> Number of windows shown = "
<<Wx::GetNbWindowsShown()<<std::endl);
}
//=========================================================================
mBox->bbGetFullName()<<"]"<<std::endl);
Wx::DecNbWindowsShown();
mShown = false;
- bbtkDebugMessage("Wx",9," -> Number of windows shown = "
+ bbtkDebugMessage("Wx",5," -> Number of windows shown = "
<<Wx::GetNbWindowsShown()<<std::endl);
}
//=========================================================================
bbtkDebugMessage("Wx",5,"WxBlackBoxFrame::bbShow("
<<bbGetBlackBox()->bbGetFullName()<<")"<<std::endl);
WxBlackBoxWindow::bbShow();
- wxFrame::Show();
+ wxFrame::Show();
+ // This Update is ** MANDATORY **
+ // to synchronize wxvtkRenderWindowInteractor objects
+ // (force wx objects creation **NOW**)
+ wxFrame::Update();
+ bbGetBlackBox()->bbUserOnShow();
+ // wxFrame::SetFocus();
}
//=========================================================================
bbtkDebugMessage("Wx",9,"WxBlackBoxFrame::bbHide() ["<<
bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
WxBlackBoxWindow::bbHide();
- Hide();
+ wxFrame::Hide();
+ bbGetBlackBox()->bbUserOnHide();
}
//=========================================================================
//=========================================================================
+ //=========================================================================
+ void WxBlackBox::bbProcess()
+ {
+ if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
+ this->bbUserProcess();
+ bbShowWindow();
+ }
+ //=========================================================================
+
//==================================================================
/// Specific methods for window creation during pipeline execution
/// Shows the window associated to the box
//==================================================================
+ //==================================================================
+ WxBlackBox::Window* WxBlackBox::bbGetContainingWindow()
+ {
+ if (bbGetWindow()!=0) return bbGetWindow();
+ BlackBox::OutputConnectorMapType::const_iterator i
+ = bbGetOutputConnectorMap().find("Widget");
+ if ( i->second->GetConnectionVector().size() != 0 )
+ {
+ return ((WxBlackBox*)i->second->GetConnectionVector().front()
+ ->GetBlackBoxTo())->bbGetContainingWindow();
+ }
+ return 0;
+ }
+ //==================================================================
+
+
+ //==================================================================
+ wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); }
+ //==================================================================
+
+
+ //==================================================================
+ bool WxBlackBox::bbIsShown()
+ {
+ if (bbGetContainingWindow()!=0)
+ return bbGetContainingWindow()->bbIsShown();
+ return false;
+ }
+ //==================================================================
}//namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.h,v $
Language: C++
- Date: $Date: 2008/03/06 09:23:43 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2008/03/10 12:28:43 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public:
typedef WxBlackBoxWindow Window;
- /// Returns the window associated to the box
+ /// Returns the **OWN** window associated to the box
/// If 0 returned = no window
Window* bbGetWindow() { return bbmWindow; }
- /// Returns the Parent Window that must be used to create the widget
- wxWindow* bbGetWxParent() { return Wx::GetTopWindow(); }
+ /// Returns the window containing the widget associated to the box
+ /// Which can be the own window of **ANOTHER** box in case of
+ /// a hierarchy of widgets.
+ /// More precisely :
+ /// If bbGetWindow() != 0 then returns bbGetWindow()
+ /// Else if the output 'Widget' is connected
+ /// then returns bbGetContainingWindow() of the box connected to 'Widget'
+ /// Else returns 0;
+ Window* bbGetContainingWindow();
+ /// Returns the parent wxWindow that must be used to create the widget
+ wxWindow* bbGetWxParent();
+ /// Returns true iff the 'containing window' exists and is shown
+ /// (see bbGetContainingWindow).
+ bool bbIsShown();
+
+ //==================================================================
+ /// User callback invoked when the containing window is shown
+ virtual void bbUserOnShow() {}
+ //==================================================================
+ //==================================================================
+ /// User callback invoked when the containing window is hidden
+ virtual void bbUserOnHide() {}
+ //==================================================================
+
protected:
/// ** Must be defined **
virtual void bbUserCreateWidget()
{
- bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is undefined : cannot work !!");
+ bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?");
}
//==================================================================
+
+
+
+
+
+
+
+
//==================================================================
- /// Calls the user defined widget creation method
- /// and the user processing method and then displays the window
- virtual void bbProcess()
- {
- if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
- this->bbUserProcess();
- bbShowWindow();
- }
+ /// Overloaded processing method for WxBlackBoxes :
+ /// 1) if the widget is null then
+ /// calls the user defined widget creation method : bbUserCreateWidget()
+ /// 2) calls the user defined processing method : bbUserProcess()
+ /// 3) displays the window : bbShowWindow();
+ virtual void bbProcess();
//==================================================================
//==================================================================
- /// Specific methods for windows creation during pipeline execution
+ /// If necessary creates the WxBlackBoxWindow associated to the box
+ /// and shows it
+ /// (does nothing if the box output 'Widget' is connected which
+ /// means that the box does not have its own window but is contained
+ /// into another window)
void bbShowWindow();
+ /// Hides the WxBlackBoxWindow associated to the box (if exists)
void bbHideWindow();
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkWxConsole.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 10:01:14 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/03/10 12:28:43 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
new WxTextCtrlStreamRedirector(std::cerr,mwxTextHistory,*wxGREEN,true);
// Creates and sets the parent window of all bbtk windows
- wxFrame* top = new wxFrame(this,-1,_T("bbtk"),
- wxDefaultPosition,
- wxSize(0,0),
- wxFRAME_TOOL_WINDOW) ;//wxMINIMIZE_BOX);
+ wxWindow* top = new wxPanel(this,-1);//,_T("top"));
+ top->Hide();
+ //new wxFrame(this,-1,_T("bbtk"),
+ // wxDefaultPosition,
+ // wxSize(0,0),
+ // wxFRAME_TOOL_WINDOW) ;//wxMINIMIZE_BOX);
+
Wx::SetTopWindow(top);
+
// top->Show();
Program: bbtk
Module: $RCSfile: bbwxSlider.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 10:01:15 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2008/03/10 12:28:43 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true) { orientation=1; }
- std::cout << "bbGetWxParent = "<<bbGetWxParent()<<std::endl;
+ // std::cout << "bbGetWxParent = "<<bbGetWxParent()<<std::endl;
SliderWidget *w = new SliderWidget(this,
bbGetWxParent(),
orientation ,
bbGetInputIn(),
bbGetInputReactiveOnTrack()
);
- std::cout << "w = "<<w<<std::endl;
- // w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
+ // std::cout << "w = "<<w<<std::endl;
+ // w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
bbSetOutputWidget( w );
}
set viewer.WinTitle "ExampleSimpleSlicer"
set viewer.WinWidth 350
set viewer.WinHeight 400
+set viewer.Slice 20
exec viewer
load std
set viewer.WinTitle "ExampleViewer2D"
set viewer.Slice 20
-
set viewer.WinWidth 400
set viewer.WinHeight 400
-# BUG :
-#exec viewer
-
-# The same :
-new LayoutLine l
-connect viewer.Widget l.Widget1
-exec l
-
-
-
-
+exec viewer
category "viewer"
new LayoutLine main
- new Viewer2D slicer
+ new Viewer2D viewer2D
new Slider slider
# WE NEED A MultipleInputs BOX TO CONNECT BOTH
# slider.BoxChange AND THE INPUT BoxExecute
- # OF THE COMPLEX BOX TO slicer.BoxExecute
+ # OF THE COMPLEX BOX TO viewer2D.BoxExecute
new MultipleInputs refresh
- connect slicer.Widget main.Widget1
+ connect viewer2D.Widget main.Widget1
connect slider.Widget main.Widget2
- connect slider.Out slicer.Slice
+ connect slider.Out viewer2D.Slice
connect slider.BoxChange refresh.In1
- connect refresh.Out slicer.BoxExecute
+ connect refresh.Out viewer2D.BoxExecute
#set main.Proportion 80
set slider.Title "Slice"
- input In slicer.In "Input image"
+ input In viewer2D.In "Input image"
input WinTitle main.WinTitle "Title of the window"
input WinWidth main.WinWidth "Width of the window"
input WinHeight main.WinHeight "Height of the window"
input BoxExecute refresh.In2 "Execute the box"
+ input Slice slider.In "Initial slice"
output Widget main.Widget "Widget"
# EXECUTING THE COMPLEX BOX EXECUTES main
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.cxx,v $
Language: C++
- Date: $Date: 2008/03/03 13:14:27 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/10 12:28:44 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
- void Viewer2DWidget::Update()
+ void Viewer2DWidget::UpdateView()
{
if (imageViewer==NULL){
// imageViewer->GetRenderer()->ResetCamera(x1,x2,y1,y2,z1,z2);
}
-
- if (backImageData!=NULL)
+ // std::cout << "update"<<std::endl;
+ // std::cout << "OW = "<< mBox->bbGetWindow() << std::endl;
+ // std::cout << "CW = "<< mBox->bbGetContainingWindow() << std::endl;
+ // std::cout << "Sh = "<< mBox->bbIsShown() << std::endl;
+
+ // mBox->bbIsShown() is necessary to be sure that the wxWindow is already
+ // created and displayed.
+ // Else when slice != 0 we get an X Window System error with wxGTK
+ if ((backImageData!=NULL)&&(mBox->bbIsShown()))
{
int z = mBox->bbGetInputSlice();
-
+ // std::cout << "slice = "<<z<<std::endl;
int ext[6];
backImageData->GetWholeExtent(ext);
+ // std::cout << "ext = "<<ext[4]<<" - "<<ext[5]<<std::endl;
if (z<ext[4]) { z=ext[4]; }
if (z>=ext[5]) { z=ext[5]-1; }
imageViewer->SetZSlice( z );
#endif
+
}
wxvtkrenderwindowinteractor->Render();
// wxvtkrenderwindowinteractor->Refresh();
- // Refresh();
+
+ //Refresh();
}
void Viewer2D::Process()
{
- ((Viewer2DWidget*)bbGetOutputWidget())->Update();
+ ((Viewer2DWidget*)bbGetOutputWidget())->UpdateView();
bbSetOutputOut( bbGetInputSlice() );
}
bbtkDebugMessageInc("Core",9,"Viewer2D::CreateWidget()"<<std::endl);
Viewer2DWidget* w = new Viewer2DWidget(this,bbGetWxParent());
- w->Update();
bbSetOutputWidget(w);
bbtkDebugDecTab("Core",9);
}
+ // This callback is necessary to get actual processing of the view
+ // when window is shown
+ void Viewer2D::bbUserOnShow()
+ {
+ ((Viewer2DWidget*)bbGetOutputWidget())->UpdateView();
+ }
+
+
}//namespace bbtk
#endif
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.h,v $
Language: C++
- Date: $Date: 2008/03/03 13:14:27 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/10 12:28:44 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public:
Viewer2DWidget(Viewer2D* box, wxWindow *parent);
~Viewer2DWidget();
- void Update();
+ void UpdateView();
private:
Viewer2D *mBox;
vtkImageViewer2 *imageViewer;
void Process();
BBTK_CREATE_WIDGET(CreateWidget);
void CreateWidget();
+ void bbUserOnShow();
};
//=================================================================