]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx
Setting values in a blackbox and almost setting values in the scene properties
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxEditionDialog.cxx
diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx
new file mode 100644 (file)
index 0000000..66a8fb0
--- /dev/null
@@ -0,0 +1,159 @@
+/*=========================================================================                                                                               
+Program:   bbtk
+Module:    $RCSfile$
+Language:  C++
+Date:      $Date$
+Version:   $Revision$
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+*  This software is governed by the CeCILL-B license under French law and 
+*  abiding by the rules of distribution of free software. You can  use, 
+*  modify and/ or redistribute the software under the terms of the CeCILL-B 
+*  license as circulated by CEA, CNRS and INRIA at the following URL 
+*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+*  or in the file LICENSE.txt.
+*
+*  As a counterpart to the access to the source code and  rights to copy,
+*  modify and redistribute granted by the license, users are provided only
+*  with a limited warranty  and the software's author,  the holder of the
+*  economic rights,  and the successive licensors  have only  limited
+*  liability. 
+*
+*  The fact that you are presently reading this means that you have had
+*  knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */                                                                         
+
+/**
+*  \file 
+*  \brief Class bbtk::wxEditionDialog . 
+*/
+
+
+#include "wxEditionDialog.h"
+
+
+namespace bbtk
+{
+       //=========================================================================
+
+       wxEditionDialog::wxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,"", wxDefaultPosition, wxSize(480, 640))
+       {
+               _model=model;
+               std::string title = "BlackBox Editing - Name:";
+               title+=_model->getBBTKName();
+               title+=" Type:";
+               title+=_model->getBBTKType();
+               SetTitle(wxT(title));
+
+               constructBlackBoxEditionDialog();
+       }
+
+       //=========================================================================
+
+       wxEditionDialog::wxEditionDialog(wxGUIEditorGraphicBBS *parent,wxVtkSceneManager* scene):wxDialog(parent, wxID_ANY, "", wxDefaultPosition, wxSize(300, 300))
+       {
+               
+       }
+
+       //=========================================================================
+
+       wxEditionDialog::~wxEditionDialog()
+       {
+
+       }
+
+       //=========================================================================
+
+       void wxEditionDialog::constructBlackBoxEditionDialog()
+       {
+               wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL);
+
+               wxStaticText *text = new wxStaticText(this, -1, wxT("Input Ports"));
+                               
+               std::vector<GPortModel*> lstInputs = _model->getInputPorts();
+               wxGridSizer *sizer = new wxGridSizer(lstInputs.size(),3,5,5);             
+               for(int i = 0;i<lstInputs.size();i++)
+               {
+                       GPortModel* port = lstInputs[i];
+                       wxStaticText *lblName = new wxStaticText(this, -1, wxT(port->getBBTKName()),wxDefaultPosition,wxSize(100,30));
+                       wxStaticText *lblType = new wxStaticText(this, -1, wxT(port->getBBTKType()),wxDefaultPosition,wxSize(150,30));
+                       wxTextCtrl *txtValue = new wxTextCtrl(this, -1, wxT(""),wxDefaultPosition,wxSize(50,15));
+
+                       if(port->getValue()!="")
+                       {
+                               txtValue->SetLabel(wxT(port->getValue()));
+                       }
+
+                       if(port->isConnected())
+                       {
+                               std::string connected = "--Port Connected--";
+                               txtValue->SetLabel(wxT(connected));
+                               txtValue->SetEditable(false);
+                       }
+
+                       _lstNames.push_back(lblName);
+                       _lstTypes.push_back(lblType);
+                       _lstValues.push_back(txtValue);
+
+                       sizer->Add(lblName,0,wxEXPAND,5);
+                       sizer->Add(lblType,0,wxCENTRE|wxEXPAND,5);
+                       sizer->Add(txtValue,0,wxEXPAND,5);
+
+               }
+               
+               wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL);
+               wxButton *okButton = new wxButton(this, 1003, wxT("Ok"),wxDefaultPosition, wxSize(70, 30));
+               wxButton *closeButton = new wxButton(this, 1004, wxT("Close"), wxDefaultPosition, wxSize(70, 30));
+
+               // connect command event handlers
+               Connect(1003,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxEditionDialog::onClickOk));
+               Connect(1004,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxEditionDialog::onClickClose));
+               
+               buts->Add(okButton,0,wxCENTRE|wxEXPAND,5);
+               buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5);
+
+               sizerDialog->Add(text,0,wxALIGN_TOP,10);
+               sizerDialog->AddSpacer(5);
+               sizerDialog->Add(sizer,0,wxALIGN_CENTER,10);
+               sizerDialog->Add(buts,0,wxALIGN_CENTER | wxTOP | wxBOTTOM,10);
+
+               SetSizer(sizerDialog);
+
+               Centre();
+               ShowModal();
+               Destroy();
+
+       }
+
+       //=========================================================================
+
+       void wxEditionDialog::onClickOk(wxCommandEvent& event)
+       {
+
+               for(int i=0;i<_lstValues.size();i++)
+               {
+                       std::string text = _lstValues[i]->GetLabelText();               
+                       _model->setValueToInputPort(i,text);
+               }
+
+               Close(true);
+       }
+
+       //=========================================================================
+
+       void wxEditionDialog::onClickClose(wxCommandEvent& event)
+       {
+               Close(true);            
+       }
+
+       //=========================================================================
+
+}  // EO namespace bbtk
+
+// EOF
+