-
-
- //=========================================================================
- // KWBlackBox
- //=========================================================================
-
- //=========================================================================
- //=========================================================================
- //=========================================================================
- //=========================================================================
- BBTK_BLACK_BOX_IMPLEMENTATION(KWBlackBox,AtomicBlackBox);
- //=========================================================================
-
- //=========================================================================
- void KWBlackBox::bbUserConstructor()
- {
- bbtkDebugMessage("Kernel",9,"KWBlackBox::bbUserConstructor()"<<std::endl);
- bbInitAttributes();
- }
- //=========================================================================
-
- //=========================================================================
- void KWBlackBox::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
- {
- bbtkDebugMessage("Kernel",9,"KWBlackBox::bbUserCopyConstructor()"
- <<std::endl);
- bbInitAttributes();
- }
- //=========================================================================
-
-
- //=========================================================================
- void KWBlackBox::bbUserDestructor()
- {
- bbtkDebugMessage("kw",9,"==> KWBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
- if (bbGetWindow()) {
- bbGetWindow()->bbClose();
- bbSetWindow(0);
- }
- bbtkDebugMessage("kw",9,"<== KWBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
- }
- //=========================================================================
-
-
-
- //=========================================================================
- /**
- * \brief Initialize the attributes of the class
- *
- */
- void KWBlackBox::bbInitAttributes()
- {
- bbmWindow = 0;
- // bbmWidget = 0;
- // bbSetInputWinParent(0);
- bbSetInputWinTitle(bbGetName());
- bbSetInputWinWidth(800);
- bbSetInputWinHeight(800);
- bbSetInputWinDialog(false);
- bbSetOutputWidget(0);
-
- // bbSetWidgetEventHandler(0);
- bbSetUpdateTransferedToParent(false);
- }
- //=========================================================================
-
- //=========================================================================
- /// Main processing method of the box.
- void KWBlackBox::bbExecute(bool force)
- {
- bbtkDebugMessageInc("process",2,
- "=> KWBlackBox::bbExecute("<<(int)force<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- // If the output 'Widget' is connected then
- // we must execute the parent box
- BlackBox::OutputConnectorMapType::const_iterator i
- = bbGetOutputConnectorMap().find("Widget");
-
- if ( i->second->GetConnectionVector().size() != 0 )
- {
- bbtkDebugMessage("process",3,
- "-> Output 'Widget' connected : transfering execution to parent"
- <<std::endl);
-
- i->second->GetConnectionVector().front() //.lock()
- ->GetBlackBoxTo()->bbExecute(force);
-
- }
- // else call 'standard' BlackBox execution method
- else
- {
- BlackBox::bbExecute(force);
- }
- //
-
- bbtkDebugMessageDec("process",2,
- "<= KWBlackBox::bbExecute() ["
- <<bbGetFullName()<<"]"<<std::endl);
- }
- //=========================================================================
-
-
- //=========================================================================
- /// Main processing method of the box.
- IOStatus KWBlackBox::bbBackwardUpdate( Connection::Pointer caller )
- {
- bbtkDebugMessage("process",3,
- "=> KWBlackBox::bbBackwardUpdate("
- <<(caller?caller->GetFullName():"0")<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- if ( ! (( bbGetStatus() == MODIFIED ) ||
- ( bbBoxProcessModeIsAlways() )) )
- {
- bbtkDebugMessage("process",3,"Up-to-date : nothing to do"<<std::endl);
- bbtkDebugMessage("process",3,
- "<= KWBlackBox::bbBackwardUpdate("
- <<(caller?caller->GetFullName():"0")<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
- return bbGetStatus();
- }
-
- // If the caller's box to is not the box to connected to the
- // output 'Widget'
-
- BlackBox::OutputConnectorMapType::const_iterator i
- = bbGetOutputConnectorMap().find("Widget") ;
- if ( i->second->GetConnectionVector().size() != 0 )
-
- {
- BlackBox::Pointer to =
- i->second->GetConnectionVector()[0]->GetBlackBoxTo();
-
- if (caller)
- {
- bbtkDebugMessage("process",3,
- "-> Output 'Widget' connected to '"
- <<to->bbGetFullName()<<"' - caller->to = '"
- <<caller->GetBlackBoxTo()->bbGetFullName()
- <<"'"
- <<std::endl);
- }
- else
- {
- bbtkDebugMessage("process",3,
- "-> Output 'Widget' connected to '"
- <<to->bbGetFullName()<<"'"
- <<std::endl);
- }
- if ((caller==0) ||
- ( (caller!=0) &&
- (caller->GetBlackBoxTo() != to)&&
- (!bbGetUpdateTransferedToParent())&&
- (!to->bbGetExecuting())
- )
- )
- {
- bbtkDebugMessage("process",3,
- " ... Transfering update order to parent"
- <<std::endl);
-
- bbSetUpdateTransferedToParent(true);
- i->second->GetConnectionVector().front() //.lock()
- ->GetBlackBoxTo()->bbExecute(false);
- }
- else
- {
- bbSetUpdateTransferedToParent(false);
- bbtkDebugMessage("process",3,
- " ... No need to transfer to parent"
- <<std::endl);
- }
- }
- /*
-
- // If the caller is not the connection to the output widget
- // and the output 'Widget' is connected then
- // we must execute the parent box
- // but only one time
- // (this is the role of the flag UpdateTransferedToParent)
- if ( (caller==0) ||
- ((caller!=0)&&(caller->GetBlackBoxFromOutput()!="Widget"))
- )
- {
- }
- */
- // call 'standard' BlackBox execution method
- if (!bbGetUpdateTransferedToParent())
- {
- AtomicBlackBox::bbBackwardUpdate(caller);
- }
-
- bbtkDebugMessageDec("process",3,
- "<= KWBlackBox::bbBackwardUpdate() ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- return bbGetStatus();
-
-
- }
-
- //=========================================================================
- void KWBlackBox::bbProcess()
- {
-/*
- if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
- this->bbUserProcess();
- bbShowWindow();
- // this->bbUserOnShow();
-*/
- this->bbUserProcess();
-
- // If output widget not connected create the window
- if ( (*bbGetOutputConnectorMap().find("Widget")).second
- ->GetConnectionVector().size() == 0 )
- {
- Window* show = 0;
- // If the window already exists : no need creating it
- if (bbGetWindow()!=0)
- {
- bbtkDebugMessage("kw",2,
- "-> Window already exists"
- <<std::endl);
- show = bbGetWindow();
- }
- // Else create window
- else
- {
- bbtkDebugMessage("kw",2,
- "-> Creating the window"
- <<std::endl);
- KW::GetApplication();
-
- // Input WinDialog set to true : creating a Dialog
- /*
- if (bbGetInputWinDialog())
- {
- bbtkDebugMessage("kw",2,
- " Input WinDialog set to true : creating a Dialog"
- <<std::endl);
- */
- vtkKWBlackBoxDialog* win = vtkKWBlackBoxDialog::New();
- show = (Window*) win;
- win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
- //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='"<<win->GetTclName()<<"'"<<std::endl;
-
- bbUserCreateWidget(win);
- KW::GetApplication()->Script("pack %s -side left -anchor c -expand y",
- bbGetOutputWidget()->GetWidgetName());
- /*
- bbGetOutputWidget()->SetParent(win);
- bbGetOutputWidget()->Create();
- KW::GetApplication()->Script("pack %s -side left -anchor c -expand y",
-
- //"pack %s -side top -anchor nw -expand y -fill none -padx 2 -pady 2",
- bbGetOutputWidget()->GetWidgetName());
- */
- /*
- }
-
- // Input WinDialog set to false : creating a Frame
- else
- {
- bbtkDebugMessage("process",2,
- " Input WinDialog set to false : creating a Frame"
- <<std::endl);
- vtkKWBlackBoxFrame* win = vtkKWBlackBoxFrame::New();
- show = (Window*) win;
- win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
- // win->SetName( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN" );
- // win->SetWidth( bbGetInputWinWidth() );
- // win->SetHeight( bbGetInputWinHeight() );
- KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
- win->Create();
-
- bbGetOutputWidget()->SetParent(win);
- bbGetOutputWidget()->Create();
- KW::GetApplication()->Script("pack %s -side top -anchor nw -expand y -fill none -padx 2 -pady 2",
- bbGetOutputWidget()->GetWidgetName()); }
- */
-
- // win->Invoke();
- }
-
- // Show the window
-
- show->bbShow();
- KW::GetApplication()->Start();
-
- }
- //
-
- }
- //=========================================================================
-
-
- /*
- // LG 24/11/08 : New widget pipeline
- void KWBlackBox::bbCreateWidgetAndEventHandler(vtkKWWidget* parent)
- {
- if (bbGetOutputWidget()==0)
- {
- this->bbUserCreateWidget(parent);
- }
-
- // If Event Handler for the widget does not exist or is obsolete : create it
-
- if (bbGetOutputWidget()!=0)
- {
- if (bbGetWidgetEventHandler()==0)
- {
- bbtkDebugMessage("kw",3,
- "-> No widget event handler : creating one"
- <<std::endl);
- new KWBlackBoxWidgetEventHandler(GetThisPointer<KWBlackBox>(),
- bbGetOutputWidget());
- }
- else if ( ! bbGetWidgetEventHandler()->IsHandlerOf
- ( bbGetOutputWidget() ) )
- {
- bbtkDebugMessage("kw",3,
- "-> Obsolete widget event handler : re-creating one"
- <<std::endl);
- delete bbGetWidgetEventHandler();
- new KWBlackBoxWidgetEventHandler(GetThisPointer<KWBlackBox>(),
- bbGetOutputWidget());
- }
- // Sets the name of the vtkKWWidget to the input WinTitle
- bbGetOutputWidget()->SetName(bbtk::std2kw(bbGetInputWinTitle()));
- }
-
- }
-
- */
-
- vtkKWWidget* KWBlackBox::bbCreateWidgetOfInput(const std::string& in, vtkKWWidget* parent)