X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOWxGimmick.cpp;h=4b8f3f3f76dbc77d6716617baa36dc5224249b51;hb=4ac76c07b4bfbdf3c69da3faa347e1f14c7c217c;hp=1acf88872f4d2abb91e1cb04ddbf861526247ef0;hpb=0f77ffb489a57c12a23d1afa592d07a37c41d8b5;p=creaImageIO.git diff --git a/src/creaImageIOWxGimmick.cpp b/src/creaImageIOWxGimmick.cpp index 1acf888..4b8f3f3 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; } //================================================================ @@ -859,6 +870,9 @@ namespace creaImageIO boost::filesystem::change_extension(filepath,GetDatabaseExtension()); if ( boost::filesystem::exists(filepath) ) { + boost::filesystem::remove(filepath); + /* + LG : works on Linux but not Windows : if ( ! boost::filesystem::remove(filepath) ) { wxMessageBox(_T("Could not overwrite ") @@ -866,8 +880,10 @@ namespace creaImageIO _T("Error"), wxOK,this); return; + } + */ } } @@ -903,9 +919,11 @@ namespace creaImageIO } } + if (GetDicomDatabaseList().size()==0) mFieldsView->UpdateFields(db); GetDicomDatabaseList().push_back(db); UpdateDicomDatabaseView(db); + } //================================================================ @@ -915,10 +933,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)."); } @@ -1007,6 +1028,13 @@ namespace creaImageIO } //================================================================ + //================================================================ + void WxGimmick::LoadOrCreateFavoritesDatabase() + { + // TODO + } + //================================================================ + /* //================================================================ void WxGimmick::OnClose(wxCloseEvent& event) @@ -1293,8 +1321,9 @@ namespace creaImageIO } if (data->IsDicomNode()) { - /* + // LG : BUGGY + /* std::string str("&Remove "); str += data->GetDicomNode()->GetTypeName(); menu.Append(PopUp_Remove, std2wx(str)); @@ -1429,7 +1458,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); } @@ -1439,7 +1468,7 @@ namespace creaImageIO void WxGimmick::OnPopUpSettings(wxCommandEvent& event) { WxGimmickSettingsDialog* s = - new WxGimmickSettingsDialog(this); + new WxGimmickSettingsDialog(this,&mSettings); s->ShowModal(); delete s; } @@ -1974,7 +2003,7 @@ namespace creaImageIO } sib = GetTreeListCtrl()->GetNextSibling(sib); } - prio = maxprio + 1000; + prio = maxprio + 999; sib = GetTreeListCtrl()->GetPrevSibling(item); while (sib.IsOk()) { @@ -2017,13 +2046,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(); } //================================================================ @@ -2144,6 +2197,14 @@ namespace creaImageIO void WxGimmick::OnInternalIdle() { ProcessImageEvents(); + /* + if (mJustStarted) + { + + mJustStarted = false; + } + */ + // } //================================================================ @@ -2244,6 +2305,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(); @@ -2749,10 +2814,19 @@ namespace creaImageIO } - - - - + //==================================================================== + void WxGimmick::ShowHelp() + { + /* + if (mHelpWindow==0) + { + mHelpWindow = new WxGimmickHelpWindow(this); + } + mHelpWindow->CenterOnParent(); + mHelpWindow->ShowModal(); + */ + } + //==================================================================== @@ -2934,38 +3008,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() - { - } - //================================================================ - - - +