X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkWidgetBlackBox.txx;h=6f2e8a6de5998b189b36de9868744d7cfa970af7;hb=16993e9f411c62e9a73d13c40f3748bdd232ce09;hp=39738cf6b3032aaebe8689488fb17d7204ac3a5b;hpb=ab0cfcfdd031ff179ed1550874c648a54d8e1023;p=bbtk.git diff --git a/kernel/src/bbtkWidgetBlackBox.txx b/kernel/src/bbtkWidgetBlackBox.txx index 39738cf..6f2e8a6 100644 --- a/kernel/src/bbtkWidgetBlackBox.txx +++ b/kernel/src/bbtkWidgetBlackBox.txx @@ -1,32 +1,40 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + /*========================================================================= Program: bbtk Module: $RCSfile: bbtkWidgetBlackBox.txx,v $ Language: C++ - Date: $Date: 2009/04/21 14:36:51 $ - Version: $Revision: 1.2 $ + Date: $Date: 2012/11/16 08:49:01 $ + Version: $Revision: 1.7 $ =========================================================================*/ -/* --------------------------------------------------------------------- - -* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) -* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux -* -* This software is governed by the CeCILL-B license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL-B -* license as circulated by CEA, CNRS and INRIA at the following URL -* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -* or in the file LICENSE.txt. -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited -* liability. -* -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL-B license and that you accept its terms. -* ------------------------------------------------------------------------ */ + + /** * \file * \brief @@ -34,7 +42,7 @@ -#include "bbtkWidgetBlackBoxWindow.h" +//#include "bbtkWidgetBlackBoxWindow.h" #include "bbtkBlackBoxOutputConnector.h" @@ -54,56 +62,56 @@ namespace bbtk //========================================================================= template - void WidgetBlackBox::bbUserConstructor() + void WidgetBlackBox::bbUserSetDefaultValues() { - bbtkDebugMessage("widget",9,"WidgetBlackBox::bbUserConstructor()"< - void WidgetBlackBox::bbUserCopyConstructor(bbtk::BlackBox::Pointer) + void WidgetBlackBox::bbUserInitializeProcessing() { - bbtkDebugMessage("widget",9,"WidgetBlackBox::bbUserCopyConstructor()" - < - void WidgetBlackBox::bbUserDestructor() + void WidgetBlackBox::bbUserFinalizeProcessing() { - bbtkDebugMessage("widget",9,"==> WidgetBlackBox::bbUserDestructor() ["<bbClose(); - bbSetWindow(0); - } - bbtkDebugMessage("widget",9,"<== WidgetBlackBox::bbUserDestructor() ["<::bbUserFinalizeProcessing()"< WidgetBlackBox::bbUserFinalizeProcessing() ["<bbIsShown(); + bbGetWindow()->bbDestroy(); + bbSetWindow(0); + + if (GetUseCount()==0) + { + bbtkBlackBoxDebugMessage("widget",9,"**** HERE use count == 0"< - void WidgetBlackBox::bbInitAttributes() - { - bbmWindow = 0; - bbSetInputWinTitle(bbGetName()); - bbSetInputWinWidth(800); - bbSetInputWinHeight(800); - bbSetInputWinDialog(false); - bbSetOutputWidget(0); - } - //========================================================================= - + //========================================================================= template @@ -125,16 +133,20 @@ namespace bbtk if ( ! bbIsOutputWidgetConnected() ) { // create the Window if does not exist - if ( bbGetWindow() == 0) + if (!bbWindowIsCreated()) { - bbtkDebugMessage("widget",2, + bbtkBlackBoxDebugMessage("widget",2, "-> Creating the window" <InitWindowManagerIfNeeded(); // If is a Dialog requested if ( bbGetInputWinDialog() ) { - bbtkDebugMessage("process",2, + bbtkBlackBoxDebugMessage("widget",2, " Input WinDialog set to true : creating a Dialog" <bbCreateDialogWindow(); @@ -142,22 +154,28 @@ namespace bbtk // Input WinDialog set to false : creating a Frame else { - bbtkDebugMessage("process",2, + bbtkBlackBoxDebugMessage("widget",2, " Input WinDialog set to false : creating a Frame" <bbCreateFrameWindow(); } } + /* // Show the window if ( !bbGetWindow() ) { bbtkInternalError("Need to show the Window of widget "< Showing the window" <bbShow(); + // bbGetWindow()->bbShow(); + this->bbShowWindow(); + */ } // } @@ -170,6 +188,9 @@ namespace bbtk WidgetBlackBox::bbCreateWidgetOfInput (const std::string& in, typename WidgetBlackBox::WidgetPointer parent) { + bbtkBlackBoxDebugMessage("widget",2,"bbCreateWidgetOfInput(" + <second ; @@ -181,10 +202,15 @@ namespace bbtk // Cast it into a WidgetBlackBox typename WidgetBlackBox::Pointer wfrom = boost::dynamic_pointer_cast >(from); - // Call bbCreateWidget + // If the black box from construction is not done yet : do it + // If not constructed do it + wfrom->bbInitializeProcessing(); + // Call bbUserCreateWidget wfrom->bbUserCreateWidget(parent); // Get the widget created w = wfrom->bbGetOutputWidget(); + // Insert the box into the NestedWidgetBoxes list + bbmNestedWidgetBoxes.push_back(from); } return w; } @@ -198,16 +224,52 @@ namespace bbtk } //================================================================== + //================================================================== + template + void WidgetBlackBox::bbSetShown(bool b) + { + if (b==bbmShown) return; + + bbtkBlackBoxDebugMessage("widget",5,"WidgetBlackBox::bbSetShown(" + <bbUserOnShow(); + } + // Have to propagate to nested widgets + std::vector::const_iterator i; + for (i =bbmNestedWidgetBoxes.begin(); + i!=bbmNestedWidgetBoxes.end(); + ++i) + { + if (!i->expired()) i->lock()->bbSetShown(b); + } + + } + //================================================================== + + //================================================================== + template + bool WidgetBlackBox::bbIsShown() + { + return bbmShown; + } + //================================================================== + + /* //================================================================== template void WidgetBlackBox::bbShowWindow() { - bbtkDebugMessageInc("widget",1,"=> WidgetBlackBox::bbShowWindow() [" + bbtkBlackBoxDebugMessage("widget",1,"=> WidgetBlackBox::bbShowWindow() [" <bbShow(); - bbtkDebugMessageDec("widget",2,"<= WidgetBlackBox::bbShowWindow() [" + bbtkBlackBoxDebugMessage("widget",1,"<= WidgetBlackBox::bbShowWindow() [" < void WidgetBlackBox::bbHideWindow() { - bbtkDebugMessageInc("widget",1,"=> WidgetBlackBox::bbHideWindow() [" + bbtkBlackBoxDebugMessage("widget",1,"=> WidgetBlackBox::bbHideWindow() [" <bbHide(); - bbtkDebugMessageDec("widget",2,"<= WidgetBlackBox::bbHideWindow() [" + bbtkBlackBoxDebugMessage("widget",1,"<= WidgetBlackBox::bbHideWindow() [" < void WidgetBlackBox::bbCloseWindow() { - bbtkDebugMessageInc("widget",1,"=> WidgetBlackBox::bbCloseWindow() [" + bbtkBlackBoxDebugMessage("widget",1,"=> WidgetBlackBox::bbCloseWindow() [" <bbClose(); + if (bbGetWindow()!=0) bbGetWindow()->bbDestroy(); - bbtkDebugMessageDec("widget",2,"<= WidgetBlackBox::bbCloseWindow() [" + bbtkBlackBoxDebugMessage("widget",1,"<= WidgetBlackBox::bbCloseWindow() [" <