00001 #ifndef Impala_Visualization_IxsDocumentGuiMain_h
00002 #define Impala_Visualization_IxsDocumentGuiMain_h
00003
00004 #include "Visualization/ImageStrip.h"
00005 #include "Visualization/ImageSet.h"
00006 #include "Visualization/DataDocumentGui.h"
00007 #include "Core/ImageSet/IxsDocument.h"
00008
00009
00010 namespace Impala
00011 {
00012 namespace Visualization
00013 {
00014
00015
00016 class IxsDocumentGuiMain : public DataDocumentGui<Core::ImageSet::IxsDocument>,
00017 public ImagesListener,
00018 public OglGui::ViewListener
00019 {
00020 static const int IM_BOOKMARKED = 1;
00021 static const int IM_CURRENT = 2;
00022 static const int IM_SET = 3;
00023
00024 public:
00025
00026 typedef Core::ImageSet::IxsDocument IxsDocument;
00027 typedef Core::Array::Array2dVec3UInt8 Array2dVec3UInt8;
00028
00029 IxsDocumentGuiMain(OglGui::Window* parent, int wndWidth, int wndHeight,
00030 int nrImOnRow, int thumbWidth, int thumbHeight,
00031 double viewScale, bool showAnno, IxsDocument* ixsDoc,
00032 int controlId) :
00033 DataDocumentGui<IxsDocument>(parent, wndWidth, wndHeight, ixsDoc,
00034 controlId, true, true, false, 3, 6,
00035 showAnno, true)
00036 {
00037 mIxsDoc = ixsDoc;
00038 mViewScale = viewScale;
00039
00040 mBookmarkedStrip = 0;
00041 if (nrImOnRow > 0)
00042 {
00043 mBookmarkedStrip = new ImageStrip(this, thumbWidth, thumbHeight,
00044 viewScale, nrImOnRow);
00045 mBookmarkedStrip->SetImagesListener(this, IM_BOOKMARKED);
00046 mBookmarkedStrip->ActivateInfoBox(false);
00047 }
00048
00049 new OglGui::Strut(this, 4000, 1);
00050
00051 mImageSet = 0;
00052 if (nrImOnRow > 0)
00053 {
00054 mImageSet = new ImageSet(this, thumbWidth, thumbHeight, viewScale,
00055 nrImOnRow*3/4, 4);
00056 mImageSet->SetImagesListener(this, IM_SET);
00057 mImageSet->ActivateInfoBox(false);
00058 }
00059
00060 mCurImWnd = new ImagesWindow(this, wndWidth/4, wndHeight);
00061 mCurImWnd->SetImagesListener(this, IM_CURRENT);
00062 mCurImWnd->SetMakeViewWithRect(true);
00063 mCurImWnd->SetViewListener(this);
00064 mCurImWnd->ActivateInfoBox(false);
00065
00066 }
00067
00068 virtual void
00069 HandleNewDir()
00070 {
00071 DataDocumentGui<IxsDocument>::HandleNewFile();
00072 if (!mImageSet)
00073 return;
00074 Core::Table::TableIds* table = mIxsDoc->GetFilesOfDir(-1);
00075 mImageSet->ReplaceImages(table, mIxsDoc->GetImageSet());
00076 mImageSet->SetFirstVisY(0, true);
00077 delete table;
00078 }
00079
00080 virtual void
00081 HandleNewFile()
00082 {
00083 DataDocumentGui<IxsDocument>::HandleNewFile();
00084 if (mConceptField)
00085 {
00086 mConceptField->SetText(mIxsDoc->GetConcept());
00087 mConceptField->ResetCaret();
00088 }
00089 mCurImWnd->RemoveImages();
00090 if (mIxsDoc->HasCurFile())
00091 {
00092 mCurImWnd->AddImage(mIxsDoc->CurImage(), "Direct", "", true);
00093 mCurImWnd->GetViewWithRect(0)->SetRect(mIxsDoc->GetRect());
00094 }
00095 }
00096
00097 virtual void
00098 HandleNewBookmarked()
00099 {
00100 DataDocumentGui<IxsDocument>::HandleNewBookmarked();
00101 if (mBookmarkedStrip)
00102 mBookmarkedStrip->ReplaceImages(mIxsDoc->GetBookmarkedIds(),
00103 mIxsDoc->GetImageSet());
00104 }
00105
00106 virtual void
00107 HandleAddedBookmark()
00108 {
00109 if (mBookmarkedStrip)
00110 mBookmarkedStrip->AddImage(mIxsDoc->CurFileId(),
00111 mIxsDoc->GetImageSet());
00112 DataDocumentGui<IxsDocument>::HandleNewBookmarked();
00113 }
00114
00115 virtual void
00116 ImageSelectionEvent(ImagesWindow* src, int imIndex, void* vData)
00117 {
00118 int listenerData = (int)(long long) vData;
00119 switch (listenerData)
00120 {
00121 case IM_BOOKMARKED:
00122 mIxsDoc->CursorToBookmark(imIndex);
00123 AllHandleNewCursor(Core::Database::LEVEL_FILE, false);
00124 break;
00125 case IM_SET:
00126 mIxsDoc->CursorToFile(mIxsDoc->GetFileOfDir(imIndex, -1));
00127 AllHandleNewCursor(Core::Database::LEVEL_FILE, false);
00128 break;
00129 }
00130 }
00131
00132 virtual void
00133 OnViewMouse(OglGui::View* view, int msg, int btn, int state,
00134 float x, float y)
00135 {
00136 Core::Geometry::Rectangle r = mCurImWnd->GetViewWithRect(0)->GetRect();
00137 mIxsDoc->SetRect(r);
00138 }
00139
00140 private:
00141
00142 IxsDocument* mIxsDoc;
00143 double mViewScale;
00144
00145 ImageStrip* mBookmarkedStrip;
00146 ImageSet* mImageSet;
00147 ImagesWindow* mCurImWnd;
00148
00149 };
00150
00151 }
00152 }
00153
00154 #endif