#include <vtkCamera.h>
#include <vtkRenderer.h>
-#include<wx/filefn.h>
+#include <wx/filefn.h>
+//#include <wx/tipwin.h>
using namespace crea;
PopUp_Settings = 501,
PopUp_About = 502,
PopUp_User = WxGimmick::UserMenuFirstId,
+ PopUp_SaveAs = 701,
+ PopUp_AddToFavorites = 702
};
//================================================================
- //================================================================
- class WxGimmickSettingsDialog : public wxDialog
- {
- public:
- WxGimmickSettingsDialog(wxWindow *parent);
- ~WxGimmickSettingsDialog();
-
-
- };
- //================================================================
-
-
// 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);
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);
rpanel->Layout();
// previewer
- mInteractor = new wxVTKRenderWindowInteractor(mPanelImage,-1);
+ mInteractor = new crea::creawxVTKRenderWindowInteractor(mPanelImage,-1);
mInteractor->UseCaptureMouseOn();
mViewer = vtkImageViewer2::New();
ShowImage(mReader.GetImage(""));
+ // Show help if no collection
+ if (GetDicomDatabaseList().size()==0)
+ {
+ mwxNotebook->SetSelection(1);
+ }
+ else
+ {
+ mwxNotebook->SetSelection(0);
+ }
+ // mJustStarted = true;
}
//================================================================
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
//================================================================
void WxGimmick::UpdateColumnsTitles(wxTreeItemId& item,
- DicomNode::Type t)
+ DicomNode::Type t)
{
// std::cout << "Update columns titles "<<t<<std::endl;
int c = 0;
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 ")
_T("Error"),
wxOK,this);
return;
+
}
+ */
}
}
}
}
+ if (GetDicomDatabaseList().size()==0) mFieldsView->UpdateFields(db);
GetDicomDatabaseList().push_back(db);
UpdateDicomDatabaseView(db);
+
}
//================================================================
{
wxBusyCursor busy;
// std::cout << "WxGimmick : Reading config"<<std::endl;
+ LoadOrCreateFavoritesDatabase();
- // std::cout << "==> Loading collections from '"<<mDatabaseListFile
+ // std::cout <<
+ creaMessage("Gimmick!",1,"Gimmick! : ==> Loading collections from '"<<mDatabaseListFile<<"'"<<std::endl);
// <<"'"<<std::endl;
+
std::ifstream s;
s.open(mDatabaseListFile.c_str());
if (s.good())
}
else
{
- // std::cout << " ... ERROR !"<<std::endl;
+ creaMessage("Gimmick!",1," ==> ERROR opening collection '"<<tokens[0]<<"'"<<std::endl);
delete db;
}
}
}
else
{
- std::cout << "ERROR opening "<<mDatabaseListFile<<std::endl;
+ creaMessage("Gimmick!",1," ==> 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).");
}
}
//================================================================
+ //================================================================
+ void WxGimmick::LoadOrCreateFavoritesDatabase()
+ {
+ // TODO
+ }
+ //================================================================
+
/*
//================================================================
void WxGimmick::OnClose(wxCloseEvent& event)
//================================================================
void WxGimmick::OnItemExpanded(wxTreeEvent& event)
{
-
// std::cout << "* Expanded *"<<std::endl;
// }
void WxGimmick::OnItemRightClick(wxTreeEvent& event)
{
-
wxTreeItemId itemId = event.GetItem();
if (itemId.IsOk())
{
event.Skip();
}
//=====================================================================
-
-
//=====================================================================
void WxGimmick::ShowMenu(wxTreeItemId id, const wxPoint& pt)
}
if (data->IsDicomNode())
{
- /*
+
// LG : BUGGY
+ /*
std::string str("&Remove ");
str += data->GetDicomNode()->GetTypeName();
menu.Append(PopUp_Remove, std2wx(str));
}
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;
}
}
*/
-
-
-
PopupMenu(&menu, pt);
#endif // wxUSE_MENUS
// 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);
}
void WxGimmick::OnPopUpSettings(wxCommandEvent& event)
{
WxGimmickSettingsDialog* s =
- new WxGimmickSettingsDialog(this);
+ new WxGimmickSettingsDialog(this,&mSettings);
s->ShowModal();
delete s;
}
}
//=====================================================================
-
//=====================================================================
void WxGimmick::OnPopUpOpenCollection(wxCommandEvent& event)
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"<<std::endl;
// wxTreeItemId id = event.GetId();
TreeItemData *data = (TreeItemData *)mTreeListCtrl->GetItemData(mItemOfMenu);
DicomDatabase* r = data->GetDicomNode()->GetDicomDatabase();
-
+
wxRemoveFile(std2wx(r->GetFileName()));
// std::cout << "OnPopUpClose '"<<r->GetName()<<"'"<<std::endl;
DeleteDicomDatabase(mItemOfMenu,r);
-
+
}
//=====================================================================
-
+
void DisplayUpdateSummary( DicomDatabase::UpdateSummary& summary,
wxWindow* parent )
{
summary.update_database_time,
(int)(summary.update_database_time*100./summary.total_time),
summary.total_time );
-
+
mess << times;
-
+
wxMessageBox(std2wx(mess.str()),_T("Update summary"),wxOK,parent);
}
-
-
+
+
//=====================================================================
void WxGimmick::OnPopUpAddFile(wxCommandEvent& event)
{
long style = wxOPEN | wxFILE_MUST_EXIST | wxFD_MULTIPLE;
- std::string wc("*.*");
+ std::string wc("*");
wxFileDialog* FD = new wxFileDialog( 0,
_T("Select file"),
mCurrentDirectory,
std2wx(wc),
style,
wxDefaultPosition);
-
+
if (FD->ShowModal()==wxID_OK)
{
wxBusyCursor busy;
}
sib = GetTreeListCtrl()->GetNextSibling(sib);
}
- prio = maxprio + 1000;
+ prio = maxprio + 999;
sib = GetTreeListCtrl()->GetPrevSibling(item);
while (sib.IsOk())
{
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 << "-----------------------------"<<std::endl;
std::cout << x1 << "-"<<x2<<std::endl;
std::cout << y1 << "-"<<y2<<std::endl;
std::cout << z1 << "-"<<z2<<std::endl;
mspy = spy;
mspz = spz;
+ double *range = im->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 : "<<bounds[0]<<","
+<<bounds[1]<<","
+<<bounds[2]<<","
+<<bounds[3]<<","
+<<bounds[4]<<","
+ <<bounds[5]<<std::endl;
+ */
+ mViewer->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();
}
//================================================================
void WxGimmick::OnInternalIdle()
{
ProcessImageEvents();
+ /*
+ if (mJustStarted)
+ {
+
+ mJustStarted = false;
+ }
+ */
+ //
}
//================================================================
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();
}
-
-
-
-
+ //====================================================================
+ void WxGimmick::ShowHelp()
+ {
+ /*
+ if (mHelpWindow==0)
+ {
+ mHelpWindow = new WxGimmickHelpWindow(this);
+ }
+ mHelpWindow->CenterOnParent();
+ mHelpWindow->ShowModal();
+ */
+ }
+ //====================================================================
- //================================================================
- //================================================================
- //================================================================
- //================================================================
-
- //================================================================
- 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()
- {
- }
- //================================================================
-
-
-
+