-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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.
-* ------------------------------------------------------------------------ */
+* ------------------------------------------------------------------------ */
/****
const int INIT_CREATION_CONTOUR = 202;
const int FIN_CREATION_CONTOUR = 203;
const int ADD_TO_SELECTED = 204;
- const int DRAG_OBJECTS = 205;
- const int EDIT_BLACKBOX = 206;
-
-
+ const int REMOVE_FROM_SELECTED = 205;
+ const int DRAG_OBJECTS = 206;
+ const int EDIT_BLACKBOX = 207;
+
+
//// COLORS (object_state_(R|G|B))
//Object Border colors
const double BOXBORDER_DRAG_R = 0.75;
const double BOXBORDER_DRAG_G = 0.75;
const double BOXBORDER_DRAG_B = 0.75;
-
+
const double BOXBORDER_SELECTED_R = 0.45;
const double BOXBORDER_SELECTED_G = 0.45;
const double BOXBORDER_SELECTED_B = 0.00;
const double BOXFILL_DRAG_R = 0.75;
const double BOXFILL_DRAG_G = 0.75;
const double BOXFILL_DRAG_B = 0.75;
-
+
const double BOXFILL_SELECTED_R = 0.65;
const double BOXFILL_SELECTED_G = 0.65;
const double BOXFILL_SELECTED_B = 0.05;
//Object Text colors
-
+
const double PORTFILL_NH_R = 0.0;
const double PORTFILL_NH_G = 0.0;
const double PORTFILL_NH_B = 0.0;
-
+
const double PORTTEXT_NH_R = 1.0;
const double PORTTEXT_NH_G = 1.0;
const double PORTTEXT_NH_B = 0.0;
-
+
const double BOXTEXT_NH_R = 0.25;
const double BOXTEXT_NH_G = 0.0;
const double BOXTEXT_NH_B = 0.0;
const int ID_SAVE_AS_COMPLEXBOX = 1011;
const int ID_COPY_TO_COMPLEXDIAGRAM = 1012;
const int ID_BTNBOX = 1013;
-
+
const int wxID_NOTEBOOK = 1013;
}
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GBlackBoxController
+* \file
+* \brief Class bbtk::GBlackBoxController
*/
//=========================================================================
GBlackBoxController::GBlackBoxController()
{
-
+
}
//=========================================================================
bool GBlackBoxController::OnMouseMove()
{
-
+
+printf("EED GBlackBoxController::OnMouseMove START \n");
+
if ( _vtkInteractorStyleBaseView!=NULL)
{
int X,Y;
_wxVTKiren->GetEventPosition( X , Y );
int state = _view->getState();
-
+
//Evaluate new state
-
+
if(state == NOTHING_HAPPENS)
{
if(_view->isPointInside(X,Y))
{
- _view->setState(HIGHLIGHTED);
- }
- }
+ _view->setState(HIGHLIGHTED);
+ }
+ } // state
+
if( state==HIGHLIGHTED)
{
if(!_view->isPointInside(X,Y))
{
_view->setState(NOTHING_HAPPENS);
}
- }
-
+ } // state
+
+
+ if ((state==DRAG) && (_isLeftClickDown==true) )
+ {
+ _objHasBeenMoved=true;
+ } // state
+
+printf("EED GBlackBoxController::OnMouseMove state=%d\n", state);
_model->notifyObservers(getId());
-
+
}
return true;
}
//=========================================================================
-
+
bool GBlackBoxController::OnLeftButtonDown()
{
+ _objHasBeenMoved = false;
+ _isLeftClickDown = true;
+ bool ok=true;
int state = _view->getState();
-
+printf("EED GBlackBoxController::OnLeftButtonDown state=%d \n", state);
//Evaluate new state
if(state == HIGHLIGHTED)
+//EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) )
{
- _isLeftClickDown=true;
+ ok=false;
_view->setState(SELECTED);
_model->notifyObservers(getId(),ADD_TO_SELECTED);
}
- return true;
- }
- //=========================================================================
-
- bool GBlackBoxController::OnLeftButtonUp()
- {
+
int X,Y;
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
+ int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+ if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) )
+ {
+ _view->setState(NOTHING_HAPPENS);
+ _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
+ }
+
+printf("EED GBlackBoxController::OnLeftButtonDown END\n" );
+
+ return ok;
+
+ }
+
+ //=========================================================================
+
+ bool GBlackBoxController::OnLeftButtonUp()
+ {
+ _isLeftClickDown = false;
+ int state = _view->getState();
+printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", state);
- int state = _view->getState();
-
//Evaluate new state
- if(_isLeftClickDown)
- {
- _isLeftClickDown=false;
- if(_view->isPointInside(X,Y))
- {
+
+//EED Borrame
+// int X,Y;
+// wxVTKRenderWindowInteractor *wxVTKiren;
+// wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+// wxVTKiren->GetEventPosition(X,Y);
+// if(_isLeftClickDown)
+// {
+// _isLeftClickDown=false;
+// if(_view->isPointInside(X,Y))
+// {
// It is supposed that I'm always inside even if the box is in drag
- _view->setState(SELECTED);
- _model->notifyObservers(getId());
- }
+// _view->setState(SELECTED);
+// _model->notifyObservers(getId());
+// }
+// }
+
+
+
+ int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+
+ if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
+ {
+ _view->setState(NOTHING_HAPPENS);
+ _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
}
+
+
+printf("EED GBlackBoxController::OnLeftButtonUp END state=%d \n", state);
+
return true;
-
+
}
-
+
//=========================================================================
bool GBlackBoxController::OnRightButtonUp()
}
else
{
- bbmodel->setExecutable(true);
+ bbmodel->setExecutable(true);
}
bbmodel->notifyObservers(getId());
}
-
+
return true;
}
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GBlackBoxController :
+* \file
+* \brief Class bbtk::GBlackBoxController :
*/
/****
class GBlackBoxController : public GBoxController
{
- public:
+ public:
//Constructors
GBlackBoxController();
~GBlackBoxController();
-
+
//Public methods
-
+
private:
//Attributes
+ bool _objHasBeenMoved;
//Private Methods
// Methods from InteractorStyleMaracas
virtual bool OnMouseMove();
- virtual bool OnLeftButtonDown();
+ virtual bool OnLeftButtonDown();
virtual bool OnLeftButtonUp();
- virtual bool OnMiddleButtonDown();
+ virtual bool OnMiddleButtonDown();
virtual bool OnRightButtonUp();
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GBoxController
+* \file
+* \brief Class bbtk::GBoxController
*/
//=========================================================================
GBoxController::GBoxController()
{
-
+
}
//=========================================================================
bool GBoxController::OnMouseMove()
{
-
+
if ( _vtkInteractorStyleBaseView!=NULL)
{
int X,Y;
wxVTKRenderWindowInteractor *_wxVTKiren;
- _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
_wxVTKiren->GetEventPosition( X , Y );
int state = _view->getState();
-
+
//Evaluate new state
-
+
if(state == NOTHING_HAPPENS)
{
if(_view->isPointInside(X,Y))
{
- _view->setState(HIGHLIGHTED);
- }
+ _view->setState(HIGHLIGHTED);
+ }
}
if( state==HIGHLIGHTED)
{
_view->setState(NOTHING_HAPPENS);
}
}
-
+
_model->notifyObservers(getId());
-
+
}
return true;
}
//=========================================================================
-
+
bool GBoxController::OnLeftButtonDown()
{
+ bool ok=true;
+printf("EED GBoxController::OnLeftButtonDown \n");
int state = _view->getState();
-
+
//Evaluate new state
if(state == HIGHLIGHTED)
{
+ ok=false;
_isLeftClickDown=true;
_view->setState(SELECTED);
_model->notifyObservers(getId(),ADD_TO_SELECTED);
}
- return true;
+ return ok;
}
//=========================================================================
-
+
bool GBoxController::OnLeftButtonUp()
{
int X,Y;
}
}
return true;
-
+
}
-
+
//=========================================================================
bool GBoxController::OnRightButtonUp()
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GConnectorController
+* \file
+* \brief Class bbtk::GConnectorController
*/
bool GConnectorController::OnMouseMove()
{
-
+
if ( _vtkInteractorStyleBaseView!=NULL)
{
int X,Y;
_wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
_wxVTKiren->GetEventPosition( X , Y );
- if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
+ if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
{
_controller->MouseMove(X,Y);
}
-
+
}
return true;
}
//=========================================================================
-
+
bool GConnectorController::OnLeftButtonDown()
{
-
+
if ( _vtkInteractorStyleBaseView!=NULL )
{
int X,Y;
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
-
+
_controller->SetKeyBoardMoving( false );
_controller->MouseClickLeft(X,Y);
_view->setState(SELECTED);
_model->notifyObservers(getId(),ADD_TO_SELECTED);
}
-
+
}
return true;
}
-
+
//=========================================================================
-
+
bool GConnectorController::OnLeftDClick()
{
}
return true;
}
-
+
//=========================================================================
-
+
bool GConnectorController::OnRightButtonDown()
{
+printf ("GConnectorController::OnRightButtonDown 1 \n" );
if( _vtkInteractorStyleBaseView!= NULL )
{
int X,Y;
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X, Y);
-
+
_controller->MouseClickRight(X,Y);
-
+
}
+printf ("GConnectorController::OnRightButtonDown 2 \n" );
return true;
}
-
+
//=========================================================================
bool GConnectorController::OnRightButtonUp()
}
//=========================================================================
-
+
void GConnectorController::setManualContourController(manualConnectorContourController* controller)
{
_controller = controller;
}
//=========================================================================
-
+
void GConnectorController::removeFromScene()
{
GConnectorModel *conMod = (GConnectorModel*)_model;
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GObjectController
+* \file
+* \brief Class bbtk::GObjectController
*/
//=========================================================================
GObjectController::GObjectController()
{
-
+
}
//=========================================================================
-
+
GObjectController::~GObjectController()
{
}
_wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
_wxVTKiren->GetEventPosition( X , Y );
int state = _view->getState();
-
+
//Evaluate new state
if( state == NOTHING_HAPPENS)
{
if(_view->isPointInside(X,Y))
{
- _view->setState(HIGHLIGHTED);
- }
+ _view->setState(HIGHLIGHTED);
+ }
}
if( state==HIGHLIGHTED)
{
_view->setState(NOTHING_HAPPENS);
}
}
-
+
_model->notifyObservers(getId());
-
+
return true;
}
//=========================================================================
-
+
bool GObjectController::OnLeftButtonDown()//virtual
{
int state = _view->getState();
-
+
//Evaluate new state
if(state == HIGHLIGHTED)
{
}
//=========================================================================
-
+
bool GObjectController::OnLeftButtonUp()//virtual
{
-
return true;
}
//=========================================================================
-
+
bool GObjectController::OnLeftDClick()//virtual
{
}
//=========================================================================
-
+
bool GObjectController::OnMiddleButtonDown()//virtual
{
return true;
void GObjectController::moveObject(int X,int Y)
{
- _view->moveObject(X,Y);
+ _view->moveObject(X,Y);
}
//=========================================================================
}
//=========================================================================
-
+
GObjectModel* GObjectController::getModel()
{
return _model;
}
//=========================================================================
-
+
void GObjectController::setId(int id)
{
_model->setObjectId(id);
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GObjectController :
+* \file
+* \brief Class bbtk::GObjectController :
*/
/****
namespace bbtk
{
- class GObjectController : public InteractorStyleMaracas
+ class GObjectController : public InteractorStyleMaracas
{
- public:
+ public:
//Constructors
GObjectController();
~GObjectController();
-
+
//Public methods
void setModelAndView(GObjectModel* model, vtkGObjectView* view);
// Same ObjectID from the model
int getId();
void setId(int id);
-
+
virtual void removeFromScene();
private:
//Attributes
-
-
+
+
//Private Methods
protected:
- //Protected Attributes
+ //Protected Attributes
- GObjectModel* _model;
- vtkGObjectView* _view;
+ GObjectModel *_model;
+ vtkGObjectView *_view;
bool _isLeftClickDown;
// Methods from InteractorStyleMaracas
virtual bool OnMouseMove();
- virtual bool OnLeftButtonDown();
+ virtual bool OnLeftButtonDown();
virtual bool OnLeftButtonUp();
virtual bool OnLeftDClick();
- virtual bool OnMiddleButtonDown();
+ virtual bool OnMiddleButtonDown();
virtual void moveObject(int X,int Y);
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::GPortController
+* \file
+* \brief Class bbtk::GPortController
*/
bool GPortController::OnLeftButtonDown()
{
-
+
int state = _view->getState();
-
+
//Evaluate new state
if(state == HIGHLIGHTED)
{
{
_view->setState(NOTHING_HAPPENS);
}
- _isLeftClickDown=false;
+ _isLeftClickDown=false;
}
return true;
//=========================================================================
-
+
} // EO namespace bbtk
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::WxInterfaceEditorGraphicBBS .
+* \file
+* \brief Class bbtk::WxInterfaceEditorGraphicBBS .
*/
#include "bbtkwxGUIEditorGraphicBBS.h"
{
_frameAUIMgr = new wxAuiManager(this);
-
+
/*std::string datadir( crea::System::GetExecutablePath() );
std::string datadir (".");
cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with crea::System::GetExecutablePath() ."<<endl;
cout<<"RaC //------------------"<<endl;
- #ifdef LINUX // assume this is OSX
+ #ifdef LINUX // assume this is OSX
datadir=datadir+"/../share/creaContours";
- #endif // MACOSX
-
- #ifdef MACOSX // assume this is OSX
+ #endif // MACOSX
+
+ #ifdef MACOSX // assume this is OSX
datadir=datadir+"/../../../../share/creaContours";
- #endif // MACOSX
+ #endif // MACOSX
_dataDir = datadir;*/
//=========================================================================
void wxGUIEditorGraphicBBS::initToolbar()
- {
+ {
wxBitmap bmp_new(new_xpm);
wxBitmap bmp_open(open_xpm);
wxBitmap bmp_save(save_xpm);
toolbar->AddTool(ID_ADDCOMPLEXBOXOUTPUT,_T("Add output to Complex box"),bmp_complexoutputport, wxNullBitmap, wxITEM_NORMAL,_T("Add output Complex box"), _T("Add output Complex box"));
toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
-
+
toolbar->SetMargins( 2, 2 );
toolbar->Realize();
SetToolBar(toolbar);
//TO FIX THE PATH OF BBTK BIN IN ORDER TO USE REGENERATE EXECUTABLES
//RegenerateAll();
_helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
- _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));
+ _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));
}
//=========================================================================
// Create Help menu and its items
wxMenu *editMenu = new wxMenu;
- editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM, _T("Copy selected to complex box"), _T("Creates a new complex box diagram with selected boxes"));
+ editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM, _T("Copy selected to complex box"), _T("Creates a new complex box diagram with selected boxes"));
Connect(ID_COPY_TO_COMPLEXDIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram));
// Create Help menu and its items
wxMenu *helpMenu = new wxMenu;
- helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
+ helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
// Append the created menu to the menu bar
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(helpMenu, _T("&Help"));
// Attach this menu bar to the frame
- SetMenuBar(menuBar);
+ SetMenuBar(menuBar);
}
//=========================================================================
{
_notebook = new wxAuiNotebook(this,wxID_NOTEBOOK,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON);
_tabsMgr = new wxTabPanelsManager(this);
- _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());
+ _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());
}
-
+
//=========================================================================
void wxGUIEditorGraphicBBS::initPackageBrowser()
{
_pkgBrowser = new WxGUIPackageBrowser2(this);
_pkgBrowser->IncludeAll();
- _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
+ _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
}
//================================================================
{
mess = "Regenerating doc for all packages";
}
-
- mess += " ... please wait";
+
+ mess += " ... please wait";
SetStatusText( std2wx(mess) );
wxOK | wxICON_INFORMATION);
*/
}
- else
+ else
{
SetStatusText( _T("Done !"));
wxString err(_T("An error occured while running '"));
err += bbtk::std2wx(command) + _T("'");
- wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
+ wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
}
}
wxOK | wxICON_INFORMATION);
*/
}
- else
+ else
{
SetStatusText( _T("Done !"));
wxString err(_T("An error occured while running '"));
err += bbtk::std2wx(command) + _T("'");
- wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
+ wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
}
}
-
+
//================================================================
void wxGUIEditorGraphicBBS::RegenerateAll()
{
- DoRegeneratePackageDoc("-a");
+ DoRegeneratePackageDoc("-a");
DoRegenerateBoxesLists();
}
std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
std::string filename = dir + separator + "tmp_bbtk.bbs";
-
+
ofstream tempFile;
tempFile.open(filename.c_str());
tempFile << script;
std::string command = "\""+ crea::System::GetExecutablePath();
-
+
#ifdef MACOSX
command += separator + "../../../bbi.app/Contents/MacOS";
#endif
-
+
#ifdef WIN32
command += "\"";
#endif
-
- /*
-
+
+ /*
+
//command += ConfigurationFile::GetInstance().Get_bin_path();
//EED command +="C:/temp/bbtkBIN/RelWithDebInfo//";
//EED command +="C:/Program Files/CreaTools/bbtk-0.9.5/bin";
#ifdef MACOSX
command += separator + "usr/local/bin/bbi.app/Contents/MacOS/bbi\" ";
- #else
+ #else
command +=".";
command += separator + "bbi\" ";
#endif
#endif
command += " & ";
-
+
printf ("RaC wxGUIEditorGraphicBBS::executeScript %s \n" , command.c_str() );
system( command.c_str() );
}
//=========================================================================
- // EVENT HANDLERS
+ // EVENT HANDLERS
//=========================================================================
void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event)
{
- _tabsMgr->addNewTab();
+ _tabsMgr->addNewTab();
refreshGUIControls();
}
void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event)
{
- std::string script = _tabsMgr->getActualDiagramBBS();
- cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl;
- cout<<script<<endl;
+ std::string script1 = _tabsMgr->getActualDiagramBBS(true);
+ cout<<endl<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl<<endl;
+ cout<<script1<<endl;
- executeScript(script);
+ std::string script2 = _tabsMgr->getActualDiagramBBS(false);
+ executeScript(script2);
}
-
+
//=========================================================================
- // HANDLERS
+ // HANDLERS
//=========================================================================
void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event)
{
if (openFileDialog->ShowModal() == wxID_OK)
{
wxString fileName = openFileDialog->GetPath( );
-
-
+
+
_tabsMgr->addNewTab();
- bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager() , _pkgBrowser->GetFactory());
-
+ bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager() , _pkgBrowser->GetFactory());
+
// We tell the interpreter to throw exceptions on error
I->SetThrow(true);
// Interpret the file supposed to define a box called 'Processing'
if (saveFileDialog->ShowModal() == wxID_OK)
{
wxString fileName = saveFileDialog->GetPath( );
-
+
ofstream file;
-//EED file.open(fileName.c_str());
+//EED file.open(fileName.c_str());
file.open( (const char*) (fileName.mb_str()) );
std::string content="";
-
+
// writing file header
content += "# ----------------------------------\n";
content += "# - BBTKGEditor v 1.0 BBS BlackBox Script\n";
{
wxString fileName = nameDialog->GetValue();
cbName=(const char*) (fileName.mb_str());
- }
+ }
if(!cbName.empty())
- {
+ {
wxFileDialog * saveFileDialog = new wxFileDialog(this ,wxT("Save Complex Box BBS") ,wxEmptyString, wxString( cbName.c_str(), wxConvUTF8),wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
if (saveFileDialog->ShowModal() == wxID_OK)
{
wxString fileName = saveFileDialog->GetPath();
-
+
ofstream file;
file.open( (const char*) (fileName.mb_str()) );
std::string content="";
-
+
// writing file header
content += "# ----------------------------------\n";
content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n";
if (saveFileDialog->ShowModal() == wxID_OK)
{
wxString fileName = saveFileDialog->GetPath();
-
+
ofstream file;
file.open( (const char*) (fileName.mb_str()) );
std::string content="";
-
+
// writing file header
content += "# ----------------------------------\n";
content += "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file\n";
content += "# ----------------------------------\n";
content += "\n";
content += "APP_START\n";
- _tabsMgr->saveActualDiagram(content);
+ _tabsMgr->saveActualDiagram(content);
content += "APP_END\n";
file << content;
file.close();
toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
-
+
GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
}
GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
}
-
+
if(_tabsMgr->getNumActualSelectedObjects()>0)
{
GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
//=========================================================================
-
+
void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
{
wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,wxT(""),wxT("*.bbg"),wxOPEN|wxFILE_MUST_EXIST);
if (openFileDialog->ShowModal() == wxID_OK)
{
wxString fileName = openFileDialog->GetPath();
-
+
ifstream inputStream;
//EED inputStream.open(fileName.c_str());
_tabsMgr->addNewTab();
_tabsMgr->loadDiagram(inputStream);
-
+
inputStream.close();
}
refreshGUIControls();
}
//=========================================================================
-
-
+
+
void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event)
{
+
BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
- std::string typeName = bbDes->GetTypeName();
- std::string packageName = bbDes->GetPackage()->GetName();
+ if (bbDes!=NULL)
+ {
+ std::string typeName = bbDes->GetTypeName();
+ std::string packageName = bbDes->GetPackage()->GetName();
+
- this->_tabsMgr->getActualTabPanel()->getSceneManager()->createGBlackBox(50,50,packageName, typeName);
- this->_tabsMgr->getActualTabPanel()->getSceneManager()->refresh();
-
- printf("EED wxGUIEditorGraphicBBS::OnClickBtnBox \n");
+ wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
+
+ if (pnl!=NULL)
+ {
+ wxVtkSceneManager *scn = pnl->getSceneManager();
+ scn->createGBlackBox(50,50,packageName, typeName);
+ scn->refresh();
+ } // if pnl
+ }// if bbDes
}
-
+
//=========================================================================
-
+
void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
{
wxToolBar* toolbar = GetToolBar();
{
_tabsMgr->setActualDiagramComplexBox(false);
}
- refreshGUIControls();
+ refreshGUIControls();
}
//=========================================================================
void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
- {
+ {
wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of input port"));
if (nameDialog->ShowModal() == wxID_OK)
{
std::string portName=(const char*) (fileName.mb_str());
_tabsMgr->addActualDiagramComplexInputPort(portName);
}
- }
+ }
}
//=========================================================================
std::string portName=(const char*) (fileName.mb_str());
_tabsMgr->addActualDiagramComplexOutputPort(portName);
}
- }
+ }
}
//=========================================================================
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::wxBlackBoxEditionDialog .
+* \file
+* \brief Class bbtk::wxBlackBoxEditionDialog .
*/
#include "wxBlackBoxEditionDialog.h"
//=========================================================================
-
+
wxBlackBoxEditionDialog::~wxBlackBoxEditionDialog()
{
{
wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL);
- wxStaticText *text = new wxStaticText(this, -1, wxT("Input Ports"));
+ wxScrolledWindow *scrollWin = new wxScrolledWindow( this, -1, wxDefaultPosition, wxSize(200,200), wxVSCROLL);
+
+ wxStaticText *text = new wxStaticText(scrollWin, -1, wxT("Input Ports"));
wxFont font(11, wxDEFAULT, wxNORMAL, wxBOLD);
text->SetFont(font);
-
+
+
+
std::vector<GPortModel*> lstInputs = _model->getInputPorts();
- wxFlexGridSizer *sizer = new wxFlexGridSizer(lstInputs.size(),3,5,5);
+ wxFlexGridSizer *sizer = new wxFlexGridSizer(lstInputs.size(),3,5,5);
for(int i = 0;i<(int)lstInputs.size();i++)
{
- GPortModel* port = lstInputs[i];
- std::string type = port->getBBTKType();
- wxStaticText *lblName = new wxStaticText(this, -1, std2wx(port->getBBTKName()),wxDefaultPosition,wxSize(100,25));
- wxStaticText *lblType = new wxStaticText(this, -1, std2wx(type),wxDefaultPosition,wxSize(250,25));
- wxTextCtrl *txtValue = new wxTextCtrl(this, -1, _T(""),wxDefaultPosition,wxSize(90,25));
-
+ GPortModel* port = lstInputs[i];
+ std::string type = port->getBBTKType();
+ wxStaticText *lblName = new wxStaticText(scrollWin, -1, std2wx(port->getBBTKName()),wxDefaultPosition,wxSize(100,25));
+ wxStaticText *lblType = new wxStaticText(scrollWin, -1, std2wx(type),wxDefaultPosition,wxSize(250,25));
+ wxTextCtrl *txtValue = new wxTextCtrl(scrollWin, -1, _T(""),wxDefaultPosition,wxSize(90,25));
+
if(port->getValue()!="")
{
txtValue->SetValue(crea::std2wx(port->getValue()));
txtValue->SetEditable(false);
}
- _lstNames.push_back(lblName);
+ _lstNames.push_back(lblName);
_lstValues.push_back(txtValue);
_lstTypes.push_back(lblType);
-
- sizer->Add(lblName,1,wxEXPAND,5);
+
+ sizer->Add(lblName,1,wxEXPAND,5);
sizer->Add(txtValue,1,wxEXPAND,5);
sizer->Add(lblType,1,wxCENTRE|wxEXPAND,5);
-
}
-
- wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL);
- wxButton *okButton = new wxButton(this, -1, _T("Ok"),wxDefaultPosition, wxSize(70, 30));
- wxButton *closeButton = new wxButton(this, -1, _T("Close"), wxDefaultPosition, wxSize(70, 30));
+
+
+ wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL);
+ wxButton *okButton = new wxButton(scrollWin, -1, _T("Ok"),wxDefaultPosition, wxSize(70, 30));
+ wxButton *closeButton = new wxButton(scrollWin, -1, _T("Close"), wxDefaultPosition, wxSize(70, 30));
// connect command event handlers
Connect(okButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxBlackBoxEditionDialog::onClickOk));
Connect(closeButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxBlackBoxEditionDialog::onClickClose));
-
+
buts->Add(okButton,0,wxCENTRE|wxEXPAND,5);
buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5);
sizerDialog->AddSpacer(15);
sizerDialog->Add(buts,0,wxALIGN_CENTER | wxTOP | wxBOTTOM);
- SetSizer(sizerDialog);
+ scrollWin->SetSizer(sizerDialog);
+ scrollWin->Centre();
+
+
+ scrollWin->SetVirtualSize(400,400);
+ scrollWin->SetSize(300,300);
+ scrollWin->SetScrollbars(10, 10, 50, 50);
+// scrollWin->SetSizer(sizer);
+
- Centre();
ShowModal();
Destroy();
}
void wxBlackBoxEditionDialog::onClickOk(wxCommandEvent& event)
{
-printf("EED wxBlackBoxEditionDialog::onClickOk size %d \n", (int)_lstValues.size() );
for(int i=0;i<(int)_lstValues.size();i++)
{
std::string text = wx2std(_lstValues[i]->GetValue());
-printf("EED wxBlackBoxEditionDialog::onClickOk text %s \n", text.c_str() );
//TOFIX Search a better alternative
if(text!="--No editable--" && text!="--Port Connected--")
{
-printf("EED wxBlackBoxEditionDialog::onClickOk text %s \n", text.c_str() );
_model->setValueToInputPort(i,text);
}
}
void wxBlackBoxEditionDialog::onClickClose(wxCommandEvent& event)
{
printf("EED wxBlackBoxEditionDialog::onClickClose\n");
- Close(true);
+ Close(true);
}
//=========================================================================
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::wxGEditorTabPanel .
+* \file
+* \brief Class bbtk::wxGEditorTabPanel .
*/
{
printf ("EED %p ~wxGEditorTabPanel()\n" , this );
//ED02JUIN2010 _sceneManager->disconnectDrop();
+
+ _panelsManager->VerifyLastTabPanel();
+
}
-
+
//=========================================================================
void wxGEditorTabPanel::initWxVtkCanvas()
{
baseview->Configure();
_sceneManager=new wxVtkSceneManager(this,baseview,_id);
+
+//EED02JUIN2010
printf("RaC-EED 21-06-2010 wxGEditorTabPanel::initWxVtkCanvas Remove the panelAUIMgr, and change to a normal sizer inside the wxGEditorTabPanel\n");
_panelAUIMgr->AddPane((wxWindow*)baseview->GetWxVTKRenderWindowInteractor(),wxAuiPaneInfo().Fixed().CenterPane());
-//EED02JUIN2010
_panelAUIMgr->Update();
}
char *result = NULL;
result = strtok( str, delims );
packageName += result;
-
+
result = strtok( NULL, delims );
boxType += result;
-
+
_sceneManager->createGBlackBox(x,y,packageName, boxType);
return true;
//=========================================================================
- std::string wxGEditorTabPanel::getDiagramBBS()
+ std::string wxGEditorTabPanel::getDiagramBBS(bool wln)
{
- return _sceneManager->getDiagramBBS();
+ return _sceneManager->getDiagramBBS(wln);
}
//=========================================================================
}
//=========================================================================
-
+
void wxGEditorTabPanel::saveDiagram(std::string &content)
{
_sceneManager->saveDiagram(content);
}
//=========================================================================
-
+
std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
{
return _sceneManager->getSelectedObjects();
_sceneManager->addObjects(objectsMap);
}
- //=========================================================================
-
+ //=========================================================================
+
int wxGEditorTabPanel::getNumSelectedObjects()
{
return _sceneManager->getNumSelectedObjects();
}
- //=========================================================================
+ //=========================================================================
+
-
wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
{
return _sceneManager;
}
-
-
+
+
} // EO namespace bbtk
// EOF
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::BlackBox : abstract black-box interface.
+* \file
+* \brief Class bbtk::BlackBox : abstract black-box interface.
*/
/****
class tmpClasswxTextDropTarget : public wxTextDropTarget
{
- public:
+ public:
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& data) { return false;}
};
- //RaC: It is important if it exists a double relation
+ //RaC: It is important if it exists a double relation
//e.g. wxGEditorTabPanel includes wxVtkSceneManager, and wxVtkSceneManager includes wxGEditorTabPanel
class wxVtkSceneManager;
class wxTabPanelsManager;
// RaC Be careful with the double heritance
class wxGEditorTabPanel : public wxPanel, public wxTextDropTarget
{
- public:
+ public:
wxGEditorTabPanel();
wxGEditorTabPanel(wxWindow *parent, int id);
~wxGEditorTabPanel();
void initWxVtkCanvas();
-
+
// Sets the parent manager
void setPanelsManager(wxTabPanelsManager* panelsManager);
// Get the BBS script of the pipeline diagram included in the panel
- std::string getDiagramBBS();
+ std::string getDiagramBBS(bool wln=false);
// Saves the actual BBS as complex box
// RaC TOFIX It must be included the package of the complex box
// Save diagram as BBG
void saveDiagram(std::string &content);
-
+
// Load BBG diagram
void loadDiagram(ifstream &inputStream);
bool isComplexBox();
void setComplexBox(bool val);
- // Returns a map with the id,controller of all the objects selected
+ // Returns a map with the id,controller of all the objects selected
std::map<int,GObjectController*> getSelectedObjects();
void addObjects(std::map<int,GObjectController*> objectsMap);
// Receives the string from a drag and drop source as for example the BBTK Package Browser
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
-
+
wxVtkSceneManager* getSceneManager();
//=========================================================================
-
+
private:
int _id;
wxAuiManager *_panelAUIMgr;
wxVtkSceneManager *_sceneManager;
- wxTabPanelsManager * _panelsManager;
+ wxTabPanelsManager *_panelsManager;
protected:
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::wxTabPanelsManager .
+* \file
+* \brief Class bbtk::wxTabPanelsManager .
*/
wxTabPanelsManager::~wxTabPanelsManager()
{
}
-
+
//=========================================================================
void wxTabPanelsManager::addNewTab()
{
_lastId++;
- wxGEditorTabPanel *newPanel = new wxGEditorTabPanel(_notebook,_lastId);
+ wxGEditorTabPanel *newPanel = new wxGEditorTabPanel(_notebook,_lastId);
newPanel->setPanelsManager(this);
- _panels[_lastId]=newPanel;
- _actual = newPanel;
+ _panels[_lastId] = newPanel;
+ _actual = newPanel;
_notebook->AddPage(newPanel,_T("Diagram"),true);
}
{
return _notebook;
}
-
+
//=========================================================================
wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
{
//=========================================================================
- std::string wxTabPanelsManager::getActualDiagramBBS()
+ std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
{
- return _actual->getDiagramBBS();
+ return _actual->getDiagramBBS(wln);
}
//=========================================================================
void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
{
- _actual->setComplexBox(val);
+ _actual->setComplexBox(val);
}
//=========================================================================
-
+
void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
{
_actual->addComplexInputPort(portName);
//=========================================================================
+ void wxTabPanelsManager::VerifyLastTabPanel()
+ {
+printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() );
+ if (this->_notebook->GetPageCount()==0)
+ {
+ this->_actual=NULL;
+ }
+ }
+
+ //=========================================================================
+
void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
{
- int index = event.GetSelection();
- wxGEditorTabPanel* tab =(wxGEditorTabPanel*)_notebook->GetPage(index);
- int id = tab->getPanelId();
- _actual = _panels[id];
+printf("wxTabPanelsManager::OnTabChanged \n");
+ int index = event.GetSelection();
+ wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
+ int id = tab->getPanelId();
+ _actual = _panels[id];
_parent->refreshGUIControls();
}
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::BlackBox : abstract black-box interface.
+* \file
+* \brief Class bbtk::BlackBox : abstract black-box interface.
*/
/****
class wxTabPanelsManager : public wxEvtHandler
{
- public:
+ public:
wxTabPanelsManager(wxGUIEditorGraphicBBS *parent);
~wxTabPanelsManager();
-
+
void addNewTab();
wxAuiNotebook* getAuiNotebook();
wxGEditorTabPanel* getActualTabPanel();
void displayBlackBoxInfo(std::string packageName, std::string boxName);
void updateStatusBar(std::string textStatus);
- std::string getActualDiagramBBS();
+ std::string getActualDiagramBBS(bool wln=false);
std::string getActualComplexBoxBBS(std::string cbName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription="");
void editBlackBox(GBlackBoxModel *bbmodel);
void addActualDiagramComplexOutputPort(std::string portName);
void copySelectedBBoxesToComplexDiagram();
int getNumActualSelectedObjects();
-
+
void OnTabChanged(wxAuiNotebookEvent& event);
+ void VerifyLastTabPanel();
private:
// Private Attributes
- wxGUIEditorGraphicBBS *_parent;
- map<int, wxGEditorTabPanel*> _panels;
- wxGEditorTabPanel* _actual;
- wxAuiNotebook *_notebook;
- int _lastId;
-
+ wxGUIEditorGraphicBBS *_parent;
+ map<int, wxGEditorTabPanel*> _panels;
+ wxGEditorTabPanel *_actual;
+ wxAuiNotebook *_notebook;
+ int _lastId;
+
protected:
};
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::wxVtkSceneManager .
+* \file
+* \brief Class bbtk::wxVtkSceneManager .
*/
if( _baseView!=NULL )
{
-//EED02JUIN2010
+//EED02JUIN2010
printf ("RaC-EED 21-06-2010 %p wxVtkSceneManager::wxVtkSceneManager If you comment this line, the drag and drop functionnality is not initialized.\n" , this );
- _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent);
+#ifdef _APPLE_
+ _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent);
+#endif
configureBaseView();
_worldState=NOTHING_HAPPENS;
registerController(this);
-
+
}
_idConnectionInCreation = -1;
_contLastId = 0;
printf ("EED %p ~wxVtkSceneManager()\n" , this );
disconnectDrop();
}
-
+
//=========================================================================
void wxVtkSceneManager::configureBaseView()
interactorstylebaseview->SetInteractor ( iren );
iren->SetInteractorStyle(interactorstylebaseview);
interactorstylebaseview->SetwxVtkBaseView(_baseView);
-
+
_baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
_baseView->GetRenderer()->ResetCamera(-100,100,-100,100,800,1100);
-
+
_baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
_baseView->GetRenderer()->GradientBackgroundOn();
_baseView->Refresh();
-
- // Actos Port_Text
+
+ // Actos Port_Text
_textActor = vtkTextActor3D::New();
_textActor->SetPosition( -9999 , -9999 , 900 );
_textActor->SetInput( "<void>" );
_textActor->GetTextProperty()->SetFontSize(60);
_textActor->GetTextProperty()->BoldOn();
_textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R,PORTTEXT_NH_G,PORTTEXT_NH_B);
-
+
_baseView->GetRenderer()->AddActor( _textActor );
-
-
+
+
// Actor Fill_Port_Text
-
+
//------------
double xInic = 0;
double yInic = 0;
vtkPolygon *aPolygon = vtkPolygon::New();
_fillObjectActor = vtkActor::New();
- _pts = vtkPoints::New();
+ _pts = vtkPoints::New();
//ups4 EED Borrame
-
+
double w=100,h=10,b=h/15,t=3;
_pts->SetNumberOfPoints(21);
_pts->InsertPoint(0, xInic+w*0.33-t/2 , yInic , zInic );
_pts->InsertPoint(2, xInic+w*0.33+t/2 , yInic , zInic );
_pts->InsertPoint(3, xInic+w*0.33+t/2 , yInic , zInic );
_pts->InsertPoint(4, xInic+w-b*4 , yInic+b*0 , zInic );
-
+
_pts->InsertPoint( 5, xInic+w-b*4 , yInic+b*0 , zInic );
_pts->InsertPoint( 6, xInic+w-b*2 , yInic+b*1 , zInic );
_pts->InsertPoint( 7, xInic+w-b*1 , yInic+b*2 , zInic );
_pts->InsertPoint( 8, xInic+w-b*0 , yInic+b*4 , zInic );
-
+
_pts->InsertPoint( 9, xInic+w-b*0 , yInic+h-b*4 , zInic );
_pts->InsertPoint(10, xInic+w-b*1 , yInic+h-b*2 , zInic );
_pts->InsertPoint(11, xInic+w-b*2 , yInic+h-b*1 , zInic );
_pts->InsertPoint(12, xInic+w-b*4 , yInic+h-b*0 , zInic );
-
+
_pts->InsertPoint(13, xInic+b*4 , yInic+h-b*0 , zInic );
_pts->InsertPoint(14, xInic+b*2 , yInic+h-b*1 , zInic );
_pts->InsertPoint(15, xInic+b*1 , yInic+h-b*2 , zInic );
_pts->InsertPoint(18, xInic+b*1 , yInic+b*2 , zInic );
_pts->InsertPoint(19, xInic+b*2 , yInic+b*1 , zInic );
_pts->InsertPoint(20, xInic+b*4 , yInic+b*0 , zInic );
-
+
aPolygon->GetPointIds()->SetNumberOfIds(21);
for (int i=0;i<21; i++)
{
aPolygon->GetPointIds()->SetId(i, i);
}
-
+
vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New();
aPolygonGrid->Allocate(1, 1);
aPolygonGrid->InsertNextCell(aPolygon->GetCellType(), aPolygon->GetPointIds());
_fillObjectActor->GetProperty()->SetOpacity(0);
_aPolygonMapper->Modified();
- _baseView->GetRenderer()->AddActor( _fillObjectActor );
+ _baseView->GetRenderer()->AddActor( _fillObjectActor );
}
//=========================================================================
-
+
std::string wxVtkSceneManager::generateANewNameForABox()
{
std::stringstream boxname;
}
//=========================================================================
-
+
std::string wxVtkSceneManager::findANewNameForABox()
{
std::string boxname=generateANewNameForABox();
bbmod->setBBTKName(name);
bbmod->setInicPoint(xIn,yIn,zIn);
bbmod->setFinalPoint(xEn,yEn,zEn);
- bbmod->setExecutable(boxExecutable);
-
+ bbmod->setExecutable(boxExecutable);
+
bbmod->notifyObservers(_idManager);
- }
-
-
+ }
+
+
//=========================================================================
int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType)
int type = GBLACKBOX;
//Create the MVC Objects
-
+
GBlackBoxModel *model = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
-
+
BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
-
+
//Prepares the initial model
- //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height
+ //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height
double xx = x;
double yy = windowHeight-y;
-
+
//z value is not important yet, because it is only used a parallel projection
double zz = 900;
-printf("EED wxVtkSceneManager::createGBlackBox 900-450\n");
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
-
+
std::stringstream stream;
-
+
std::string newBoxName;
newBoxName = findANewNameForABox();
-
-
+
+
stream << newBoxName;
-
+
std::string arraystring = stream.str();
model->setBBTKName(arraystring);
model->setBBTKType(boxType);
model->setBBTKPackage(packageName);
-
+
model->addObserver(view);
model->addObserver(this);
view->setModel(model);
view->setBaseView(_baseView);
view->initVtkObjects();
-
+
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
//Resgiter change to the observers of the actual model
model->notifyObservers(_idManager);
-
+
int newId = addObjectController(controller);
return newId;
{
//EED int windowWidth=_baseView->GetRenWin()->GetSize()[0];
int windowHeight=_baseView->GetRenWin()->GetSize()[1];
-
+
int type = GCOMPLEXINPUTPORT;
//Create the MVC Objects
-
+
GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
-
- //Prepares the initial model
+
+ //Prepares the initial model
double xx = 5;
double yy = windowHeight-5;
-
+
//z value is not important yet, because it is only used a parallel projection
double zz = 900;
printf("EED wxVtkSceneManager::createGComplexBoxInputPort 900-450\n");
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
-
+
model->setBBTKName(inputName);
model->setBBTKType("ComplexInputPort");
model->setComplexPortType(type);
-
+
model->addObserver(view);
model->addObserver(this);
-
- //create the output port
+
+ //create the output port
GPortController* portController = createGPort(GOUTPUTPORT,inputName,"ComplexInputPort",0,model);
model->addOutputPort((GPortModel*)portController->getModel());
-
+
//Associates the view with the correspondent renderer and the model.
//(NOTE: Refresh is only made by the view)
view->setModel(model);
view->setBaseView(_baseView);
view->initVtkObjects();
-
+
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
//Resgiter change to the observers of the actual model
model->notifyObservers(_idManager);
-
+
int newId = addObjectController(controller);
return newId;
}
//=========================================================================
-
+
int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName)
{
//EED int windowWidth=_baseView->GetRenWin()->GetSize()[0];
int type = GCOMPLEXOUTPUTPORT;
//Create the MVC Objects
-
+
GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
-
- //Prepares the initial model
+
+ //Prepares the initial model
double xx = 5;
double yy = windowHeight-5;
-
+
//z value is not important yet, because it is only used a parallel projection
double zz = 900;
-
+
printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n");
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
-
+
model->setBBTKName(outputName);
model->setBBTKType("ComplexOutputPort");
model->setComplexPortType(type);
-
+
model->addObserver(view);
model->addObserver(this);
-
- //create the output port
+
+ //create the output port
GPortController* portController = createGPort(GINPUTPORT,outputName,"ComplexInputPort",0,model);
model->addInputPort((GPortModel*)portController->getModel());
-
+
//Associates the view with the correspondent renderer and the model.
//(NOTE: Refresh is only made by the view)
view->setModel(model);
view->setBaseView(_baseView);
view->initVtkObjects();
-
+
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
//Resgiter change to the observers of the actual model
model->notifyObservers(_idManager);
-
+
int newId = addObjectController(controller);
return newId;
}
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
model->registerInBox(blackBox,portType, posInBox);
-
+
model->setBBTKType(bbtkType);
model->setBBTKName(bbtkName);
view->setModel(model);
view->setBaseView(_baseView);
view->initVtkObjects();
-
+
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
manualConnectorContourView* manContourView = new manualConnectorContourView();
manualContourModel* manContourModel = new manualContourModel();
- GConnectorController* connectorcontroller = new GConnectorController();
+ GConnectorController* connectorcontroller = new GConnectorController();
GConnectorModel* connectorModel = new GConnectorModel();
vtkGConnectorView* connectorView = new vtkGConnectorView();
connectorModel->setGObjectType(type);
manContourView->SetShowText(false);
manContourControl->SetModelView( manContourModel , manContourView );
-
+
manContourControl->CreateNewManualContour();
manContourView->RefreshContour();
manContourControl->SetState(1);
manContourModel->SetCloseContour(false);
-
+
manContourModel->AddPoint(x,y,z);
manContourView->AddPoint();
int newId = addObjectController(connectorcontroller);
- connectorcontroller->setManualContourController(manContourControl);
+ connectorcontroller->setManualContourController(manContourControl);
connectorModel->setManualContourModel(manContourModel);
connectorView->setManualContourView(manContourView);
connectorView->setModel(connectorModel);
connectorView->setBaseView(_baseView);
-
+
connectorModel->addObserver(connectorView);
connectorModel->addObserver(this);
}
//=========================================================================
-
+
+ //=========================================================================
+ int wxVtkSceneManager::GetIndexInSelected(int idControler)
+ {
+ int index=-1;
+ for (int i=0; i<(int)_selectedObjects.size(); i++)
+ {
+ if(_selectedObjects[i]==idControler)
+ {
+ index=i;
+ break;
+ }
+ }
+ return index;
+ }
+ //=========================================================================
+
void wxVtkSceneManager::update(int idController,int command)
{
+printf("EED wxVtkSceneManager::update 1 \n" );
+
if(command != NO_COMMAND)
{
if(command == ADD_TO_SELECTED)
{
-//EED GObjectController* cont = _controllers[idController];
+//EEDBorrame GObjectController* cont = _controllers[idController];
- bool foundID=false;
- for (int i=0; i<(int)_selectedObjects.size() && foundID==false; i++)
- {
- int id = _selectedObjects[i];
- if(id==idController)
- {
- foundID = true;
- }
- }
- if(!foundID)
+ if (GetIndexInSelected(idController)==-1)
{
- int id = idController;
- _selectedObjects.push_back(id);
+ _selectedObjects.push_back(idController);
}
- }
+//EEDBorrame
+// bool foundID=false;
+// for (int i=0; i<(int)_selectedObjects.size() && foundID==false; i++)
+// {
+// if(_selectedObjects[i]==idController)
+// {
+// foundID = true;
+// }
+// }
+// if(!foundID)
+// {
+// _selectedObjects.push_back(idController);
+// }
+
+ }else if(command == REMOVE_FROM_SELECTED)
+ {
+ int index=GetIndexInSelected(idController);
+ if (index>=0)
+ {
+ _selectedObjects.erase( _selectedObjects.begin()+index );
+ }
+ }
else if(command == INIT_CREATION_CONTOUR)
- {
- _worldState = INIT_CREATION_CONTOUR;
- GObjectController* cont = _controllers[idController];
+ {
+ _worldState = INIT_CREATION_CONTOUR;
+ GObjectController* cont = _controllers[idController];
GPortModel* startOutputPort = (GPortModel*)cont->getModel();
-
+
// The last one is the controller of the connector
std::map<int, GObjectController*>::iterator it2;
cont->getView()->setState(NOTHING_HAPPENS);
cont->getModel()->notifyObservers(_idManager);
cont->SetActive(false);
- }
+ }
}
_selectedObjects.clear();
}
else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR)
- {
+ {
_worldState = NOTHING_HAPPENS;
//int id = _controllers.size()-1;
- GObjectController* cont = _controllers[_idConnectionInCreation];
+ GObjectController* cont = _controllers[_idConnectionInCreation];
GConnectorModel* modelContour = (GConnectorModel*)cont->getModel();
GObjectController* finPort = _controllers[idController];
{
GPortModel* modelPort = (GPortModel*)finPort->getModel();
modelContour->setEndPort(modelPort);
- }
+ }
- manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController();
+ manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController();
manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour();
connView->Refresh();
cont->getView()->setState(NOTHING_HAPPENS);
cont->getModel()->notifyObservers(_idManager);
}
- cont->SetActive(true);
+ cont->SetActive(true);
}
}
-
+
}
+
+printf("EED wxVtkSceneManager::update 2 \n" );
+
}
//=========================================================================
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
-
-
+
+
if(_worldState == DRAG_OBJECTS)
- {
+ {
for (int i=0; i<(int)_selectedObjects.size(); i++)
{
int id = _selectedObjects[i];
vconn->updateStartEndPoints();
}
}
-
+
_startDragging=false;
}
int type = desc->getGObjectType();
int state = desc->getView()->getState();
desc->getModel()->getCenter(px,py,pz);
-
+
if(state == HIGHLIGHTED){
okStatusMessage = true;
updateStatusBar(desc->getStatusText());
_textActor->SetInput( desc->getStatusText().c_str() );
_textActor->SetScale(0.1);
_textActor->SetPosition( px-25 ,py+1 , pz+2 );
-
-//ups4 EED Borrame
+
+//ups4 EED Borrame
// FillPortText
px=px-33;
py=py;
} // if GPORT
} // for controllers it
- }
+ }
}
- if (okStatusMessage==false)
+ if (okStatusMessage==false)
{
updateStatusBar("");
}
-
- if (okPortMessage==false)
+
+ if (okPortMessage==false)
{
_textActor->SetScale(0.0001);
_fillObjectActor->SetScale(0.0001);
}
-
+
return true;
}
//=========================================================================
-
+
bool wxVtkSceneManager::OnLeftButtonDown()
{
if(_worldState==INIT_CREATION_CONTOUR)
isOverPort=true;
} // if
} // if
- } // for
-
+ } // for
+
if(isOverPort==false)
{
_worldState=NOTHING_HAPPENS;
//int lastId = _controllers.size()-1;
- GConnectorController *connector = (GConnectorController*)_controllers[_controllers.size()-1];
+//EED2Oct2010 GConnectorController *connector = (GConnectorController*)_controllers[_controllers.size()-1];
+ GConnectorController *connector = (GConnectorController*)_controllers[_idConnectionInCreation];
+
connector->removeFromScene();
unregisterController(connector);
- _controllers.erase(_controllers.size()-1);
+ _controllers.erase(_controllers.size()-1);
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
desc->SetActive(true);
desc->getView()->setState(NOTHING_HAPPENS);
desc->getModel()->notifyObservers(_idManager);
- } // for
+ } // for
} // isOverPort
} // _worldState
-
- if(_selectedObjects.size()!=0)
- {
- _worldState = DRAG_OBJECTS;
- _startDragging = true;
- for (int i = 0; i < (int)_selectedObjects.size(); i++)
- {
- int id = _selectedObjects[i];
- GObjectController* cont = _controllers[id];
- cont->getView()->setState(DRAG);
- cont->getModel()->notifyObservers(_idManager);
- } // for
- } // _selectedObjects
-
-
-
+ _worldState = DRAG_OBJECTS;
+ _startDragging = true;
+
+
+printf("EED wxVtkSceneManager::OnLeftButtonDown 1 \n" );
+
+
+ int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+ GObjectController *cont = GetGBlackBoxControlerPointedByMouse();
+
+ if (GetGBlackBoxControlerPointedByMouse()!=NULL)
+ {
+ int state=cont->getView()->getState() ;
+ if( (ctrlkey==0) && (state==HIGHLIGHTED) )
+ {
+ UnSelectBlackBoxes();
+ }
+ }
+
+
+ for (int i = 0; i < (int)_selectedObjects.size(); i++)
+ {
+ int id = _selectedObjects[i];
+ GObjectController* cont = _controllers[id];
+ cont->getView()->setState(DRAG);
+ cont->getModel()->notifyObservers(_idManager);
+ } // for
+
+printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" );
+
return true;
}
//=========================================================================
-
+
bool wxVtkSceneManager::OnLeftButtonUp()
{
if(_worldState == DRAG_OBJECTS)
{
_worldState=NOTHING_HAPPENS;
//int lastId = _controllers.size()-1;
+
GConnectorController *connector = (GConnectorController*)_controllers[_idConnectionInCreation];
connector->removeFromScene();
unregisterController(connector);
- _controllers.erase(_idConnectionInCreation);
+ _controllers.erase(_idConnectionInCreation);
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
}
}
-
+
for (int i = 0; i < (int)_selectedObjects.size(); i++)
{
int id = _selectedObjects[i];
//=========================================================================
+ GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse()
+ {
+ GObjectController *result=NULL;
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ std::map<int, GObjectController*>::iterator it;
+
+ for(it = _controllers.begin(); it != _controllers.end() ; ++it)
+ {
+ GObjectController *cont = it->second;
+ int type = cont->getGObjectType();
+
+ if( cont->getView()->isPointInside(X,Y)==true )
+ {
+ if(type==GBLACKBOX)
+ {
+ result=cont;
+ } // if type
+ } // if isPointInside
+ } // for it
+ return result;
+ }
+
+ //=========================================================================
+ bool wxVtkSceneManager::UnSelectBlackBoxes()
+ {
+ for (int i=0; i< (int)_selectedObjects.size(); i++)
+ {
+ int id = _selectedObjects[i];
+ GObjectController* control = _controllers[id];
+ control->getView()->setState(NOTHING_HAPPENS);
+ }// for _selectedObjects
+ _selectedObjects.clear();
+ }
+
+ //=========================================================================
bool wxVtkSceneManager::OnLeftDClick()
{
+ GObjectController *cont = GetGBlackBoxControlerPointedByMouse();
+ if (cont!=NULL)
+ {
+ UnSelectBlackBoxes();
+ _parent->editBlackBox( (GBlackBoxModel*)cont->getModel() );
+ }
+
+/*EED Borrame
+
int X,Y;
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
{
GObjectController *cont = it->second;
int type = cont->getGObjectType();
-
+
if(cont->getView()->isPointInside(X,Y))
{
if(type==GBLACKBOX)
GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel();
_parent->editBlackBox(bbmodel);
}
- clickOnObject = true;
+ clickOnObject = true;
}
}
{
//_parent->editDiagramParameters(this);
}
-
+*/
return true;
}
-
+
//=========================================================================
bool wxVtkSceneManager::OnChar()
- {
+ {
char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
-
+
// KeyCode 127 : Delete Key
// KeyCode 8 : Backspace Key
if(keyCode == 8 || keyCode == 127)
{
for(int i=0;i<(int)_selectedObjects.size();i++)
{
- int id = _selectedObjects[i];
+ int id = _selectedObjects[i];
std::map<int,GObjectController*>::iterator it;
it = _controllers.find(id);
if (it!=_controllers.end())
void wxVtkSceneManager::AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id)
{
-
+
int i;
bool ok=true;
for(i=0 ; i < (int)controllersToRemove->size() ; i++ )
ok=false;
}
}
-
+
if (ok==true)
{
controllersToRemove->push_back( id );
}
-
+
}
-
+
//=========================================================================
-
+
void wxVtkSceneManager::deleteObject(int id)
{
GObjectController *control = _controllers[id];
{
GBoxModel *bbmod = (GBoxModel*)control->getModel();
std::vector<GPortModel*> inputs = bbmod->getInputPorts();
-
+
bool boxConnected = false;
// Add box input controllers to be removed
AddControlerToBeRemove( &controllersToRemove, bbmod->getObjectId() );
}
else if(control->getGObjectType()==GCONNECTOR)
- {
+ {
GConnectorModel *conMod = (GConnectorModel*)control->getModel();
AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() );
}
-
+
std::map<int,GObjectController*>::iterator it;
for(int i = 0;i<(int)controllersToRemove.size();i++)
if(cont!=NULL)
{
cont->removeFromScene();
- unregisterController((InteractorStyleMaracas*)cont);
+ unregisterController((InteractorStyleMaracas*)cont);
_controllers.erase(it);
}//if
}// for
_parent->updateStatusBar(textStatus);
}
+
+ //=========================================================================
+ std::string wxVtkSceneManager::LineNumber(bool withLineNumber, int &value)
+ {
+ std::string result="";
+ if (withLineNumber==true)
+ {
+ value++;
+ stringstream StrStream;
+ StrStream << value;
+ std::string strValue=StrStream.str();
+ if (value<10)
+ {
+ result+=" ";
+ }else if (value<100)
+ {
+ result+=" ";
+ }
+
+ result+=strValue+": ";
+ }
+ return result;
+ }
//=========================================================================
- std::string wxVtkSceneManager::getDiagramBBS()
+ std::string wxVtkSceneManager::getDiagramBBS(bool wln)
{
bool existsExec=false;
if(type==GBLACKBOX)
{
GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
-
+
std::string pkg = mod->getBBTKPackage();
bool existsPkg = false;
for(int t = 0;t< (int)packages.size() && existsPkg == false;t++)
}
}
+ int lnNmbr=0;
std::string script = "";
- script+="# BBTK GEditor Script\n";
- script+="# ----------------------\n";
- script+="\n";
+ script+=LineNumber(wln,lnNmbr)+"# BBTK GEditor Script\n";
+ script+=LineNumber(wln,lnNmbr)+"# ----------------------\n";
+ script+=LineNumber(wln,lnNmbr)+"\n";
if(existsExec)
{
- script+="include std\n"; // EED
- script+="include itkvtk\n"; // EED
+ script+=LineNumber(wln,lnNmbr)+"include std\n"; // EED
+ script+=LineNumber(wln,lnNmbr)+"include itkvtk\n"; // EED
int i;
for(i = 0; i< (int)packages.size();i++)
{
+ script+=LineNumber(wln,lnNmbr);
script+="include ";
script+=packages[i];
script+="\n";
}
+
+ script+=LineNumber(wln,lnNmbr);
script+="\n";
// script+="include std\n"; // JPR
for(i = 0; i < (int)boxes.size();i++)
{
+ script+=LineNumber(wln,lnNmbr);
script+="new ";
int id = boxes[i];
GObjectController *control = _controllers[id];
GPortModel* inputPort = inputs[j];
if(inputPort->isValueSet())
{
+ script+=LineNumber(wln,lnNmbr);
script+=" set ";
script+=model->getBBTKName();
script+=".";
script+="\n";
}
}
+
+ script+=LineNumber(wln,lnNmbr);
script+="\n";
}
+ script+=LineNumber(wln,lnNmbr);
script+="\n";
for(i = 0; i<(int)connections.size();i++)
{
+ script+=LineNumber(wln,lnNmbr);
script+="connect ";
int id = connections[i];
GObjectController *control = _controllers[id];
script+="\n";
}
+ script+=LineNumber(wln,lnNmbr);
script+="\n";
for(i = 0; i<(int)execBoxes.size();i++)
{
+ script+=LineNumber(wln,lnNmbr);
script+="exec ";
int id = execBoxes[i];
GObjectController *control = _controllers[id];
if(type==GBLACKBOX)
{
GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
-
+
std::string pkg = mod->getBBTKPackage();
bool existsPkg = false;
for(int t = 0;t<(int)packages.size() && existsPkg == false;t++)
}
script+="\n";
-
+
for(i = 0; i<(int)execBoxes.size();i++)
{
script+="exec ";
script+="\n";
script+="endefine";
- script+="\n";
+ script+="\n";
return script;
}
//=========================================================================
void wxVtkSceneManager::deleteAllBoxes()
- {
+ {
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
cont->removeFromScene();
unregisterController((InteractorStyleMaracas*)cont);
}
_selectedObjects.clear();
- _controllers.clear();
+ _controllers.clear();
refreshScene();
}
//=========================================================================
-
+
void wxVtkSceneManager::refresh()
{
_baseView->Refresh();
{
_baseView->RefreshView();
}
-
+
//=========================================================================
-
+
void wxVtkSceneManager::centerView()
{
double temp[3];
sprintf (buffer, "%d", insize);
content+=buffer;
content+="\n";
-
+
for(int i = 0;i<insize;i++)
{
int id = inputs[i];
sprintf (buffer, "%d", outsize);
content+=buffer;
content+="\n";
-
+
for(int i = 0;i<outsize;i++)
{
int id = outputs[i];
sprintf (buffer, "%d", bsize);
content+=buffer;
content+="\n";
-
+
for(int i = 0;i<bsize;i++)
{
int id = boxes[i];
sprintf (buffer, "%d", csize);
content+=buffer;
content+="\n";
-
+
for(int i = 0;i<csize;i++)
{
int id = connections[i];
void wxVtkSceneManager::loadDiagram(ifstream &inputStream)
{
- std::string line="";
+ std::string line="";
char delims[] = ":";
char *result = NULL;
getline(inputStream,line);
bool start = false;
- while ( !inputStream.eof() )
+ while ( !inputStream.eof() )
{
if(line=="" || line[0]=='#')
{
strcpy( inputs, line.c_str() );
result = strtok( inputs, delims );
result = strtok( NULL, delims );
-
+
int numInputs;
std::istringstream inps(result);
inps >> numInputs;
-
+
for(int i = 0;i<numInputs;i++)
{
//----------
configGComBoxInputOutputPort(true, inputPortName,xIn,yIn,zIn);
-
+
} // for input complex box
strcpy( outputs, line.c_str() );
result = strtok( outputs, delims );
result = strtok( NULL, delims );
-
+
int numOutputs;
std::istringstream outps(result);
outps >> numOutputs;
-
+
for(int i = 0;i<numOutputs;i++)
{
//----------
strcpy( boxes, line.c_str() );
result = strtok( boxes, delims );
result = strtok( NULL, delims );
-
+
int numBoxes;
std::istringstream is(result);
is >> numBoxes;
-
+
for(int i = 0;i<numBoxes;i++)
{
//----------
getline(inputStream,line);//ISEXEC:TRUE|FALSE
char exec[15];
strcpy( exec, line.c_str() );
- result = strtok( exec, delims );//ISEXEC
+ result = strtok( exec, delims );//ISEXEC
result = strtok( NULL, delims );//TRUE|FALSE
std::string isExec(result);
ySt >> yIn;
std::istringstream zSt(zInic);
zSt >> zIn;
-
+
//----------
getline(inputStream,line);//xEnd:yEnd:zEnd
strcpy( coord, line.c_str() );
{
boxExecutable= true;
}
-
+
int idBox = createGBlackBox(xIn,yIn,package,type);
configGBlackBox(idBox, xIn,yIn,zIn,name, boxExecutable,xEn,yEn,zEn);
-
+
GObjectController *cont = _controllers[idBox];
GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel();
-
+
//----------
getline(inputStream,line);//PORT o FIN_BOX
std::string port=line.substr(0,4);
result = strtok( NULL, delims );//value
std::string value(result);
- bbmod->setValueToInput(name,value);
+ bbmod->setValueToInput(name,value);
getline(inputStream,line);//PORT o FIN_BOX
port=line.substr(0,4);
- } // while
+ } // while
//EED bbmod->notifyObservers(_idManager);
} // for boxes
strcpy( conns, line.c_str() );
result = strtok( conns, delims );
result = strtok( NULL, delims );
-
+
int numConns;
std::istringstream isCons(result);
isCons >> numConns;
-
+
for(int i = 0;i<numConns;i++)
{
//----------
configGConnetion(nameStartBox, nameStartPort, nameEndBox, nameEndPort);
} // for numConns
-
+
} // start
}
//=========================================================================
-
-
- //=========================================================================
+
+
+ //=========================================================================
void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput, std::string portName, double xIn, double yIn,double zIn)
{
int idPort;
GObjectController *cont = _controllers[idPort];
GBoxModel *cbmod = (GBoxModel*)cont->getModel();
cbmod->setInicPoint(xIn,yIn,zIn);
- cbmod->notifyObservers(_idManager);
+ cbmod->notifyObservers(_idManager);
}
//=========================================================================
-
-
+
+
//=========================================================================
GBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
- {
+ {
int j;
int idB;
GBoxModel *bMod;
GBoxModel *boxModel = NULL;
- std::vector<int> lstB = getBlackBoxes();
+ std::vector<int> lstB = getBlackBoxes();
for(j = 0;j<(int)lstB.size();j++)
{
idB = lstB[j];
boxModel = bMod;
}
} // for
-
+
if((_isComplexBox) && (boxModel==NULL))
{
std::vector<int> lstInputs = getComplexInputPorts();
if(_controllers[idB]->getModel()->getBBTKName()==boxname)
{
boxModel = bMod;
- }
+ }
} // for
-
+
std::vector<int> lstOutputs = getComplexOutputPorts();
for(j = 0;j<(int)lstOutputs.size();j++)
{
int idB = lstOutputs[j];
bMod = (GBoxModel*)_controllers[idB]->getModel();
if(_controllers[idB]->getModel()->getBBTKName()==boxname)
- {
+ {
boxModel = bMod;
- }
+ }
} // for
-
+
} // complex box
return boxModel;
}
-
+
//=========================================================================
- void wxVtkSceneManager::configGConnetion(std::string nameStartBox, std::string nameStartPort, std::string
+ void wxVtkSceneManager::configGConnetion(std::string nameStartBox, std::string nameStartPort, std::string
nameEndBox, std::string nameEndPort)
{
- printf("EED wxVtkSceneManager::configGConnetion 1 %s %s %s %s\n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str() );
-
+
GBoxModel *boxModel;
GPortModel *startP = NULL;
GPortModel *endP = NULL;
-
+
boxModel= findGBox(nameStartBox);
if (boxModel!=NULL)
{
endP = boxModel->getInputPort(nameEndPort);
}
-
- printf("EED wxVtkSceneManager::configGConnetion 2 %p %p \n", startP, endP );
-
int idCon = createGConnector(startP);
_worldState = NOTHING_HAPPENS;
- GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
-
+ GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
+
GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
tempp->endContourCreation();
- conMod->setEndPort(endP);
- conView->updateStartEndPoints();
+ conMod->setEndPort(endP);
+ conView->updateStartEndPoints();
}
//=========================================================================
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
if(cont->getModel()->getBBTKName()==boxname)
{
ok=true;
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
if(cont->getGObjectType()==GBLACKBOX)
{
vect.push_back(cont->getId());
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
if(cont->getGObjectType()==GCOMPLEXINPUTPORT)
{
vect.push_back(cont->getId());
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
if(cont->getGObjectType()==GCOMPLEXOUTPUTPORT)
{
vect.push_back(cont->getId());
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
if(cont->getGObjectType()==GCONNECTOR)
{
vect.push_back(cont->getId());
}
//=========================================================================
-
+
bool wxVtkSceneManager::isComplexBox()
{
return _isComplexBox;
{
_isComplexBox=val;
}
-
+
//=========================================================================
int wxVtkSceneManager::addObjectController(GObjectController* objController)
//Register the controller of the new object
registerController((InteractorStyleMaracas*) objController);
- //Add the object to the objects list
+ //Add the object to the objects list
int newId = _contLastId;//_controllers.size();
objController->setId(newId);
_controllers[newId] = objController;
std::map<int, GObjectController*>::iterator it;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
- GObjectController *cont = it->second;
+ GObjectController *cont = it->second;
if(cont->getGObjectType()==GBLACKBOX && cont->getView()->getState()==SELECTED)
{
mapSelected[cont->getId()]=cont;
std::map<int, GObjectController*>::iterator it2;
for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
{
- GObjectController *cont = it2->second;
+ GObjectController *cont = it2->second;
if(cont->getGObjectType()==GCONNECTOR)
{
GConnectorModel* cmod = (GConnectorModel*)cont->getModel();
std::map<int, GObjectController*>::iterator iterOBJ1 = mapSelected.find(startPortParentBox->getObjectId());
std::map<int, GObjectController*>::iterator iterOBJ2 = mapSelected.find(endPortParentBox->getObjectId());
-
+
if(iterOBJ1 != mapSelected.end() && iterOBJ2 != mapSelected.end())
- {
+ {
int ID = cont->getId();
mapSelected[ID]=cont;
- }
+ }
}
}
return mapSelected;
void wxVtkSceneManager::addObjects(std::map<int,GObjectController*> objectsMap)
{
-
+
std::map<int,int> oldIdNewIdBoxes;
std::vector<int> connections;
- std::map<int, GObjectController*>::iterator it;
+ std::map<int, GObjectController*>::iterator it;
for(it = objectsMap.begin(); it != objectsMap.end(); ++it)
{
GObjectController *cont = it->second;
int idcB = copyBox->getObjectId();
oldIdNewIdBoxes[idcB]=idBox;
- cont = _controllers[idBox];
+ cont = _controllers[idBox];
GBlackBoxModel* newbox = (GBlackBoxModel*)cont->getModel();
- newbox->setInicPoint(xInic,yInic,zInic);
+ newbox->setInicPoint(xInic,yInic,zInic);
int num = newbox->getNumInputPorts();
for(int j=0;j<num;j++)
{
int idCon = cont->getId();
connections.push_back(idCon);
}
-
+
}
-
+
for(int i = 0 ;i<(int)connections.size();i++)
{
int objId = connections[i];
- GObjectController *cont = objectsMap[objId];
+ GObjectController *cont = objectsMap[objId];
GConnectorModel* connectModel = (GConnectorModel*)cont->getModel();
-
+
GPortModel* startPort = connectModel->getStartPort();
int startPortIndex = startPort->getPosInBox();
GPortModel* endPort = connectModel->getEndPort();
- int endPortIndex = endPort->getPosInBox();
+ int endPortIndex = endPort->getPosInBox();
GBlackBoxModel* startPortParentBox = (GBlackBoxModel*)startPort->getParentBox();
GBlackBoxModel* endPortParentBox = (GBlackBoxModel*)endPort->getParentBox();
-
+
int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
- // Creates connection
+ // Creates connection
int idCon = createGConnector(newStartPort);
- GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
+ GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
tempp->endContourCreation();
- conMod->setEndPort(newEndPort);
+ conMod->setEndPort(newEndPort);
conView->updateStartEndPoints();
}
- std::map<int, int>::iterator itIds;
+ std::map<int, int>::iterator itIds;
for(itIds = oldIdNewIdBoxes.begin(); itIds != oldIdNewIdBoxes.end(); ++itIds)
{
int idOld = itIds->first;
if(exist==false)
{
- //Create complex input
+ //Create complex input
int posInBox = oldInputConnections[k];
GPortModel* inputPort = oldBox->getInputPort(posInBox);
std::string inputPortName = inputPort->getBBTKName();
yIn+=20;
cbmod->setInicPoint(xIn,yIn,zIn);
cbmod->notifyObservers(_idManager);
-
+
GPortModel* inputPortEnd = newBox->getInputPort(posInBox);
- // Creates connection
+ // Creates connection
int idCon = createGConnector(cbmod->getOutputPort(0));
- GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
+ GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
tempp->endContourCreation();
- conMod->setEndPort(inputPortEnd);
+ conMod->setEndPort(inputPortEnd);
conView->updateStartEndPoints();
}
-
+
}
-
+
for(int k = 0; k<(int)oldOutputConnections.size();k++)
{
if(exist==false)
{
- //Create complex output
+ //Create complex output
int posInBox = oldOutputConnections[k];
GPortModel* outputPort = oldBox->getOutputPort(posInBox);
std::string outputPortName = outputPort->getBBTKName();
yIn-=20;
cbmod->setInicPoint(xIn,yIn,zIn);
cbmod->notifyObservers(_idManager);
-
+
GPortModel* outputPortEnd = newBox->getOutputPort(posInBox);
- // Creates connection
+ // Creates connection
int idCon = createGConnector(outputPortEnd);
- GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
+ GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
tempp->endContourCreation();
- conMod->setEndPort(cbmod->getInputPort(0));
+ conMod->setEndPort(cbmod->getInputPort(0));
conView->updateStartEndPoints();
}
-
+
}
}
}
- //=========================================================================
+ //=========================================================================
} // EO namespace bbtk
-/*=========================================================================
+/*=========================================================================
Program: bbtk
Module: $RCSfile$
Language: C++
* 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
+* 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.
+* 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 Class bbtk::BlackBox : abstract black-box interface.
+* \file
+* \brief Class bbtk::BlackBox : abstract black-box interface.
*/
/****
class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
{
- public:
+ public:
wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
~wxVtkSceneManager();
virtual bool OnChar();
virtual bool OnMouseMove();
- virtual bool OnLeftButtonDown();
+ virtual bool OnLeftButtonDown();
virtual bool OnLeftButtonUp();
virtual bool OnRightButtonUp();
virtual bool OnLeftDClick();
int createGConnector(GPortModel* startPort);
void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
- void configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string
+ void configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string
nameEndBox, std::string nameEndPort);
void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
GBoxModel* findGBox(std::string boxname);
-
-
+
+
vtkRenderWindow* getRenderWindow();
- vtkRenderer* getRenderer();
+ vtkRenderer* getRenderer();
virtual void update(int idController,int command);
//-------
//Returns a string with the BBS script of the current diagram.
- std::string getDiagramBBS();
+ std::string getDiagramBBS(bool wln=false);
//Returns a string with the BBS script of the complex box.
std::string saveComplexBoxBBS(std::string cbName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription="");
//Delete the object in the list of controllers with the id given by parameter.
void deleteObject(int id);
-
+
void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
//Clear list of controllers and refresh
//Save the diagram in the BBG format, in the string given by param.
void saveDiagram(std::string &content);
- //Load the diagram
+ //Load the diagram
void loadDiagram(ifstream &inputStream);
//Center the view of the camera in the initial position
//Saves the id's of the selected objects in the controllers map
std::vector<int> _selectedObjects;
- //Is the diagram in state complex box
+ //Is the diagram in state complex box
bool _isComplexBox;
int _idConnectionInCreation;
int _contLastId;
-
+
vtkTextActor3D *_textActor;
vtkPoints *_pts;
vtkActor *_fillObjectActor;
vtkDataSetMapper *_aPolygonMapper;
+ std::string LineNumber(bool withLineNumber, int &value);
+ int GetIndexInSelected(int idControler);
+ bool UnSelectBlackBoxes();
+ GObjectController *GetGBlackBoxControlerPointedByMouse();
+
+
protected:
};