X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOWxGimmickView.cpp;h=2d8785147b5754b69a9c2d69bc715f89acbd8f31;hb=eb57b703668a22b19df49f57aeb0bca95f048029;hp=900101ad1a4cdc848fa05489766bb0d3382689ea;hpb=f1caae70392f96f30dd90eb073be6be10fbf1caa;p=creaImageIO.git diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index 900101a..2d87851 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -15,6 +15,7 @@ using namespace crea; namespace creaImageIO { + //====================================================================== // The ids of the different tools enum @@ -61,11 +62,13 @@ namespace creaImageIO wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, - int image_type, + int min_dim, + int max_dim, int number_of_threads) : wxPanel(parent,id,pos,size), - GimmickView(gimmick), - mProgressDialog(0) + GimmickView(gimmick, number_of_threads), + mProgressDialog(0), + mConstructed(false) { GimmickDebugMessage(1,"WxGimmickView::WxGimmickView" <SetImageVector(pointers); + mViewer->StartPlayer(); + + + bottom_sizer->Add(mViewer,1,wxGROW,1); + // mViewer->Show(); + + mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!")); + bottom_sizer->Add(mText,0,wxGROW,0); + + + + mBottomPanel->SetSizer(bottom_sizer); // Splitting int hsize = size.GetHeight(); - int bottom_minsize = 200; + + int top_minsize = 450; + int bottom_minsize = 50; mSplitter->SetMinimumPaneSize( bottom_minsize ); mSplitter->SplitHorizontally( mNotebook, mBottomPanel, - hsize - bottom_minsize); - + top_minsize); + sizer->Add( mSplitter,1,wxGROW ,0); SetSizer( sizer ); SetAutoLayout(true); Layout(); - + + mConstructed = true; } //====================================================================== @@ -179,7 +209,7 @@ namespace creaImageIO GimmickMessage(2,"Creating the tree view for '"<< name<<"'"<AddPage( view, crea::std2wx(name) ); } - //====================================================================== - - + //====================================================================== + /// Returns the selected Images so that they comply with the given parameter(4D) + void WxGimmickView::GetSelectedImages(std::vector& s, int dim) + { + int level=GetTreeViewMap()["Local database"]->GetNumberOfLevels(); + std::vector im=GetTreeViewMap()["Local database"]->GetSelected(level+1); + ReadImagesNotThreaded(s,im,dim); + } + //====================================================================== + /// Returns the selected Images so that they comply with the given parameter(4D) + void WxGimmickView::GetSelectedFiles(std::vector& s) + { + GetTreeViewMap()["Local database"]->GetSelectedAsString(s); + } //================================================= void WxGimmickView::CreateIconList() { @@ -263,8 +304,8 @@ namespace creaImageIO 1000, this, wxPD_ELAPSED_TIME | - wxPD_ESTIMATED_TIME | - wxPD_REMAINING_TIME | + // wxPD_ESTIMATED_TIME | + // wxPD_REMAINING_TIME | wxPD_CAN_ABORT ); // TO DO : select the current tree handler @@ -274,30 +315,7 @@ namespace creaImageIO UpdateTreeViewLevel("Local database",1); delete mProgressDialog; - - /* - TreeItemData *data = - (TreeItemData *) - mTreeListCtrl->GetItemData(mItemOfMenu); - DicomDatabase* db = data->GetDicomNode()->GetDicomDatabase(); - DicomDatabase::UpdateSummary summary; - wxProgressDialog* progress = - new wxProgressDialog(_T("Adding file(s)"), - _T(""), - 1000, - this, - wxPD_ELAPSED_TIME | - wxPD_ESTIMATED_TIME | - wxPD_REMAINING_TIME | - wxPD_CAN_ABORT ); - - db->AddFiles(filenames,progress,summary); - - progress->Pulse(_T("Updating view...")); - UpdateDicomDatabaseView(db); - delete progress; - DisplayUpdateSummary(summary,this); - */ + DisplayAddSummary(); } } @@ -334,8 +352,8 @@ namespace creaImageIO 1000, this, wxPD_ELAPSED_TIME | - wxPD_ESTIMATED_TIME | - wxPD_REMAINING_TIME | + // wxPD_ESTIMATED_TIME | + // wxPD_REMAINING_TIME | wxPD_CAN_ABORT ); std::string dirname = wx2std (FD->GetPath()) ; mCurrentDirectory = FD->GetPath(); @@ -347,8 +365,190 @@ namespace creaImageIO UpdateTreeViewLevel("Local database",1); delete mProgressDialog; + DisplayAddSummary(); + } + } + //================================================= + + //================================================= + void WxGimmickView::OnSelectionChange(std::vector& sel, bool isSelection, int selection, bool needProcess) + { + GimmickDebugMessage(5, + "WxGimmickView::OnSelectionChange" + <::iterator i; + for(i=sel.begin();i!=sel.end()&&valid;++i) + { + valid= ValidateSelected((*i), + mSelectionMinDimension, + mSelectionMaxDimension ); + } + } + else if(isSelection) + { + valid= ValidateSelected(sel.front(), + mSelectionMinDimension, + mSelectionMaxDimension ); + } + else + { + ClearStatus(); + std::vector::iterator i; + for(i=sel.begin();i!=sel.end()&&valid;++i) + { + valid= ValidateSelected((*i), + mSelectionMinDimension, + mSelectionMaxDimension ); + } + } + + mText->SetLabel(crea::std2wx(GetMessage())); + /*if(valid) + { + ReadImageThreaded(sel); } + else + { + ClearSelection(); + }*/ + ReadImageThreaded(sel); + + + } + + //================================================== + + //================================================== + ///Reads Images (Threaded) + void WxGimmickView::ReadImageThreaded(std::vector sel) + { + GimmickDebugMessage(5, + "ReadImageThreaded" + <0) + { + //First load the selected images + mCurImageItemToShow = sel.front(); + pointers.clear(); + int index = 0; + std::vector::iterator selected; + for(selected=sel.begin();selected!=sel.end();++selected) + { + GimmickDebugMessage(5, + "Requesting image from selected " + <<(*selected)->GetAttribute("FullFileName") + <SetImageVector(pointers); + //Going up + prio = maxprio + 20; + std::vector up; + GetTreeViewMap()["Local database"]->GetNodes(up,true); + std::vector::iterator iterUp; + for(iterUp=up.begin();iterUp!=up.end();++iterUp) + { + GimmickDebugMessage(5, + "Requesting image from neighbors up " + <<(*iterUp)->GetAttribute("FullFileName") + < down; + GetTreeViewMap()["Local database"]->GetNodes(down,false); + std::vector::iterator iterDown; + for(iterDown=down.begin();iterDown!=down.end();++iterDown) + { + GimmickDebugMessage(5, + "Requesting image from neighbors down " + <<(*iterDown)->GetAttribute("FullFileName") + <SetImageVector(pointers); + } + } + + //================================================== + + //================================================== + + //================================================== + void WxGimmickView::OnInternalIdle() + { + if (!mConstructed) return; + static bool first_time = true; + if (false) + { + first_time = false; + } + // GimmickMessage(1,"WxGimmickView : Refresh viewer"<StartPlayer(); + if(mViewer) + { + mViewer->RefreshIfNecessary(); + } + } + + //================================================== + + //================================================== + void WxGimmickView::ClearSelection() + { + pointers.clear(); + pointers.push_back(new ImagePointerHolder(GetDefaultImage())); + mViewer->SetImageVector(pointers); + mViewer->RefreshIfNecessary(); + ClearStatus(); + } + + //================================================= + + //================================================= + void WxGimmickView::OnRemove(wxCommandEvent& event) + { + //TODO Select current tree handler + wxBusyCursor busy; + GetTreeViewMap()["Local database"]->RemoveSelected(1); + ClearSelection(); } //================================================= @@ -363,7 +563,7 @@ namespace creaImageIO p.GetNumberScannedFiles(), p.GetNumberHandledFiles(), p.GetNumberAddedFiles()); - std::cout << "OnAddProgress "<Pulse(s)) @@ -374,11 +574,41 @@ namespace creaImageIO } //================================================= - //================================================= + //================================================= + void WxGimmickView::DisplayAddSummary() + { + const Gimmick::AddProgress& p = mGimmick->GetAddProgress(); + std::stringstream mess; + mess << "Dirs \tscanned\t: " << p.GetNumberScannedDirs() << "\n"; + mess << "Files\tscanned\t: " << p.GetNumberScannedFiles() << "\n"; + mess << "Files\thandled\t: " << p.GetNumberHandledFiles() << "\n\n"; + mess << "Files\tadded \t: " << p.GetNumberAddedFiles() << "\n\n"; + + /* char times[500]; + sprintf(times,"Time to parse dir \t\t: %ld ms \t%d°/o\nTime to read files info \t: %ld ms \t%d°/o\nTime to update structs \t: %ld ms \t%d°/o\nTime to update database \t: %ld ms \t%d°/o\nTotal time \t\t\t: %ld ms", + summary.parse_time, + (int)( summary.parse_time*100./summary.total_time), + summary.file_scan_time, + (int)(summary.file_scan_time*100./summary.total_time), + summary.update_structs_time, + (int)(summary.update_structs_time*100./summary.total_time), + summary.update_database_time, + (int)(summary.update_database_time*100./summary.total_time), + summary.total_time ); + + mess << times; + */ + wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this); + } + + //================================================= + + //================================================= BEGIN_EVENT_TABLE(WxGimmickView, wxPanel) EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles) EVT_TOOL(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir) - END_EVENT_TABLE() + EVT_TOOL(TOOL_REMOVE_ID, WxGimmickView::OnRemove) + END_EVENT_TABLE() //================================================= } // EO namespace creaImageIO