% ==========================================
-\tableofcontents
+%\tableofcontents
% ==========================================
% ==========================================
\section{Introduction}
% ==========================================
+% ==========================================
+\section{The library architecture}
+% ==========================================
+
+% ==========================================
+\subsection{BlackBox and related classes}
+% ==========================================
+
+% ==========================================
+\subsection{Factory and Package}
+% ==========================================
+
+% ==========================================
+\subsection{Interpreter, VirtualExec, Executer and Transcriptor}
+% ==========================================
+
+% ==========================================
+\subsection{WxGUI elements}
+% ==========================================
+
+% ==========================================
+\subsection{Utilities}
+% ==========================================
+
% ==========================================
\section{Pipeline processing algorithm}
% ==========================================
The status of an output is stored by the class BlackBoxOutputConnector.
If a box output 'O' is connected to another box input 'I' then there are some consistency constraints on their I/O statuses:
-\begin{itemize}
-\item If 'I' is UPTODATE then 'O' is necesseraly UPTODATE
-\item If 'I' is MODIFIED then 'O' is necesseraly UPTODATE
-\item If 'I' is OUTOFDATE then 'O' can be in any Status (The case 'O' is UPTODATE occurs for example when the amont box was created and executed - hence setting its outputs UPTODATE - *BEFORE* being connected to the aval box)
-\item If 'O' is UPTODATE then 'I' can be in any Status
-\item If 'O' is OUTOFDATE then 'I' is necessarly OUTOFDATE
-\end{itemize}
+
+\begin{tabular}{|l|p{10cm}|}
+\hline
+If & then \\ \hline
+'I' is UPTODATE & 'O' is necesseraly UPTODATE\\
+'I' is MODIFIED & 'O' is necesseraly UPTODATE\\
+'I' is OUTOFDATE & 'O' can be in any Status (The case 'O' is UPTODATE occurs for example when the amont box was created and executed - hence setting its outputs UPTODATE - *BEFORE* being connected to the aval box)\\ \hline
+'O' is UPTODATE & 'I' can be in any Status\\
+'O' is OUTOFDATE & 'I' is necessarly OUTOFDATE\\ \hline
+\end{tabular}
The status of an input can be modified:
\begin{itemize}
\item By BlackBox::bbSetStatusAndPropagate which is called by:
\begin{itemize}
-\item BlackBox::bbSetInput : it is set to MODIFIED
-\item BlackBox::bbSignalOutputModification
-\item BlackBox::bbConnectInput which is called when a Connection is connected to the input : it is set to OUTOFDATE
-\item Connection::OnOutputChange
+\item BlackBox::bbSetInput when a new value of an input is set.
+\item BlackBox::bbSignalOutputModification when the output which is connected to it is signaled as modified.
+\item BlackBox::bbConnectInput which is called when a Connection is connected to the input.
+\item Connection::OnOutputChange
\end{itemize}
-\item By BlackBox::bbComputePostProcessStatus which is called after bbProcess in AtomicBlackBox::bbBackwardUpdate : if the input status is MODIFIED then it is changed to UPTODATE.
-\item By Connection::BackwardUpdate which is responsible for updating its amont box, transfering the output value to the input and updating the input status. If, after processing the amont box, the output status is UPTODATE then the new input status is MODIFIED, else if the output status is OUTOFDATE then the new input status is OUTOFDATE.
+\item By BlackBox::bbComputePostProcessStatus which is called after bbProcess in BlackBox::bbRecursiveExecute.
+\item By Connection::RecursiveExecute which is responsible for updating its amont box, transfering the output value to the input and updating the input status.
\end{itemize}
-The status of an output is modifed in:
+The status of an output can be modifed in:
\begin{itemize}
\item By BlackBox::bbSetStatusAndPropagate, when propagating the new input status to the outputs.
-\item By BlackBox::bbComputePostProcessStatus, which is called after bbProcess in AtomicBlackBox::bbBackwardUpdate. The new output status is :
-\begin{itemize}
-\item UPTODATE if all the box inputs are UPTODATE and the BoxProcessMode is *NOT* 'Always'
-\item OUTOFDATE in other cases
-\end{itemize}
+\item By BlackBox::bbComputePostProcessStatus, which is called after bbProcess in BlackBox::bbRecursiveExecute.
\end{itemize}
+
% ==========================================
\subsection{Pipeline execution}
% ==========================================
bbExecute checks werther the box is not already executing (bbGetExecuting())
to prevent reentrance and
checks werther the execution is not frozen (bbGlobalGetFreezeExecution()).
-If it is not the case then it calls bbBackwardUpdate which is
-the main recursive pipeline processing method of a box, giving it a
-NULL Connection::Pointer.
-
-bbBackwardUpdate is defined in AtomicBlackBox:
-
+If it is not the case then it calls bbRecursiveExecute which is
+the main recursive pipeline processing method of a box.
+
+bbRecursiveExecute does:
+\begin{enumerate}
+\item Update the inputs of the box calling bbUpdateInputs
+\item If at least one input is MODIFIED or OUTOFDATE or the
+BoxProcessMode is 'Always' then it:
+\begin{enumerate}
+\item Calls the virtual method bbProcess
+which is responsible for the actual box processing.
+bbProcess is overloaded in AtomicBlackBox to call a user defined method
+and in widget box descendents (WxBlackBox, KWBlackBox) to handle
+the widget creation.
+\item Compute the post-process statuses of inputs and outputs calling
+bbComputePostProcessStatus.
+\end{enumerate}
+\end{enumerate}
\bigskip\hrule\begin{verbatim}
-void AtomicBlackBox::bbBackwardUpdate ( Connection::Pointer caller )
+void BlackBox::bbRecursiveExecute ( Connection::Pointer caller )
{
// Updates the box inputs. Returns the max input IOStatus after update
IOStatus s = bbUpdateInputs();
// If at least one input is modified or BoxProcessMode=='Always'
if ( (s != UPTODATE) || bbBoxProcessModeIsAlways() )
{
- // User process
+ // User process (virtual)
bbProcess();
- // Displays the window (overloaded in widget Blackboxes, WxBlackBox, KWBlackBox, etc.)
- bbShowWindow(caller);
// Compute the final status of inputs and outputs
bbComputePostProcessStatus();
}
}
\end{verbatim}\hrule\bigskip
-bbUpdateInputs iterates over the InputConnector of the box and
-calls BackwardUpdate on each one. It returns the max of the final
-status of the input connectors:
+bbUpdateInputs iterates the InputConnectorMap of the box and
+calls RecursiveExecute on each BlackBoxInputConnector.
+It returns the max of the final status of the input connectors:
\bigskip\hrule\begin{verbatim}
IOStatus BlackBox::bbUpdateInputs()
{
for ( i = bbGetInputConnectorMap().begin();
i!= bbGetInputConnectorMap().end(); ++i)
{
- i->second->BackwardUpdate();
+ i->second->RecursiveExecute();
IOStatus t = i->second->GetStatus();
if (t > s) s = t;
}
return s;
+}
+\end{verbatim}\hrule\bigskip
+
+bbComputPostProcessStatus computes the new status of inputs and outputs
+after box processing.
+
+The input status update rules are simple:
+\begin{tabular}{|lll|}
+\hline
+UPTODATE & remains & UPTODATE\\ \hline
+MODIFIED & becomes & UPTODATE\\ \hline
+OUTOFDATE & remains & OUTOFDATE\\ \hline
+\end{tabular}
+
+The new output status is:
+
+\begin{tabular}{|ll|}
+\hline
+OUTOFDATE & if any input is OUTOFDATE\\
+& or bbBoxProcessModeIsAlways() is true\\ \hline
+UPTODATE & in any other case\\ \hline
+\end{tabular}
+
+\bigskip\hrule\begin{verbatim}
+void BlackBox::bbComputePostProcessStatus()
+{
+ // A priori, the new output status is UPTODATE
+ // except if the BoxProcessMode is always
+ IOStatus new_output_status = UPTODATE;
+ if (bbBoxProcessModeIsAlways()) new_output_status = OUTOFDATE;
+
+ // Update the input statuses
+ InputConnectorMapType::iterator i;
+ for ( i = bbGetInputConnectorMap().begin();
+ i!= bbGetInputConnectorMap().end(); ++i)
+ {
+ IOStatus t = i->second->GetStatus();
+ // If any input is OUTOFDATE then the outputs also are
+ if (t == OUTOFDATE) new_output_status = OUTOFDATE;
+ // A previously MODIFIED status turns to UPTODATE
+ if (t==MODIFIED) i->second->SetStatus(UPTODATE);
+ }
+
+ // Update the output statuses
+ OutputConnectorMapType::iterator o;
+ for ( o = bbGetOutputConnectorMap().begin();
+ o!= bbGetOutputConnectorMap().end(); ++o)
+ {
+ o->second->SetStatus(new_output_status);
+ }
}
\end{verbatim}\hrule\bigskip
+
+BlackBox::bbUpdateInputs may calls BlackBoxInputConnector::RecursiveExecute
+which is responsible for recursive update of the input value.
+If it is connected and its status is OUTOFDATE then it calls
+RecursiveExecute on the Connection which is plugged into:
\bigskip\hrule\begin{verbatim}
-void BlackBoxInputConnector::BackwardUpdate()
+void BlackBoxInputConnector::RecursiveExecute()
{
// If connected and OUTOFDATE : recursive update
// Post-update status is updated by the connection
// (either MODIFIED or OUTOFDATE)
if ( mConnection && (mStatus == OUTOFDATE) )
{
- mConnection->BackwardUpdate();
+ mConnection->RecursiveExecute();
}
}
\end{verbatim}\hrule\bigskip
+Connection::RecursiveExecute does:
+\begin{enumerate}
+\item Call bbRecursiveExecute on the initial box of the connection
+\item Transfer the data from the initial box output to the final box input, adpating it if needed (add crossref).
+\item Update the final box input status. It sets it to:
+
+\begin{tabular}{lll}
+MODIFIED & If the initial box output is & UPTODATE \\
+OUTOFDATE & If the initial box output is & OUTOFDATE
+\end{tabular}
+\end{enumerate}
+
\bigskip\hrule\begin{verbatim}
-void Connection::BackwardUpdate()
+void Connection::RecursiveExecute()
{
- // Calls bbBackwardUpdate on the initial box
- mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
+ // Calls bbRecursiveExecute on the initial box
+ mFrom->bbRecursiveExecute(GetThisPointer<Connection>());
// Transfers the data from the initial box output to the
// final box input adapting it if necessary
TransferData();
}
\end{verbatim}\hrule\bigskip
+% ==========================================
+\subsection{The main processing method (bbProcess) overloads}
+% ==========================================
+
+BlackBox::bbProcess
+
+
% ==========================================
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/08 12:53:35 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2008/12/11 09:50:34 $
+ Version: $Revision: 1.12 $
=========================================================================*/
/* ---------------------------------------------------------------------
- //=========================================================================
- /// Main processing method of the box.
- void AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
- {
- bbtkDebugMessageInc("process",3,
- "=> AtomicBlackBox::bbBackwardUpdate("
- <<(caller?caller->GetFullName():"0")<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- // If already executing : return
- if (bbGetExecuting())
- {
- bbtkDebugMessage("process",3,
- " -> already executing : returning"<<std::endl);
- return;
- }
-
- bbSetExecuting(true);
- bool wasExecuting = bbGlobalGetSomeBoxExecuting();
- bbGlobalSetSomeBoxExecuting(true);
-
- // Updates its inputs
- IOStatus s = bbUpdateInputs();
-
- if ( (s != UPTODATE) ||
- bbBoxProcessModeIsAlways() )
- {
- // User process
- bbProcess();
-
- // Displays the window (WxBlackbox)
- bbShowWindow(caller);
-
- // Update the I/O statuses
- bbComputePostProcessStatus();
- }
- else
- {
- bbtkDebugMessage("process",5," -> Up-to-date : nothing to do"
- <<std::endl);
- }
-
- bbtkDebugMessage("process",3,
- "<= AtomicBlackBox::bbBackwardUpdate() ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- bbSetExecuting(false);
- bbGlobalSetSomeBoxExecuting(wasExecuting);
-
- return; // bbGetStatus();
-
- }
- //=========================================================================
-
//=========================================================================
Data AtomicBlackBox::bbGetOutput( const std::string &name )
{
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBox.h,v $
Language: C++
- Date: $Date: 2008/12/08 12:53:39 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2008/12/11 09:50:34 $
+ Version: $Revision: 1.8 $
=========================================================================*/
/* ---------------------------------------------------------------------
/**
* \file
- * \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes).
+ * \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. ComplexBlackBox objects which are made up of other (atomic or complex) boxes).
*/
/**
{
return bbmDescriptorPointer;
}
+ //==================================================================
+
//==================================================================
/// Gets the output Data of a given label
Data bbGetOutput( const std::string &label );
/// Constructor from an existing box (copy) with a new instance name
AtomicBlackBox(AtomicBlackBox& from, const std::string &name,
bool alloc = true);
- //==================================================================
- //==================================================================
/// Destructor
virtual ~AtomicBlackBox();
- //==================================================================
-
- //==================================================================
- protected:
+ ///
virtual void bbLockDescriptor() = 0;
- // private:
- // virtual void bbReleaseDescriptor();
- //==================================================================
-
- public:
- //==================================================================
- /// Recursive pipeline processing in backward direction
- /// (recursion is in backward direction however execution always goes forward).
- /// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on amont boxes if needed)
- /// - if the return value of bbUpdateInputs is not UPTODATE
- /// - calls bbProcess
- /// - calls bbComputePostProcessStatus
- virtual void bbBackwardUpdate(Connection::Pointer caller);
//==================================================================
//==================================================================
- protected:
- //==================================================================
/// Calls the user defined processing method.
/// Overloaded in WxBlackBox to handle widget creation and show
virtual void bbProcess() { this->bbUserProcess(); }
//==================================================================
/// User callback which computes the outputs as a function of the inputs.
- /// It is assumed to be deterministic and thus is only called is the inputs have changed
- /// (i.e. if the black box is marked as modified)
+ /// It is assumed to be deterministic and thus is only called
+ /// if the inputs have changed
virtual void bbUserProcess()
{
bbtkWarning("AtomicBlackBox::bbUserProcess() not overloaded for box '"
};
// Class AtomicBlackBox
- //===========================================================================
-
+ //====================================================================
}
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/10 09:33:18 $
- Version: $Revision: 1.36 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.37 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=========================================================================
- //=========================================================================
- /// Main processing method of the box.
- void BlackBox::bbExecute(bool force)
- {
- bbtkDebugMessageInc("process",2,
- "=> BlackBox::bbExecute("<<(int)force<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- // If already executing : return
- if (bbGetExecuting())
- {
- bbtkDebugMessage("process",2,
- " -> already executing : bailing out"<<std::endl);
- return;
- }
-
- // If execution frozen : return
- if (bbGlobalGetFreezeExecution())
- {
- bbtkDebugMessage("process",2,
- " -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
- }
-
- BBTK_BUSY_CURSOR;
-
- // If force is true then update is triggered even if the box is UPTODATE
- // if (force) bbSetModifiedStatus();
-
- // Calls the main recursive update method
- bbBackwardUpdate(Connection::Pointer());
-
- bbtkDebugMessageDec("process",2,
- "<= BlackBox::bbExecute() ["
- <<bbGetFullName()<<"]"<<std::endl);
- }
- //=========================================================================
//=========================================================================
std::string BlackBox::bbGetFullName() const
}
//=========================================================================
+
+
+
+
+
+
+ //=========================================================================
+ /// Main processing method of the box.
+ void BlackBox::bbExecute(bool force)
+ {
+ bbtkDebugMessageInc("process",2,
+ "=> BlackBox::bbExecute("<<(int)force<<") ["
+ <<bbGetFullName()<<"]"<<std::endl);
+
+ // If already executing : return
+ /*
+ if (bbGetExecuting())
+ {
+ bbtkDebugMessage("process",2,
+ " -> already executing : abort"<<std::endl);
+ return;
+ }
+ */
+
+ // If execution frozen : return
+ if (bbGlobalGetFreezeExecution())
+ {
+ bbtkDebugMessage("process",2,
+ " -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
+ }
+
+ BBTK_BUSY_CURSOR;
+
+ // If force is true then update is triggered even if the box is UPTODATE
+ // if (force) bbSetModifiedStatus();
+
+ // Calls the main recursive execution method
+ bbRecursiveExecute(Connection::Pointer());
+
+ bbtkDebugMessageDec("process",2,
+ "<= BlackBox::bbExecute() ["
+ <<bbGetFullName()<<"]"<<std::endl);
+ }
+ //=========================================================================
+
+
+ //=========================================================================
+ /// Main recursive processing method of the box.
+ void BlackBox::bbRecursiveExecute( Connection::Pointer caller )
+ {
+ bbtkDebugMessageInc("process",3,
+ "=> BlackBox::bbRecursiveExecute("
+ <<(caller?caller->GetFullName():"0")<<") ["
+ <<bbGetFullName()<<"]"<<std::endl);
+
+ // If already executing : return
+ if (bbGetExecuting())
+ {
+ bbtkDebugMessage("process",3,
+ " -> already executing : abort"<<std::endl);
+ return;
+ }
+
+ bbSetExecuting(true);
+ bool wasExecuting = bbGlobalGetSomeBoxExecuting();
+ bbGlobalSetSomeBoxExecuting(true);
+
+ // Updates its inputs
+ IOStatus s = bbUpdateInputs();
+
+ if ( (s != UPTODATE) ||
+ bbBoxProcessModeIsAlways() )
+ {
+ // Displays the window (WxBlackbox)
+ // bbShowWindow(caller);
+
+ // Actual processing (virtual)
+ this->bbProcess();
+
+
+ // Update the I/O statuses
+ bbComputePostProcessStatus();
+ }
+ else
+ {
+ // Test output status...
+ OutputConnectorMapType::iterator o;
+ for ( o = bbGetOutputConnectorMap().begin();
+ o!= bbGetOutputConnectorMap().end(); ++o)
+ {
+ if (o->second->GetStatus() != UPTODATE)
+ {
+ bbtkWarning("BlackBox::bbRecursiveExecute ["
+ <<bbGetFullName()
+ <<"] : all inputs are Up-to-date but output '"
+ <<o->first<<"' is Out-of-date ???");
+ }
+ }
+
+ bbtkDebugMessage("process",3," -> Up-to-date : nothing to do"
+ <<std::endl);
+ }
+
+ bbtkDebugMessage("process",3,
+ "<= BlackBox::bbRecursiveExecute() ["
+ <<bbGetFullName()<<"]"<<std::endl);
+
+ bbSetExecuting(false);
+ bbGlobalSetSomeBoxExecuting(wasExecuting);
+
+ return;
+
+ }
+ //=========================================================================
+
+
+
+
+
//=========================================================================
/// Updates the BlackBox inputs
- /// Calls BackwardUpdate on all BlackBoxInputConnector
+ /// Calls RecursiveExecute on all BlackBoxInputConnector
/// \returns The maximum of final IOStatus after each input update
IOStatus BlackBox::bbUpdateInputs()
{
<<" status before update = '"
<<GetIOStatusString(i->second->GetStatus())
<<"'"<<std::endl);
- i->second->BackwardUpdate();
+ i->second->RecursiveExecute();
IOStatus t = i->second->GetStatus();
if (t > s) s = t;
bbtkDebugMessageDec("change",2,
Program: bbtk
Module: $RCSfile: bbtkBlackBox.h,v $
Language: C++
- Date: $Date: 2008/12/10 09:33:18 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.21 $
=========================================================================*/
/* ---------------------------------------------------------------------
class BlackBoxOutputConnector;
-#define BBTK_MAKE_OUTPUT_OBSERVER(OBJECT,METHOD) \
- boost::bind( METHOD, OBJECT, _1, _2, _3)
class BBTK_EXPORT BlackBox : public Object
{
virtual void bbExecute(bool force = false);
- /// The type of callback function when an output changes
- // typedef BlackBoxOutputConnector::ChangeCallbackType OutputChangeCallbackType;
-
- /// Adds the function f to the list of functions to call when
- /// the output changes.
- /// f is of type ChangeCallbackType which is basically:
- /// void (*ChangeCallbackType)(bbtk::BlackBox::Pointer,
- /// const std::string&,
- /// bbtk::IOStatus)
- /// To pass a member function 'f' of an instance 'c' of a class 'C'
- /// as callback you have to 'bind' it, i.e. call:
- /// bbAddOutputObserver ( "Out", boost::bind( &C::f , c, _1, _2, _3 ) );
- /// The convenience macro BBTK_BIND_OUTPUT_OBSERVER ( c, C::f ) does it for you
- void bbAddOutputObserver(const std::string& output_name,
- OutputChangeCallbackType f);
-
- /// Removes the function f from the list of functions to call when
- /// the output changes (TO WRITE)
- void bbRemoveOutputObserver(const std::string& output_name,
- OutputChangeCallbackType f);
-
-
- /// Signals that the BlackBox outputs have been modified
- /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
- /// This method should be used by widgets in response
- /// to user interaction when **ALL** outputs have been modified
- /// (after the outputs has been updated !).
- /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
- /// ** USER INTENDED **
- virtual void bbSignalOutputModification(bool reaction = true);
- /// Signals that the BlackBox output "output_name" has been modified
- /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
- /// This method should be used by widgets in response to user interaction
- /// only when **ONE** output has been modified
- /// (after the output has been updated !)
- /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
- /// ** USER INTENDED **
- virtual void bbSignalOutputModification( const std::string& output_name,
- bool reaction = true);
- /// Signals that the BlackBox vector of outputs "output_name"
- /// have been modified.
- /// Should be used when more than ONE output is modified but not ALL
- /// (optimization issue).
- /// (without marking the box as MODIFIED because its output state is ok).
- /// This method should be used by widgets in response to user interaction
- /// When more than one output has been changed but not all
- /// (after the outputs have been updated of course!)
- /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
- /// ** USER INTENDED **
- virtual void bbSignalOutputModification( const std::vector<std::string>&
- output_name,
- bool reaction = true);
-
- /// Gets the status of the box
- // virtual const IOStatus& bbGetStatus() const { return bbmStatus; }
+
+
/// Returns true iff the BlackBox has an input of name label
/// Prints the Help on the BlackBox type
virtual void bbGetHelp(bool full=true) const;
+ //==================================================================
+ /// Adds the function f to the list of functions to call when
+ /// the output changes.
+ /// f is of type ChangeCallbackType which is basically:
+ /// void (*ChangeCallbackType)(bbtk::BlackBox::Pointer,
+ /// const std::string&,
+ /// bbtk::IOStatus)
+ /// To pass a member function 'f' of an instance 'c' of a class 'C'
+ /// as callback you have to 'bind' it, i.e. call:
+ /// bbAddOutputObserver ( "Out", boost::bind( &C::f , c, _1, _2, _3 ) );
+ /// The convenience macro BBTK_BIND_OUTPUT_OBSERVER ( c, C::f ) does it for you
+ void bbAddOutputObserver(const std::string& output_name,
+ OutputChangeCallbackType f);
+
+ /// Removes the function f from the list of functions to call when
+ /// the output changes (TO WRITE)
+ void bbRemoveOutputObserver(const std::string& output_name,
+ OutputChangeCallbackType f);
+ //==================================================================
+
+
+ //==================================================================
+ /// Signals that the BlackBox outputs have been modified
+ /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
+ /// This method should be used by widgets in response
+ /// to user interaction when **ALL** outputs have been modified
+ /// (after the outputs has been updated !).
+ /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+ /// ** USER INTENDED **
+ virtual void bbSignalOutputModification(bool reaction = true);
+ /// Signals that the BlackBox output "output_name" has been modified
+ /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
+ /// This method should be used by widgets in response to user interaction
+ /// only when **ONE** output has been modified
+ /// (after the output has been updated !)
+ /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+ /// ** USER INTENDED **
+ virtual void bbSignalOutputModification( const std::string& output_name,
+ bool reaction = true);
+ /// Signals that the BlackBox vector of outputs "output_name"
+ /// have been modified.
+ /// Should be used when more than ONE output is modified but not ALL
+ /// (optimization issue).
+ /// (without marking the box as MODIFIED because its output state is ok).
+ /// This method should be used by widgets in response to user interaction
+ /// When more than one output has been changed but not all
+ /// (after the outputs have been updated of course!)
+ /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+ /// ** USER INTENDED **
+ virtual void bbSignalOutputModification( const std::vector<std::string>&
+ output_name,
+ bool reaction = true);
+ //==================================================================
+
- // Returns true iff the box is up-to-date
- // (ChangeTime of inputs are all lower strictly to ChangeTime of outputs -
- // i.e. max(inputs)<=min(outputs) )
- // bool bbIsUpToDate() { return mMaxInputChangeTime < mMinOutputChangeTime; }
- // Returns true iff the box is out-of-date
- // (At least one ChangeTime of an input is greater than one ChangeTime
- // of an output - i.e. max(inputs)>min(outputs))
- // == !IsUpToDate()
- // bool bbIsOutOfDate() { return mMaxInputChangeTime >= mMinOutputChangeTime; }
//==================================================================
// Common inputs / outputs to all boxes
protected:
/// @name Pipeline processing methods
/// Methods which participate to pipeline processing.
- /// Some are pure virtual and prepare particular update mechanism which are implemented by descendents
- /// The main method is bbBackwardUpdate which is called by bbExecute and implemented in UserBlackBox and ComplexBlackBox.
- ///
//@{
//==================================================================
- /// Recursive pipeline processing in backward direction
- /// (recursion is in backward direction however execution always
- /// goes forward).
- /// Pure virtual; defined in AtomicBlackBox and ComplexBlackBox
+ /// Recursive execution method
///
/// \param caller : The connection which invoked the method; null if called by bbExecute
- virtual void bbBackwardUpdate(Connection::Pointer caller) = 0;
+ virtual void bbRecursiveExecute(Connection::Pointer caller);
//==================================================================
//==================================================================
/// Updates the BlackBox inputs
- /// Calls BackwardUpdate on all BlackBoxInputConnector
+ /// Calls RecursiveExecute on all BlackBoxInputConnector
/// \returns The maximum of final IOStatus after each input update
IOStatus bbUpdateInputs();
//==================================================================
+ //==================================================================
+ /// Actual processing method (vitual)
+ /// Overloaded in AtomicBlacBox and descendants
+ virtual void bbProcess()
+ {
+ bbtkError("BlackBox::bbProcess called : how can this happen ?");
+// this->bbUserProcess();
+ }
+ //==================================================================
+
//==================================================================
/// Computes the final IOStatus of inputs and outputs after processing
void bbComputePostProcessStatus();
/// Shows the window associated to the box
/// (called after bbProcess during bbExecute)
/// Does nothing here but overloaded in WxBlackBox and WxContainerBlackBox
- virtual void bbShowWindow(Connection::Pointer caller) { }
-
- virtual void bbHideWindow() {}
- virtual void bbCloseWindow() { }
- //==================================================================
+ // virtual void bbShowWindow(Connection::Pointer caller) { }
+ // virtual void bbHideWindow() {}
+ // virtual void bbCloseWindow() { }
+ //==================================================================
//@}
public:
//==================================================================
// ATTRIBUTES
- /// The status of the box
- // IOStatus bbmStatus;
/// Is the box executing ?
bool bbmExecuting;
/// The name of the black-box
InputConnectorMapType mInputConnectorMap;
//==================================================================
- /// The maximum ChangeTime of the inputs
- // ChangeTime mMaxInputChangeTime;
- /// The minimum ChangeTime of the outputs
- // ChangeTime mMinOutputChangeTime;
-
-
- protected:
- //=========================================================================
- /// Sets the ChangeTime of input
- /*
- void bbSetInputChangeTime(BlackBoxInputConnector* c,
- const ChangeTime& t);
- /// Sets the ChangeTime of output
- void bbSetOutputChangeTime(BlackBoxOutputConnector* c,
- const ChangeTime& t);
- */
- // void bbUpdateMaxInputChangeTime(const ChangeTime& t);
- // void bbUpdateMinOutputChangeTime(const ChangeTime& t);
-
- /// Set the change time of the input
- // void bbSetInputChangeTime(const std::string& n, ChangeTime);
- /// Set the change time of the output
- // void bbSetOutputChangeTime(const std::string& n, ChangeTime);
-
-
};
// Class BlackBox
+ /// Convenient macro to create output observer callbacks (freehand functions) from object and method pointer (see samples/SampleOutputObserver)
+#define BBTK_MAKE_OUTPUT_OBSERVER(OBJECT,METHOD) \
+ boost::bind( METHOD, OBJECT, _1, _2, _3)
Program: bbtk
Module: $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
Language: C++
- Date: $Date: 2008/12/09 11:48:31 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.9 $
=========================================================================*/
/* ---------------------------------------------------------------------
//========================================================================
//========================================================================
- void BlackBoxInputConnector::BackwardUpdate()
+ void BlackBoxInputConnector::RecursiveExecute()
{
-
- // If UPTODATE or MODIFIED : nothing to do
- // if (mStatus != OUTOFDATE) return;
-
// If connected and OUTOFDATE : recursive update
// Post-update status is updated by the connection
// (either MODIFIED or OUTOFDATE)
if ( mConnection && (mStatus == OUTOFDATE) )
{
- bbtkDebugMessage("process",9,
- "==> BlackBoxInputConnector::BackwardUpdate() : "
- <<"calling connection BackwardUpdate"
- <<std::endl);
- mConnection->BackwardUpdate();
+ mConnection->RecursiveExecute();
}
else
{
- bbtkDebugMessage("process",9,
- "==> BlackBoxInputConnector::BackwardUpdate() : "
- <<"input Up-to-date or Modified : nothing to do"
+ bbtkDebugMessage("process",5,
+ "--> BlackBoxInputConnector::RecursiveExecute() : "
+ <<"No connection or input not Out-of-date : nothing to do"
<<std::endl);
}
- // If not connected : it was set to OUTOFDATE on creation
- // Becomes MODIFIED
- // LGTODO : Initialize to MODIFIED and set to OUTOFDATE on connection ?
- // else
- // {
- // mStatus = MODIFIED;
- // }
}
//========================================================================
Program: bbtk
Module: $RCSfile: bbtkBlackBoxInputConnector.h,v $
Language: C++
- Date: $Date: 2008/12/08 13:05:59 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
/// The parameter is USELESS today but would be useful if we allow multiple connections on inputs
void UnsetConnection(Connection* c);
- // IOStatus
- void BackwardUpdate();
-
- /// Returns the ChangeTime of the output (const)
- // const ChangeTime& GetChangeTime() const { return mChangeTime; }
- /// Returns the ChangeTime of the output
- // ChangeTime& GetChangeTime() { return mChangeTime; }
- // bool SetChangeTime(const ChangeTime& t) { return mChangeTime.Set(t); }
+ // Recursive execution
+ void RecursiveExecute();
/// Returns the connection plugged into this input (const)
Connection* GetConnection() const { return mConnection; }
/// The status of the input (UPTODATE | MODIFIED | OUTOFDATE)
IOStatus mStatus;
- // The change time
- // ChangeTime mChangeTime;
-
- /*
- /// Returns the TimeStamp
- const TimeStamp& GetTimeStamp() const { return mTimeStamp;}
- TimeStamp& GetTimeStamp() { return mTimeStamp;}
- /// Set the connector to MODIFIED status and increments the time stamp
- void SetModified()
- { mStatus = MODIFIED; mTimeStamp.Modified(); }
- /// The TimeStamp
- TimeStamp mTimeStamp;
- */
};
}
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/08 12:54:09 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.23 $
=========================================================================*/
/* ---------------------------------------------------------------------
}
//==================================================================
- /*
- //==================================================================
- void ComplexBlackBox::bbSetModifiedStatus(BlackBoxInputConnector* c)
- {
- bbtkDebugMessage("modified",1,
- "==> ComplexBlackBox::bbSetModifiedStatus("
- <<c<<") ["<<bbGetFullName()<<"]"<<std::endl);
-
- c->GetBlackBox()->bbSetModifiedStatus(c);
-
- }
- //==================================================================
-*/
-
//==================================================================
void ComplexBlackBox::bbAddToExecutionList( const std::string& name )
{
- bbtkDebugMessageInc("Kernel",9,
+ bbtkDebugMessageInc("Kernel",9,
"ComplexBlackBox::bbAddToExecutionList(\""
<<name<<"\") ["
<<bbGetFullName()<<"]"<<std::endl);
-
- mExecutionList.push_back( name );
-
- bbtkDebugDecTab("Kernel",9);
-
- }
- //==================================================================
-
- //==================================================================
- void ComplexBlackBox::bbBackwardUpdate(Connection::Pointer caller)
- {
- bbtkDebugMessageInc("process",3,
- "==> ComplexBlackBox::bbBackwardUpdate("
- <<(caller?caller->GetFullName():"0")<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
- // bbtkInternalError("ComplexBlackBox::bbBackwardUpdate should never be called !");
- if (caller==0)
- {
- bbtkInternalError("ComplexBlackBox::bbBackwardUpdate called with caller=0");
- }
-
- /*
- std::cout << "CBB BUP : "<<caller->GetBlackBoxFrom()->bbGetFullName()
- <<"."<<caller->GetBlackBoxFromOutput()<<"----"
- <<caller->GetOriginalBlackBoxFrom()->bbGetFullName()
- <<"."<<caller->GetOriginalBlackBoxFromOutput()<<std::endl;
- */
-
-
-
- // IOStatus s = UPTODATE;
- const BlackBoxDescriptor::OutputDescriptorMapType& omap
- = bbGetDescriptor()->GetOutputDescriptorMap();
- BlackBoxDescriptor::OutputDescriptorMapType::const_iterator i
- = omap.find(caller->GetBlackBoxFromOutput());
- if (i!=omap.end())
- {
- // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor
- ComplexBlackBoxOutputDescriptor* d =
- (ComplexBlackBoxOutputDescriptor*)i->second;
- // Get the internal box
- BlackBox::Pointer b = bbUnsafeGetBlackBox ( d->GetTarget() );
- // Calls BackwardUpdate on it
- bbtkDebugMessageInc("process",4,"Internal box connected to output : "<<d->GetTarget()<<std::endl);
- // Because internal box can also be a complex box we have to
- // temporarily change the connection BlackBoxFromOutput to the
- // mapped one
-
- // std::string oldout = caller->GetBlackBoxFromOutput();
- // std::cout << "oldout = "<<oldout<<std::endl;
- // std::cout << "tmpout = "<<d->GetOutput()<<std::endl;
- // caller->SetBlackBoxFromOutput(d->GetOutput());
- //
- //Connection newcaller(*caller);
- //newcaller.SetBlackBoxFromOutput(d->GetOutput());
- //IOStatus s1 = b->bbBackwardUpdate(&newcaller);
- //IOStatus s1 =
- b->bbBackwardUpdate(caller);
- //newcaller.Clear();
- // restore old output
- // caller->SetBlackBoxFromOutput(oldout);
-
- // ??? STATUS OF CBBs ???
- // ??? Here it is only the final status of the boxes connected to the output
- // if (s1==MODIFIED) s=MODIFIED;
- }
- else
- {
- bbtkError("Connection '"<<caller->GetFullName()<<"' does not point to a valid output of the complex box !");
- }
-
- return; // s;
+ mExecutionList.push_back( name );
+
+ bbtkDebugDecTab("Kernel",9);
}
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.h,v $
Language: C++
- Date: $Date: 2008/12/08 12:54:13 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
/// Constructor from an existing box (copy) with a new name
ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
- public:
- //IOStatus
- void bbBackwardUpdate(Connection::Pointer caller);
- // void bbForwardUpdate(Connection* caller);
- // void bbSetModifiedStatus(BlackBoxInputConnector* c);
-
protected:
Program: bbtk
Module: $RCSfile: bbtkConnection.cxx,v $
Language: C++
- Date: $Date: 2008/12/09 11:48:31 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.19 $
=========================================================================*/
/* ---------------------------------------------------------------------
//==================================================================
//==================================================================
- /// Backward Update
- void Connection::BackwardUpdate()
+ /// Recursive execution
+ void Connection::RecursiveExecute()
{
- bbtkDebugMessage("process",3,
- "===> Connection::BackwardUpdate() ["
+ bbtkDebugMessage("process",4,
+ "===> Connection::RecursiveExecute() ["
<<GetFullName()<<"]"<<std::endl);
- mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
+ mFrom->bbRecursiveExecute(GetThisPointer<Connection>());
TransferData();
}
mTo->bbGetInputConnector(mInput).SetStatus(s);
- bbtkDebugMessage("process",3,
+ bbtkDebugMessage("process",4,
" --> '"<<mTo->bbGetName()<<"."<<mInput
<<" ["<<&mTo->bbGetInputConnector(mInput)<<"] "
<<"' new status '"
<<"'"
<< std::endl);
- bbtkDebugMessage("process",3,
- "<=== Connection::BackwardUpdate() ["
+ bbtkDebugMessage("process",4,
+ "<=== Connection::RecursiveExecute() ["
<<GetFullName()<<"]"<<std::endl);
- return; // s;
+ return;
}
//==================================================================
- /*
- //==================================================================
- /// Forward Update
- void Connection::ForwardUpdate()
- {
- bbtkDebugMessageInc("process",2,
- "Connection::ForwardUpdate() ["
- <<GetFullName()<<"]"<<std::endl);
-
-
- TransferData();
- mTo->bbForwardUpdate(this);
-
- bbtkDebugDecTab("process",2);
- }
- //==================================================================
- */
//==================================================================
/// Transfers the data from the source output to the target input
}
//==================================================================
-
- /*
- //==================================================================
- /// Modified
- void Connection::SetModifiedStatus()
- {
- bbtkDebugMessage("modified",2,
- "==> Connection::SetModifiedStatus() ["
- <<GetFullName()<<"]"<<std::endl);
-
- if (mAdaptor) mAdaptor->bbSetModifiedStatus();
-
- mTo->bbSetModifiedStatus( mTo->bbGetInputConnectorMap().find(mInput)->second );
-
-
- }
- //==================================================================
- */
+
//==================================================================
/// From.Output change propagation
void Connection::OnOutputChange(bbtk::BlackBox::Pointer, const std::string&,
Program: bbtk
Module: $RCSfile: bbtkConnection.h,v $
Language: C++
- Date: $Date: 2008/12/08 12:54:23 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.11 $
=========================================================================*/
/* ---------------------------------------------------------------------
// void Delete();
/// Pipeline processing method
- /// 1) call bbBackwardUpdate(this) on the from box
+ /// 1) call bbRecursiveExecute(this) on the from box
/// 2) copies the from box output to the to box input
/// adapting it if needed
/// 3) sets the new IOStatus of the to box input to the
/// status of the from box output
- void BackwardUpdate();
+ void RecursiveExecute();
/// Change callback
void OnOutputChange(BlackBoxPointer, const std::string&,
Program: bbtk
Module: $RCSfile: bbtkKWBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/08 12:54:26 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
}
//=========================================================================
- //=========================================================================
- /// 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 )
- {
- bbtkWarning("Execution called on '"<<bbGetFullName()
- <<"' although its Output 'Widget' is connected: "
- <<"if the widget is not created yet then it will not be! "
- <<"Execute the top level Layout widget to create and "
- <<"display the widget.");
- }
-
- AtomicBlackBox::bbExecute(force);
-
- bbtkDebugMessageDec("process",2,
- "<= KWBlackBox::bbExecute() ["
- <<bbGetFullName()<<"]"<<std::endl);
- }
- //=========================================================================
-
//=========================================================================
void KWBlackBox::bbProcess()
{
-/*
- if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
- this->bbUserProcess();
- bbShowWindow();
- // this->bbUserOnShow();
-*/
+
this->bbUserProcess();
// If output widget not connected create the window
Program: bbtk
Module: $RCSfile: bbtkKWBlackBox.h,v $
Language: C++
- Date: $Date: 2008/12/08 12:54:26 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.5 $
========================================================================*/
- //==================================================================
- // Forward declaration of the widget event handler class
- // class KWBlackBoxWidgetEventHandler;
- //==================================================================
-
//==================================================================
/// Widget black boxes
BBTK_DECLARE_OUTPUT(Widget, vtkKWWidget*);
public:
- /// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (as the container window must be created and displayed - this box will be executed by the normal pipeline recursion mechanism)
- virtual void bbExecute(bool force = false);
-
-
+
typedef vtkKWBlackBoxDialog Window;
/// Returns the **OWN** window associated to the box
/// Else returns 0;
Window* bbGetContainingWindow();
- /// Returns the parent wxWindow that must be used to create the widget
- //
- // LG 24/11/08 : New widget pipeline
- // wxWindow* bbGetKWParent();
/// Returns true iff the 'containing window' exists and is shown
/// (see bbGetContainingWindow).
virtual void bbUserOnHide() {}
//==================================================================
- // LG 24/11/08 : New widget pipeline
- // void bbCreateWidgetAndEventHandler(vtkKWWidget* parent);
- /// Sets the window
+ /// Sets the window
inline void bbSetWindow(Window* w) { bbmWindow=w; }
//==================================================================
+ //==================================================================
vtkKWWidget* bbCreateWidgetOfInput(const std::string& in,
vtkKWFrame* parent);
-
-
//==================================================================
- /// Main processing method of the box.
- // virtual void bbBackwardUpdate( Connection::Pointer caller );
- //==================================================================
-
//==================================================================
friend class vtkKWBlackBoxWindow;
// friend class KWBlackBoxWidgetEventHandler;
-
- /*
- /// Sets the Widget Event Handler
- inline void bbSetWidgetEventHandler(KWBlackBoxWidgetEventHandler* w)
- { bbmWidgetEventHandler = w; }
- /// Gets the Widget Event Handler
- inline KWBlackBoxWidgetEventHandler* bbGetWidgetEventHandler()
- { return bbmWidgetEventHandler; }
- */
-
/// The KWBlackBoxWindow associated to the box
Window* bbmWindow;
- /// The KWBlackBoxWidgetEventHandler associated to the box
- // KWBlackBoxWidgetEventHandler* bbmWidgetEventHandler;
void bbInitAttributes();
- protected :
-
- /*
- /// For Forward update mechanism when execution is called
- /// on a contained window
- /// Is set to true before transfering update to parent
- /// in order to not re-transfer a second time...
- bool bbmUpdateTransferedToParent;
-
- bool bbGetUpdateTransferedToParent() const { return bbmUpdateTransferedToParent; }
- void bbSetUpdateTransferedToParent(bool b)
- { bbmUpdateTransferedToParent = b; }
- */
};
//=================================================================
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/08 14:02:15 $
- Version: $Revision: 1.34 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.35 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=========================================================================
- /*
- //=========================================================================
- WxBlackBox::Widget* WxBlackBox::bbGetWidget()
- {
- if (bbGetOutputWidget() && bbGetOutputWidget()->IsDead())
- {
- bbtkDebugMessage("wx",9,"WxBlackBox::bbGetWidget() ["<<
- bbGetFullName()<<"] : Widget is dead : deleting it"
- <<std::endl);
- delete bbGetOutputWidget();
- bbSetOutputWidget(0);
- }
- return bbGetOutputWidget();
- }
- //=========================================================================
- */
-
-
//=========================================================================
/**
* \brief Initialize the attributes of the class
}
//=========================================================================
- //=========================================================================
- /// Main processing method of the box.
- void WxBlackBox::bbExecute(bool force)
- {
-
- bbtkDebugMessageInc("process",2,
- "=> WxBlackBox::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 )
- {
- bbtkWarning("Execution called on '"<<bbGetFullName()
- <<"' although its Output 'Widget' is connected: "
- <<"if the widget is not created yet then it will not be! "
- <<"Execute the top level Layout widget to create and "
- <<"display the widget.");
- }
-*/
- AtomicBlackBox::bbExecute(force);
-
- bbtkDebugMessageDec("process",2,
- "<= WxBlackBox::bbExecute() ["
- <<bbGetFullName()<<"]"<<std::endl);
- }
- //=========================================================================
-
-
//=========================================================================
void WxBlackBox::bbProcess()
{
-/*
- if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
- this->bbUserProcess();
- bbShowWindow();
- // this->bbUserOnShow();
- */
- // LG 22/11/08 : new widget pipeline
- // If output widget not connected :
+ // If output widget not connected : have to create and show the window
if ( (*bbGetOutputConnectorMap().find("Widget")).second
->GetConnectionVector().size() == 0 )
{
"-> Creating the window"
<<std::endl);
-
// Input WinDialog set to true : creating a Dialog
if (bbGetInputWinDialog())
{
" Input WinDialog set to true : creating a Dialog"
<<std::endl);
show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
- // bbGetWxParent(),
- // LG 24/11/08 : New widget pipeline
Wx::GetTopWindow(),
std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
" Input WinDialog set to false : creating a Frame"
<<std::endl);
show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
- // bbGetWxParent(),
- // LG 24/11/08 : New widget pipeline
Wx::GetTopWindow(),
std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
- // LG 24/11/08 : New widget pipeline
+ //=========================================================================
void WxBlackBox::bbCreateWidgetAndEventHandler(wxWindow* parent)
{
if (bbGetOutputWidget()==0)
}
+ //=========================================================================
-
- wxWindow* WxBlackBox::bbCreateWidgetOfInput(const std::string& in, wxWindow* parent)
+ //=========================================================================
+ wxWindow* WxBlackBox::bbCreateWidgetOfInput(const std::string& in,
+ wxWindow* parent)
{
wxWindow* w = 0;
// If input is connected
}
return w;
}
-
- /*
//==================================================================
- /// Specific methods for window creation during pipeline execution
- /// Shows the window associated to the box
- /// (called after bbProcess during bbExecute)
- void WxBlackBox::bbShowWindow()
- {
- bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbShowWindow() ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- // If Event Handler for the widget does not exist or is obsolete : create it
- if (bbGetOutputWidget()!=0)
- {
- if (bbGetWidgetEventHandler()==0)
- {
- bbtkDebugMessage("wx",3,
- "-> No widget event handler : creating one"
- <<std::endl);
- new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
- bbGetOutputWidget());
- }
- else if ( ! bbGetWidgetEventHandler()->IsHandlerOf
- ( bbGetOutputWidget() ) )
- {
- bbtkDebugMessage("wx",3,
- "-> Obsolete widget event handler : re-creating one"
- <<std::endl);
- delete bbGetWidgetEventHandler();
- new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
- bbGetOutputWidget());
- }
- // Sets the name of the wxWindow to the input WinTitle
- bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
- }
-
- // If the output 'Widget' is connected then it's gonna
- // be captured by its parent window : nothing to do
- if ( (*bbGetOutputConnectorMap().find("Widget")).second
- ->GetConnectionVector().size() != 0 )
- {
-
- bbtkDebugMessage("wx",2,
- "-> Output 'Widget' connected : nothing to do"
- <<std::endl);
- return;
- }
-
-
- Window* show = 0;
- // If the window already exists : no need creating it
- if (bbGetWindow()!=0)
- {
- bbtkDebugMessage("wx",2,
- "-> Window already exists"
- <<std::endl);
- show = bbGetWindow();
- }
- // Else if the widget exists : create window
- else if (bbGetOutputWidget()!=0)
- {
- bbtkDebugMessage("wx",2,
- "-> Widget exists : creating the window"
- <<std::endl);
-
-
- // Input WinDialog set to true : creating a Dialog
- if (bbGetInputWinDialog())
- {
- bbtkDebugMessage("wx",2,
- " Input WinDialog set to true : creating a Dialog"
- <<std::endl);
- show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
- // bbGetWxParent(),
- // LG 24/11/08 : New widget pipeline
- Wx::GetTopWindow(),
- std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
- wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
- }
- // Input WinDialog set to false : creating a Frame
- else
- {
- bbtkDebugMessage("process",2,
- " Input WinDialog set to false : creating a Frame"
- <<std::endl);
- show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
- // bbGetWxParent(),
- // LG 24/11/08 : New widget pipeline
- Wx::GetTopWindow(),
- std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
- wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
- }
-
- }
- // No window nor widget : error
- else
- {
- bbtkError("WxBlackBox::bbShowWindow() ["
- <<bbGetFullName()
- <<"] : No widget. Did you set the box output 'Widget' in the processing method of the box ?");
- }
-
-
- // Show the window
- if (true) //!show->IsShown())
- {
- show->bbShow();
- }
- else
- {
- bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<<std::endl);
- }
-
-
- bbtkDebugMessage("wx",2,"<= WxBlackBox::bbShowWindow() ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- }
- //==================================================================
-*/
-
//==================================================================
//==================================================================
- //==================================================================
- // LG 24/11/08 : New widget pipeline
- // wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); }
- //==================================================================
-
-
//==================================================================
bool WxBlackBox::bbIsShown()
{
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.h,v $
Language: C++
- Date: $Date: 2008/12/08 12:54:27 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2008/12/11 09:50:35 $
+ Version: $Revision: 1.23 $
========================================================================*/
public:
/// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (as the container window must be created and displayed - this box will be executed by the normal pipeline recursion mechanism)
- virtual void bbExecute(bool force = false);
+ // virtual void bbExecute(bool force = false);
typedef WxBlackBoxWindow Window;
/// Else returns 0;
Window* bbGetContainingWindow();
- /// Returns the parent wxWindow that must be used to create the widget
- //
- // LG 24/11/08 : New widget pipeline
- // wxWindow* bbGetWxParent();
-
/// Returns true iff the 'containing window' exists and is shown
/// (see bbGetContainingWindow).
bool bbIsShown();
//==================================================================
- // LG 24/11/08 : New widget pipeline
+ //==================================================================
void bbCreateWidgetAndEventHandler(wxWindow* parent);
+ //==================================================================
protected:
//==================================================================
/// User callback for creating the widget associated to the box
/// ** Must be defined **
- // LG 24/11/08 : New widget pipeline
virtual void bbUserCreateWidget(wxWindow* parent)
{
bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?");
wxWindow* bbCreateWidgetOfInput(const std::string& in, wxWindow* parent);
//==================================================================
-
- //==================================================================
- /// Main processing method of the box.
- // No more overloaded
- // virtual void bbBackwardUpdate( Connection::Pointer caller );
- //==================================================================
-
//==================================================================
/// (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();
+ // void bbShowWindow();
/// Hides the WxBlackBoxWindow associated to the box (if exists)
void bbHideWindow();
/// Closes (destroys) the WxBlackBoxWindow associated to the box (if exists)
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.cxx,v $
Language: C++
- Date: $Date: 2008/12/09 15:25:08 $
- Version: $Revision: 1.30 $
+ Date: $Date: 2008/12/11 09:50:38 $
+ Version: $Revision: 1.31 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
- // This callback is *no more*
- // necessary to get actual processing of the view
- // when window is shown
- void Viewer2D::OnShowWidget()
- {
- }
-
}//namespace bbtk
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.h,v $
Language: C++
- Date: $Date: 2008/12/09 15:25:08 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2008/12/11 09:50:38 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
BBTK_DECLARE_OUTPUT(Renderer,vtkRenderer*);
BBTK_PROCESS(Process);
BBTK_CREATE_WIDGET(CreateWidget);
- BBTK_ON_SHOW_WIDGET(OnShowWidget);
+ // BBTK_ON_SHOW_WIDGET(OnShowWidget);
void Process();
void CreateWidget(wxWindow*);
- void OnShowWidget();
+ // void OnShowWidget();
void bbUserConstructor();
};