X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=kernel%2Fsrc%2FbbtkWxGUIPackageBrowser2.cxx;h=5d95e06092ef7c32c6da89eec25c141da3e2ad17;hb=310a70fea52f768e60d0a844e6ef84f13e4babd4;hp=d95d80dee445b049038efc327f155694e990439a;hpb=4ad5b5ee44357ad873bc8c43230defb6d0a79879;p=bbtk.git diff --git a/kernel/src/bbtkWxGUIPackageBrowser2.cxx b/kernel/src/bbtkWxGUIPackageBrowser2.cxx index d95d80d..5d95e06 100644 --- a/kernel/src/bbtkWxGUIPackageBrowser2.cxx +++ b/kernel/src/bbtkWxGUIPackageBrowser2.cxx @@ -1,25 +1,40 @@ -/*========================================================================= - -Program: bbtk -Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $ -Language: C++ -Date: $Date: 2008/04/18 12:59:16 $ -Version: $Revision: 1.5 $ - -Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de -l'Image). All rights reserved. See Doc/License.txt or -http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*//** - * \brief Short description in one line - * - * Long description which - * can span multiple lines - */ +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $ + Language: C++ + Date: $Date: 2008/10/17 08:18:15 $ + Version: $Revision: 1.11 $ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* 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. +* ------------------------------------------------------------------------ */ + + +/* \brief Short description in one line + * + * Long description which + * can span multiple lines + */ + /** * \file * \brief @@ -114,7 +129,7 @@ namespace bbtk if (GetColumnCount()!=3) { InsertColumn( 0, _("Package"), - wxLIST_FORMAT_LEFT, 40 ); + wxLIST_FORMAT_LEFT, 60 ); InsertColumn( 1, _("Box"), wxLIST_FORMAT_LEFT, 200 ); InsertColumn( 2, _("Description"), @@ -127,8 +142,8 @@ namespace bbtk int nID = this->GetItemCount(); kNewItem.SetId(nID); kNewItem.SetMask(wxLIST_MASK_DATA); - // TO DO : STORE SHARED POINTER - // kNewItem.SetData(d.get()); + // TO DO : STORE SMART POINTER ? + kNewItem.SetData(d.get()); // BlackBoxDescriptor::Pointer* d2 = (BlackBoxDescriptor::Pointer*)kNewItem.GetData(); // std::cout << "Descr = "<InsertItem(kNewItem); @@ -193,7 +208,7 @@ namespace bbtk void WxGUIBlackBoxList::LogColEvent(const wxListEvent& event, const wxChar *name) { - const int col = event.GetColumn(); + // const int col = event.GetColumn(); /* wxLogMessage(wxT("%s: column %d (width = %d or %d)."), @@ -229,9 +244,8 @@ namespace bbtk void WxGUIBlackBoxList::OnBeginDrag(wxListEvent& event) { - const wxPoint& pt = event.m_pointDrag; + // const wxPoint& pt = event.m_pointDrag; - int flags; //wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."), // pt.x, pt.y, HitTest(pt, flags) ); } @@ -313,9 +327,9 @@ namespace bbtk info.m_mask = wxLIST_MASK_DATA; if ( GetItem(info) ) { - // TO DO : STORE SHARED - // BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData()); - // if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d); + // TO DO : STORE SMART PTR ? + BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData()); + if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d); } else { @@ -466,7 +480,8 @@ namespace bbtk int flags; long subitem; - long item = HitTest(event.GetPosition(), flags, &subitem); + // long item = + HitTest(event.GetPosition(), flags, &subitem); wxString where; switch ( flags ) @@ -606,7 +621,7 @@ namespace bbtk //================================================================ - void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor::Pointer descr) + void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor* descr) { // mName->SetLabel(std2wx(descr->GetTypeName())); @@ -750,8 +765,12 @@ namespace bbtk id_f3, id_f4, id_f5, - id_f6 - + id_f6, + id_f7, + id_f8, + id_fc1, + id_fc2, + id_fc3 }; @@ -836,8 +855,8 @@ namespace bbtk fsizer->Add(fcat,0,wxGROW); wxBoxSizer *fintype = new wxStaticBoxSizer - ( new wxStaticBox(filters, wxID_ANY, _T("Input type")), wxHORIZONTAL ); - mInputTypeFilter = new wxTextCtrl(filters,id_f4,_T(""), + ( new wxStaticBox(filters, wxID_ANY, _T("Input type")), wxHORIZONTAL ); + mInputTypeFilter = new wxTextCtrl(filters,id_f5,_T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); @@ -846,12 +865,43 @@ namespace bbtk wxBoxSizer *fouttype = new wxStaticBoxSizer ( new wxStaticBox(filters, wxID_ANY, _T("Output type")), wxHORIZONTAL ); - mOutputTypeFilter = new wxTextCtrl(filters,id_f4,_T(""), + mOutputTypeFilter = new wxTextCtrl(filters,id_f6,_T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); fouttype->Add(mOutputTypeFilter,1,wxGROW); fsizer->Add(fouttype,0,wxGROW); + wxBoxSizer *finnat = + new wxStaticBoxSizer + ( new wxStaticBox(filters, wxID_ANY, _T("Input nature")),wxHORIZONTAL ); + mInputNatureFilter = new wxTextCtrl(filters,id_f7,_T(""), + wxDefaultPosition, + wxDefaultSize, + wxTE_PROCESS_ENTER); + finnat->Add(mInputNatureFilter,1,wxGROW); + fsizer->Add(finnat,0,wxGROW); + wxBoxSizer *foutnat = + new wxStaticBoxSizer + ( new wxStaticBox(filters, wxID_ANY,_T("Output nature")),wxHORIZONTAL ); + mOutputNatureFilter = new wxTextCtrl(filters,id_f8,_T(""), + wxDefaultPosition, + wxDefaultSize, + wxTE_PROCESS_ENTER); + foutnat->Add(mOutputNatureFilter,1,wxGROW); + fsizer->Add(foutnat,0,wxGROW); + + + mShowWidgetsFilter = new wxCheckBox(filters,id_fc1,_T("Show widgets")); + mShowWidgetsFilter->SetValue(true); + fsizer->Add(mShowWidgetsFilter,0,wxGROW); + + mShowAdaptorsFilter = new wxCheckBox(filters,id_fc2,_T("Show adaptors")); + mShowAdaptorsFilter->SetValue(false); + fsizer->Add(mShowAdaptorsFilter,0,wxGROW); + + mShowGUIsFilter = new wxCheckBox(filters,id_fc3,_T("Show GUIs")); + mShowGUIsFilter->SetValue(false); + fsizer->Add(mShowGUIsFilter,0,wxGROW); filters->SetSizer(fsizer); @@ -884,7 +934,8 @@ namespace bbtk //================================================================ // User callback when a box is selected in the list - void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer d) + void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected + ( BlackBoxDescriptor* d) { mBoxInfo->UpdateInfo(d); std::string title = d->GetPackage()->GetName()+"::"+d->GetTypeName(); @@ -897,10 +948,10 @@ namespace bbtk //================================================================ WxGUIPackageBrowser2::~WxGUIPackageBrowser2() { - - // std::cout << "del interpreter" << std::endl; - // if (mInterpreter) delete mInterpreter; - // std::cout << "ok" << std::endl; + mFactory.reset(); + mInterpreter.reset(); + // Object::PrintObjectListInfo(""); + m_mgr.UnInit(); } //================================================================ @@ -909,7 +960,10 @@ namespace bbtk { if (!mInterpreter) mInterpreter =bbtk::Interpreter::New(); mInterpreter->SetCommandLine(true); - mInterpreter->InterpretLine("include *"); + std::stringstream* buf = new std::stringstream; + *buf << "message max 0" << std::endl; + *buf << "include *" << std::endl; + mInterpreter->InterpretBuffer(buf); Factory::Pointer F = mInterpreter->GetExecuter()->GetFactory(); BuildFromFactory(F); @@ -956,6 +1010,14 @@ namespace bbtk { // std::cout << " '" << wx2std(mPackageFilter->GetValue())<<"'"<GetPackage()->GetName() << "'"<IsChecked())&& + ((d->GetKind()==BlackBoxDescriptor::ADAPTOR)|| + (d->GetKind()==BlackBoxDescriptor::DEFAULT_ADAPTOR))) + return false; + if ((!mShowGUIsFilter->IsChecked())&& + ((d->GetKind()==BlackBoxDescriptor::GUI)|| + (d->GetKind()==BlackBoxDescriptor::DEFAULT_GUI))) + return false; if (d->GetPackage()->GetName().find( wx2std(mPackageFilter->GetValue()) ) == std::string::npos ) return false; if (d->GetTypeName().find( wx2std(mNameFilter->GetValue()) ) @@ -964,6 +1026,22 @@ namespace bbtk == std::string::npos ) return false; if (d->GetCategory().find( wx2std(mCategoryFilter->GetValue()) ) == std::string::npos ) return false; + if (!mShowWidgetsFilter->IsChecked()) + { + bool found = false; + const BlackBoxDescriptor::OutputDescriptorMapType& imap = + d->GetOutputDescriptorMap(); + BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { + if (in->second->GetName() == "Widget" ) + { + found = true; + break; + } + } + if (found) return false; + } if (mInputTypeFilter->GetValue().size()>0) { std::string s = wx2std(mInputTypeFilter->GetValue()); @@ -998,7 +1076,40 @@ namespace bbtk } if (!found) return false; } - + if (mInputNatureFilter->GetValue().size()>0) + { + std::string s = wx2std(mInputNatureFilter->GetValue()); + bool found = false; + const BlackBoxDescriptor::InputDescriptorMapType& imap = + d->GetInputDescriptorMap(); + BlackBoxDescriptor::InputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { + if (in->second->GetNature().find(s)!=std::string::npos) + { + found = true; + break; + } + } + if (!found) return false; + } + if (mOutputNatureFilter->GetValue().size()>0) + { + std::string s = wx2std(mOutputNatureFilter->GetValue()); + bool found = false; + const BlackBoxDescriptor::OutputDescriptorMapType& imap = + d->GetOutputDescriptorMap(); + BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { + if (in->second->GetNature().find(s)!=std::string::npos) + { + found = true; + break; + } + } + if (!found) return false; + } return true; } @@ -1012,6 +1123,11 @@ namespace bbtk EVT_TEXT_ENTER(id_f4, WxGUIPackageBrowser2::OnFilter ) EVT_TEXT_ENTER(id_f5, WxGUIPackageBrowser2::OnFilter ) EVT_TEXT_ENTER(id_f6, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT_ENTER(id_f7, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT_ENTER(id_f8, WxGUIPackageBrowser2::OnFilter ) + EVT_CHECKBOX( id_fc1, WxGUIPackageBrowser2::OnFilter ) + EVT_CHECKBOX( id_fc2, WxGUIPackageBrowser2::OnFilter ) + EVT_CHECKBOX( id_fc3, WxGUIPackageBrowser2::OnFilter ) END_EVENT_TABLE() //======================================================================== @@ -1036,12 +1152,11 @@ namespace bbtk SetSizer(sizer); - // Creates and sets the parent window of all bbtk windows - wxWindow* top = new wxPanel(this,-1); - top->Hide(); - - Wx::SetTopWindow(top); - + // Creates the parent window of all bbtk windows as a child of this +// Wx::CreateTopWindow(this); + // Add the method OnWxSignal as a Wx::Signal observer + //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal); + SetAutoLayout(true); Layout(); }