1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::wxBlackBoxEditionDialog .
36 #include "wxBlackBoxEditionDialog.h"
41 //=========================================================================
43 wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,_T(""), wxDefaultPosition, wxSize(480, 640),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
46 std::string title("BlackBox Editing - Name:");
47 title+=_model->getBBTKName();
49 title+=_model->getBBTKType();
50 SetTitle(std2wx(title));
52 constructBlackBoxEditionDialog();
55 //=========================================================================
57 wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,wxVtkSceneManager* scene):wxDialog(parent, wxID_ANY, _T(""), wxDefaultPosition, wxSize(300, 300))
62 //=========================================================================
64 wxBlackBoxEditionDialog::~wxBlackBoxEditionDialog()
69 //=========================================================================
71 void wxBlackBoxEditionDialog::constructBlackBoxEditionDialog()
73 wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL);
75 wxStaticText *text = new wxStaticText(this, -1, wxT("Input Ports"));
76 wxFont font(11, wxDEFAULT, wxNORMAL, wxBOLD);
79 std::vector<GPortModel*> lstInputs = _model->getInputPorts();
80 wxFlexGridSizer *sizer = new wxFlexGridSizer(lstInputs.size(),3,5,5);
81 for(int i = 0;i<lstInputs.size();i++)
83 GPortModel* port = lstInputs[i];
84 wxStaticText *lblName = new wxStaticText(this, -1, std2wx(port->getBBTKName()),wxDefaultPosition,wxSize(100,25));
85 wxStaticText *lblType = new wxStaticText(this, -1, std2wx(port->getBBTKType()),wxDefaultPosition,wxSize(250,25));
86 wxTextCtrl *txtValue = new wxTextCtrl(this, -1, _T(""),wxDefaultPosition,wxSize(90,25));
88 if(port->getValue()!="")
90 txtValue->SetLabel(crea::std2wx(port->getValue()));
93 if(port->isConnected())
95 std::string connected("--Port Connected--");
96 txtValue->SetLabel(crea::std2wx(connected));
97 txtValue->SetEditable(false);
100 _lstNames.push_back(lblName);
101 _lstTypes.push_back(lblType);
102 _lstValues.push_back(txtValue);
104 sizer->Add(lblName,1,wxEXPAND,5);
105 sizer->Add(lblType,1,wxCENTRE|wxEXPAND,5);
106 sizer->Add(txtValue,1,wxEXPAND,5);
110 wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL);
111 wxButton *okButton = new wxButton(this, 1003, _T("Ok"),wxDefaultPosition, wxSize(70, 30));
112 wxButton *closeButton = new wxButton(this, 1004, _T("Close"), wxDefaultPosition, wxSize(70, 30));
114 // connect command event handlers
115 Connect(1003,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxBlackBoxEditionDialog::onClickOk));
116 Connect(1004,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxBlackBoxEditionDialog::onClickClose));
118 buts->Add(okButton,0,wxCENTRE|wxEXPAND,5);
119 buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5);
121 sizerDialog->AddSpacer(10);
122 sizerDialog->Add(text,0,wxALIGN_TOP|wxALIGN_CENTER);
123 sizerDialog->AddSpacer(15);
124 sizerDialog->Add(sizer,0,wxALIGN_CENTER);
125 sizerDialog->Add(buts,0,wxALIGN_CENTER | wxTOP | wxBOTTOM);
127 SetSizer(sizerDialog);
134 //=========================================================================
136 void wxBlackBoxEditionDialog::onClickOk(wxCommandEvent& event)
139 for(int i=0;i<_lstValues.size();i++)
141 std::string text = wx2std(_lstValues[i]->GetLabelText());
142 _model->setValueToInputPort(i,text);
148 //=========================================================================
150 void wxBlackBoxEditionDialog::onClickClose(wxCommandEvent& event)
155 //=========================================================================
157 } // EO namespace bbtk