creaImageIOWxGimmickPanel.cpp

Go to the documentation of this file.
00001 #include <creaImageIOWxGimmickPanel.h>
00002 #include <creaImageIOSystem.h>
00003 #include <creaImageIOGimmick.h>
00004 #ifdef _DEBUG
00005 #define new DEBUG_NEW
00006 #endif
00007 namespace creaImageIO
00008 {
00009   // CTor
00010   WxGimmickPanel::WxGimmickPanel(wxWindow *parent, 
00011                                  wxWindowID id,
00012                                  const wxPoint& pos,
00013                                  const wxSize& size,
00014                                  const std::string i_namedescp, 
00015                                  const std::string i_namedb,
00016                                  int threads)
00017  :   wxPanel( parent, 
00018               id, 
00019               pos,
00020               size,
00021               wxRESIZE_BORDER | 
00022               wxSYSTEM_MENU   |
00023               wxCLOSE_BOX     |
00024               wxMAXIMIZE_BOX  | 
00025               wxMINIMIZE_BOX  | 
00026               wxCAPTION  
00027               ),
00028      //mGimmick(0),
00029      mView(0)
00030   {
00031     GimmickDebugMessage(1,"WxGimmickPanel::WxGimmickPanel"
00032                         <<std::endl);
00033     wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
00034     
00035     try {
00036             mGimmick = boost::shared_ptr<Gimmick>(new Gimmick());
00037             mGimmick->Initialize(i_namedescp,i_namedb);
00038             int min_dim = GIMMICK_2D_IMAGE_SELECTION;
00039             int max_dim = GIMMICK_3D_IMAGE_SELECTION;
00040             mView = new WxGimmickView(mGimmick,
00041                                 this,
00042                                 -1,
00043                                 wxDefaultPosition,
00044                                 size,
00045                                 min_dim,
00046                                 max_dim,
00047                                 threads);
00048             mView->Initialize();
00049           // Connect the AddProgress callback
00050             mView->ConnectValidationObserver ( boost::bind( &WxGimmickPanel::OnSelectedImage , this, _1 ) );
00051     }
00052     catch (crea::Exception e)
00053     {
00054       e.Print();
00055       return;
00056     }
00057 
00058     topsizer->Add( mView,1,wxGROW,0);
00059 
00060     SetSizer( topsizer );     
00061     Layout(); 
00062   }
00063 
00065   WxGimmickPanel::~WxGimmickPanel()
00066   {
00067     GimmickDebugMessage(1,"WxGimmickPanel::~WxGimmickPanel"
00068                         <<std::endl);
00069     if (mView) 
00070       {
00071         delete mView;
00072       }
00073     if (mGimmick) 
00074       {
00075         mGimmick->Finalize();
00076       }
00077   }
00078   
00079 //======================================================================
00080   
00081 //====================================================================== 
00082   
00084   void WxGimmickPanel::OnSelectedImage(bool t)
00085   {
00086       mSendImageSignal(t);
00087   }
00088 
00089   void WxGimmickPanel::AddImagesToDB(std::string dir)
00090   {
00091       mView->AddDir(dir);
00092   }
00093 
00094   //================================================================
00095   //  BEGIN_EVENT_TABLE(WxGimmickPanel, wxDialog)
00096   //    END_EVENT_TABLE()
00097   //================================================================
00098 
00099 
00100   //====================================================================
00101 
00102   //====================================================================
00103   void WxGimmickPanel::ConnectSendImageObserver(SendImageCallbackType callback)
00104   {
00105       mSendImageSignal.connect(callback);
00106   }
00107 
00108 } // EO namespace creaImageIO
00109 
00110