X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkWxBlackBox.cxx;h=e4a8410357eedb865837908d5effa2763157f6df;hb=2b8d8f686974ab38c9ffcf0f88dd533b01b68e84;hp=06ec96786de00233ec26424bfb22e6ce7055455e;hpb=35efff5ca9f485da0da66535dc3ce8fff49df520;p=bbtk.git diff --git a/kernel/src/bbtkWxBlackBox.cxx b/kernel/src/bbtkWxBlackBox.cxx index 06ec967..e4a8410 100644 --- a/kernel/src/bbtkWxBlackBox.cxx +++ b/kernel/src/bbtkWxBlackBox.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxBlackBox.cxx,v $ Language: C++ - Date: $Date: 2008/03/06 09:23:43 $ - Version: $Revision: 1.8 $ + Date: $Date: 2008/04/23 14:49:28 $ + Version: $Revision: 1.15 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -48,14 +48,14 @@ namespace bbtk //========================================================================= - WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox* box) + WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox::Pointer box) : mBox(box), mShown(false) { - bbtkDebugMessage("Wx",9,"WxBlackBoxWindow::WxBlackBoxWindow("<< - mBox->bbGetFullName()<<")"<bbSetWindow(this); + bbtkDebugMessage("wx",9,"WxBlackBoxWindow::WxBlackBoxWindow("<< + mBox.lock()->bbGetFullName()<<")"<bbSetWindow(this); Wx::IncNbWindowsAlive(); - bbtkDebugMessage("Wx",9," -> Number of windows alive = " + bbtkDebugMessage("wx",5," -> Number of windows alive = " <bbGetFullName()<<"]"<bbSetWindow(0); Wx::DecNbWindowsAlive(); - bbtkDebugMessage("Wx",9," -> Number of windows alive = " + if (!mBox.expired()) + { + mBox.lock()->bbSetWindow(0); + } + else + { + } + bbtkDebugMessage("wx",5," -> Number of windows alive = " <bbGetFullName()<<"]"< Number of windows shown = " + bbtkDebugMessage("wx",5," -> Number of windows shown = " <bbGetFullName()<<"]"< Number of windows shown = " + bbtkDebugMessage("wx",5," -> Number of windows shown = " <bbGetFullName()<<","<bbGetFullName()<<"]"<bbGetFullName()<<"]"<bbGetFullName()<<","<bbGetFullName()<<")"<bbUserOnShow(); + // wxFrame::SetFocus(); } //========================================================================= //========================================================================= void WxBlackBoxFrame::bbHide() { - bbtkDebugMessage("Wx",9,"WxBlackBoxFrame::bbHide() ["<< - bbGetBlackBox()->bbGetFullName()<<"]"<bbUserOnHide(); } //========================================================================= - //========================================================================= - // WxBlackBoxDialogWrapper - //========================================================================= - /* - //========================================================================= - WxBlackBoxDialogWrapper::WxBlackBoxDialogWrapper(WxBlackBox* box, - wxDialog *wrapped) - : WxBlackBoxWindow(box), - mWrapped(wrapped) - { - bbtkDebugMessage("Wx",9, - "WxBlackBoxDialogWrapper::WxBlackBoxDialogWrapper(" - <bbGetFullName()<<","<bbGetFullName()<<")"<ShowModal(); - // For Windows : - mWrapped->SetReturnCode( i ); - } - //========================================================================= - - //========================================================================= - void WxBlackBoxDialogWrapper::bbHide() - { - bbtkDebugMessage("Wx",9,"WxBlackBoxDialogWrapper::bbHide() ["<< - bbGetBlackBox()->bbGetFullName()<<"]"<Hide(); - } - //========================================================================= - - */ - - /* - //========================================================================= - // WxBlackBoxWidget - //========================================================================= - - //========================================================================= - WxBlackBoxWidget::WxBlackBoxWidget( WxBlackBox* box) - : mBox(box) - { - bbtkDebugMessage("Wx",9,"WxBlackBoxWidget::WxBlackBoxWidget("<bbGetFullName()<<")"<bbSetWidget(this); - } - //========================================================================= - - //========================================================================= - WxBlackBoxWidget::~WxBlackBoxWidget() - { - bbtkDebugMessage("Wx",9,"WxBlackBoxWidget::~WxBlackBoxWidget("<bbGetFullName()<<")"<bbSetWidget(0); - //bbtkDebugMessage("Wx",9,"EO WxBlackBoxWidget::~WxBlackBoxWidget("<bbGetFullName()<<")"<bbGetFullName()<<")"<bbGetFullName()<<")"<bbSetWidgetEventHandler(this); + mBox.lock()->bbSetWidgetEventHandler(this); Connect ( mWindow->GetId(), wxEVT_DESTROY, @@ -342,22 +277,22 @@ namespace bbtk //========================================================================= WxBlackBoxWidgetEventHandler::~WxBlackBoxWidgetEventHandler() { - bbtkDebugMessage("Wx",9, - "WxBlackBoxWidgetEventHandler::~WxBlackBoxWidgetEventHandler(" - <bbGetFullName()<<")"<bbSetWidgetEventHandler(0); + if (mBox.expired()) return; + bbtkDebugMessage("wx",9, + "WxBlackBoxWidgetEventHandler::~WxBlackBoxWidgetEventHandler() [" + <bbGetFullName()<<"]"<bbSetWidgetEventHandler(0); } //========================================================================= //========================================================================= void WxBlackBoxWidgetEventHandler::OnWindowDestroy(wxWindowDestroyEvent&) { - bbtkDebugMessage("Wx",9,"WxBlackBoxWidgetEventHandler::OnWindowDestroy() [" - <bbGetFullName()<<"]"<bbSetOutputWidget(0); - mBox->bbSetModifiedStatus(); - //mDead = true; - //delete this; + if (mBox.expired()) return; + bbtkDebugMessage("wx",9,"WxBlackBoxWidgetEventHandler::OnWindowDestroy() [" + <bbGetFullName()<<"]"<bbSetOutputWidget(0); + mBox.lock()->bbSetModifiedStatus(); } //========================================================================= @@ -367,46 +302,6 @@ namespace bbtk - /* - //========================================================================= - wxWindow* WxParentToChildData::GetWindowInWhichToInsert( const BlackBox* b) - const - { - bbtkDebugMessageInc("Kernel",9,"WxParentToChildData::GetWindowInWhichToInsert("<bbGetFullName()<<")"<bbGetInputConnectorMap().find("WinParent"); - if (i==b->bbGetInputConnectorMap().end()) - { - bbtkError("WxParentToChildData::GetWindowInWhichToInsert : the box " - <bbGetFullName() - <<" does not have any 'Parent' input ?!?"); - } - Connection* c = i->second->GetConnection(); - if (!c) - { - bbtkDebugMessage("Kernel",9, - "-> The input 'Parent' of the box " - <bbGetFullName() - <<" is not connected."<::const_iterator j - = mConnectionToWindowMap.find(c); - - if (j==mConnectionToWindowMap.end()) - { - bbtkError("WxParentToChildData::GetWindowInWhichToInsert(" - <bbGetFullName() - <<") no window provided by parent ?!?"); - } - - bbtkDebugDecTab("Kernel",9); - return j->second; - } - //========================================================================= - */ - //========================================================================= // WxBlackBox //========================================================================= @@ -415,7 +310,7 @@ namespace bbtk //========================================================================= //========================================================================= //========================================================================= - BBTK_USER_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox); + BBTK_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox); //========================================================================= //========================================================================= @@ -439,12 +334,12 @@ namespace bbtk //========================================================================= void WxBlackBox::bbUserDestructor() { - bbtkDebugMessage("Kernel",9,"WxBlackBox::bbUserDestructor()"< WxBlackBox::bbUserDestructor() ["<IsDead()) { - bbtkDebugMessage("Wx",9,"WxBlackBox::bbGetWidget() ["<< + bbtkDebugMessage("wx",9,"WxBlackBox::bbGetWidget() ["<< bbGetFullName()<<"] : Widget is dead : deleting it" < Output 'Widget' connected : transfering execution to parent" <second->GetConnectionVector().front() + i->second->GetConnectionVector().front() //.lock() ->GetBlackBoxTo()->bbExecute(force); } @@ -524,6 +420,106 @@ namespace bbtk //========================================================================= + //========================================================================= + /// Main processing method of the box. + IOStatus WxBlackBox::bbBackwardUpdate( Connection::Pointer caller ) + { + bbtkDebugMessage("Process",1, + "=> WxBlackBox::bbBackwardUpdate(" + <<(caller?caller->GetFullName():"0")<<") [" + <GetFullName():"0")<<") [" + <second->GetConnectionVector().size() != 0 ) + + { + BlackBox::Pointer to = + i->second->GetConnectionVector()[0]->GetBlackBoxTo(); + + if (caller) + { + bbtkDebugMessage("Process",2, + "-> Output 'Widget' connected to '" + <bbGetFullName()<<"' - caller->to = '" + <GetBlackBoxTo()->bbGetFullName() + <<"'" + < Output 'Widget' connected to '" + <bbGetFullName()<<"'" + <GetBlackBoxTo() != to))&& + (!bbGetUpdateTransferedToParent())) + { + bbtkDebugMessage("Process",2, + " ... Transfering update order to parent" + <second->GetConnectionVector().front() //.lock() + ->GetBlackBoxTo()->bbExecute(false); + } + else + { + bbSetUpdateTransferedToParent(false); + bbtkDebugMessage("Process",2, + " ... No need to transfer to parent" + <GetBlackBoxFromOutput()!="Widget")) + ) + { + } + */ + // call 'standard' BlackBox execution method + if (!bbGetUpdateTransferedToParent()) + { + AtomicBlackBox::bbBackwardUpdate(caller); + } + + bbtkDebugMessageDec("Process",1, + "<= WxBlackBox::bbBackwardUpdate() [" + <bbUserCreateWidget(); + this->bbUserProcess(); + bbShowWindow(); + } + //========================================================================= + //================================================================== /// Specific methods for window creation during pipeline execution /// Shows the window associated to the box @@ -541,7 +537,8 @@ namespace bbtk bbtkDebugMessage("Process",3, "-> No widget event handler : creating one" <(), + bbGetOutputWidget()); } else if ( ! bbGetWidgetEventHandler()->IsHandlerOf ( bbGetOutputWidget() ) ) @@ -550,7 +547,8 @@ namespace bbtk "-> Obsolete widget event handler : re-creating one" <(), + bbGetOutputWidget()); } // Sets the name of the wxWindow to the input WinTitle bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle())); @@ -593,8 +591,8 @@ namespace bbtk bbtkDebugMessage("Process",2, " Input WinDialog set to true : creating a Dialog" <(), + bbGetWxParent(), std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"), wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) ); } @@ -604,8 +602,8 @@ namespace bbtk bbtkDebugMessage("Process",2, " Input WinDialog set to false : creating a Frame" <(), + bbGetWxParent(), std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"), wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) ); } @@ -654,6 +652,36 @@ namespace bbtk //================================================================== + //================================================================== + WxBlackBox::Window* WxBlackBox::bbGetContainingWindow() + { + if (bbGetWindow()!=0) return bbGetWindow(); + BlackBox::OutputConnectorMapType::const_iterator i + = bbGetOutputConnectorMap().find("Widget"); + if ( i->second->GetConnectionVector().size() != 0 ) + { + return boost::static_pointer_cast + (i->second->GetConnectionVector().front() //.lock() + ->GetBlackBoxTo())->bbGetContainingWindow(); + } + return 0; + } + //================================================================== + + + //================================================================== + wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); } + //================================================================== + + + //================================================================== + bool WxBlackBox::bbIsShown() + { + if (bbGetContainingWindow()!=0) + return bbGetContainingWindow()->bbIsShown(); + return false; + } + //================================================================== }//namespace bbtk