X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOWxGimmick.cpp;h=63470ba141b56f8d126d92715499c4a1fc90b79d;hb=2a666dd833520248172d1158171cbb995b7e8ec2;hp=57cf94f1f0ac707a8e0a3cce968615840b61a472;hpb=91c74cbf343af3e44a6b4a242d285d1cebc6d679;p=creaImageIO.git diff --git a/src/creaImageIOWxGimmick.cpp b/src/creaImageIOWxGimmick.cpp index 57cf94f..63470ba 100644 --- a/src/creaImageIOWxGimmick.cpp +++ b/src/creaImageIOWxGimmick.cpp @@ -19,7 +19,8 @@ #include #include -#include +#include +//#include using namespace crea; @@ -62,6 +63,8 @@ namespace creaImageIO PopUp_Settings = 501, PopUp_About = 502, PopUp_User = WxGimmick::UserMenuFirstId, + PopUp_SaveAs = 701, + PopUp_AddToFavorites = 702 }; //================================================================ @@ -209,18 +212,6 @@ namespace creaImageIO - //================================================================ - class WxGimmickSettingsDialog : public wxDialog - { - public: - WxGimmickSettingsDialog(wxWindow *parent); - ~WxGimmickSettingsDialog(); - - - }; - //================================================================ - - @@ -345,9 +336,15 @@ namespace creaImageIO // Image sizer wxBoxSizer *isizer = new wxBoxSizer(wxHORIZONTAL ); mPanelImage->SetSizer( isizer ); - + + // Notebook + mwxNotebook = new wxNotebook(mSplitter2, + -1,wxDefaultPosition, wxDefaultSize, 0); + + + // Fields view (bottom) - mFieldsView = new WxGimmickFieldsView(mSplitter2,-1, + mFieldsView = new WxGimmickFieldsView(mwxNotebook,-1, wxDefaultPosition, wxDefaultSize,0); @@ -362,16 +359,20 @@ namespace creaImageIO GetSettings().BgColour(DicomNode::Series), GetSettings().Colour(DicomNode::Image), GetSettings().BgColour(DicomNode::Image)); + mwxNotebook->AddPage( mFieldsView, _T("Dicom fields")); - - + // Help + mHelp = new WxGimmickHelp(mwxNotebook); + mwxNotebook->AddPage( mHelp, _T("Help")); + + // Splitting int wsize = size.GetWidth(); int hsize = size.GetHeight(); int previewhsize = 150; int previewwsize = 400; mSplitter2->SetMinimumPaneSize( previewhsize ); - mSplitter2->SplitHorizontally( mPanelImage, mFieldsView, + mSplitter2->SplitHorizontally( mPanelImage, mwxNotebook, //mFieldsView, hsize - previewhsize); rsizer->Add( mSplitter2,1,wxGROW ,0); @@ -381,7 +382,7 @@ namespace creaImageIO rpanel->Layout(); // previewer - mInteractor = new wxVTKRenderWindowInteractor(mPanelImage,-1); + mInteractor = new crea::creawxVTKRenderWindowInteractor(mPanelImage,-1); mInteractor->UseCaptureMouseOn(); mViewer = vtkImageViewer2::New(); @@ -411,6 +412,16 @@ namespace creaImageIO ShowImage(mReader.GetImage("")); + // Show help if no collection + if (GetDicomDatabaseList().size()==0) + { + mwxNotebook->SetSelection(1); + } + else + { + mwxNotebook->SetSelection(0); + } + // mJustStarted = true; } //================================================================ @@ -707,8 +718,7 @@ namespace creaImageIO mTreeListCtrl->SetItemText(item,std2wx(lab)); } else - { - + { int c = 0; Settings::ColumnListType::iterator col; // If Study and Series level are merged and node type is Series @@ -777,7 +787,7 @@ namespace creaImageIO //================================================================ void WxGimmick::UpdateColumnsTitles(wxTreeItemId& item, - DicomNode::Type t) + DicomNode::Type t) { // std::cout << "Update columns titles "<UpdateFields(db); GetDicomDatabaseList().push_back(db); UpdateDicomDatabaseView(db); + } //================================================================ @@ -920,10 +932,13 @@ namespace creaImageIO { wxBusyCursor busy; // std::cout << "WxGimmick : Reading config"< Loading collections from '"< Loading collections from '"< ERROR opening collection '"< File does not exist. It will be created on exit (if you already ran Gimmick! and exited normally, this is not normal. Send a bug report)."); } @@ -1012,6 +1027,13 @@ namespace creaImageIO } //================================================================ + //================================================================ + void WxGimmick::LoadOrCreateFavoritesDatabase() + { + // TODO + } + //================================================================ + /* //================================================================ void WxGimmick::OnClose(wxCloseEvent& event) @@ -1091,7 +1113,6 @@ namespace creaImageIO //================================================================ void WxGimmick::OnItemExpanded(wxTreeEvent& event) { - // std::cout << "* Expanded *"<IsDicomNode()) { - /* + // LG : BUGGY + /* std::string str("&Remove "); str += data->GetDicomNode()->GetTypeName(); menu.Append(PopUp_Remove, std2wx(str)); @@ -1353,13 +1372,11 @@ namespace creaImageIO } GetEventHandler()->ProcessEvent(ev); // - + if (menu.GetMenuItemCount()>0) menu.AppendSeparator(); menu.Append(PopUp_Settings, wxT("&Settings...")); menu.Append(PopUp_About, wxT("&About...")); - - /* wxMenu* newmenu = new wxMenu; wxMenu* openmenu = new wxMenu; @@ -1419,9 +1436,6 @@ namespace creaImageIO } } */ - - - PopupMenu(&menu, pt); #endif // wxUSE_MENUS @@ -1434,7 +1448,7 @@ namespace creaImageIO // Pop up menu callbacks void WxGimmick::OnPopUpAbout(wxCommandEvent& event) { - wxMessageBox( _T("Give me my medical images quick ! \n\n (c) CREATIS-LRMN 2008\n"), + wxMessageBox( _T("Give me my medical images quick ! \n\n (c) CREATIS-LRMN 2008\n laurent.guigues@creatis.insa-lyon.fr"), _T("Gimmick!"), wxOK | wxICON_INFORMATION, this); } @@ -1444,7 +1458,7 @@ namespace creaImageIO void WxGimmick::OnPopUpSettings(wxCommandEvent& event) { WxGimmickSettingsDialog* s = - new WxGimmickSettingsDialog(this); + new WxGimmickSettingsDialog(this,&mSettings); s->ShowModal(); delete s; } @@ -1458,7 +1472,6 @@ namespace creaImageIO } //===================================================================== - //===================================================================== void WxGimmick::OnPopUpOpenCollection(wxCommandEvent& event) @@ -1488,22 +1501,21 @@ namespace creaImageIO void WxGimmick::OnPopUpDeleteCollection(wxCommandEvent& event) { if (wxMessageBox(_T("This will physically delete the collection's file on disk and cannot be reverted. Proceed ?"),_T("Confirm"),wxYES_NO,this)==wxNO) return; - + wxBusyCursor busy; - // std::cout << "OnPopUpClose"<GetItemData(mItemOfMenu); DicomDatabase* r = data->GetDicomNode()->GetDicomDatabase(); - + wxRemoveFile(std2wx(r->GetFileName())); // std::cout << "OnPopUpClose '"<GetName()<<"'"<ShowModal()==wxID_OK) { wxBusyCursor busy; @@ -1979,7 +1991,7 @@ namespace creaImageIO } sib = GetTreeListCtrl()->GetNextSibling(sib); } - prio = maxprio + 1000; + prio = maxprio + 999; sib = GetTreeListCtrl()->GetPrevSibling(item); while (sib.IsOk()) { @@ -2022,13 +2034,17 @@ namespace creaImageIO void WxGimmick::ShowImage(vtkImageData* im) { // wxBusyCursor busy; + mViewer->SetInput( im ); + mViewer->SetSlice( 0 ); + int x1,x2,y1,y2,z1,z2; double spx,spy,spz; + im->Update(); im->GetSpacing(spx,spy,spz); im->GetExtent (x1,x2,y1,y2,z1,z2); - /* + std::cout << "-----------------------------"<GetScalarRange(); + mViewer->SetColorWindow(range[1] - range[0]); + mViewer->SetColorLevel(0.5 * (range[1] + range[0])); + + mViewer->GetRenderer()->ResetCamera(); + double bounds[6]; + + + mViewer->GetRenderer()->ComputeVisiblePropBounds(bounds); + + /* + std::cout <<"bounds : "<GetRenderer()->ResetCameraClippingRange(bounds); + /* vtkCamera *camera = mViewer->GetRenderer()->GetActiveCamera(); camera->SetViewUp ( spx*0, -spy*1, spz*0); - camera->SetPosition( spx*(x1+x2)/2, spy*(y1+y2)/2, -spz*10000000); + camera->SetPosition( spx*(x1+x2)/2, spy*(y1+y2)/2, spz*10000000); camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0); camera->ComputeViewPlaneNormal(); camera->SetParallelScale( spx*(x2-x1)/2.0 ); + camera->Roll ( 180 ); + */ } - mViewer->SetInput( im ); - mViewer->SetSlice( 0 ); mInteractor->Render(); } //================================================================ @@ -2149,6 +2185,14 @@ namespace creaImageIO void WxGimmick::OnInternalIdle() { ProcessImageEvents(); + /* + if (mJustStarted) + { + + mJustStarted = false; + } + */ + // } //================================================================ @@ -2249,6 +2293,10 @@ namespace creaImageIO ext[5] = im.size(); out->SetExtent(ext); // LG : TODO : Z Spacing ? + // + // ==> to get an accurate ZSpacing from a Dicom set of files + // ==> you need a gdcm::SerieHelper + // JPR out->AllocateScalars(); @@ -2754,10 +2802,19 @@ namespace creaImageIO } - - - - + //==================================================================== + void WxGimmick::ShowHelp() + { + /* + if (mHelpWindow==0) + { + mHelpWindow = new WxGimmickHelpWindow(this); + } + mHelpWindow->CenterOnParent(); + mHelpWindow->ShowModal(); + */ + } + //==================================================================== @@ -2939,38 +2996,7 @@ namespace creaImageIO - //================================================================ - //================================================================ - //================================================================ - //================================================================ - - //================================================================ - WxGimmickSettingsDialog::WxGimmickSettingsDialog(wxWindow *parent) - : - wxDialog( parent, - -1, - _T("Settings"), - wxDefaultPosition, - wxSize(400,400), - wxRESIZE_BORDER | - wxSYSTEM_MENU | - wxCLOSE_BOX | - wxMAXIMIZE_BOX | - wxMINIMIZE_BOX | - wxCAPTION - ) - { - } - //================================================================ - - //================================================================ - WxGimmickSettingsDialog::~WxGimmickSettingsDialog() - { - } - //================================================================ - - - +