00001
00002
00003
00004
00005 #include "MFCBase.h"
00006 #include "vThumbNailDoc.h"
00007 #include "ProgressBarDLG.h"
00008
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00016
00017 using namespace jbxl;
00018 using namespace jbxwl;
00019
00020
00022
00023
00024 IMPLEMENT_DYNCREATE(CvThumbNailDoc, CExDocument)
00025
00026
00027 CvThumbNailDoc::CvThumbNailDoc()
00028 {
00029 SetSize(THUMBNAIL_SIZE, THUMBNAIL_SIZE, 4, 2, 4, 12);
00030 }
00031
00032
00033
00034 CvThumbNailDoc::~CvThumbNailDoc()
00035 {
00036 }
00037
00038
00039
00040 BEGIN_MESSAGE_MAP(CvThumbNailDoc, CRwGRDoc)
00041
00042
00043
00044 END_MESSAGE_MAP()
00045
00046
00047
00049
00050
00051 #ifdef _DEBUG
00052 void CvThumbNailDoc::AssertValid() const
00053 {
00054 CRwGRDoc::AssertValid();
00055 }
00056
00057
00058
00059 void CvThumbNailDoc::Dump(CDumpContext& dc) const
00060 {
00061 CRwGRDoc::Dump(dc);
00062 }
00063 #endif //_DEBUG
00064
00065
00066
00067
00069
00070
00071 void CvThumbNailDoc::Serialize(CArchive& ar)
00072 {
00073 if (ar.IsStoring())
00074 {
00075
00076 }
00077 else
00078 {
00079
00080 }
00081 }
00082
00083
00084
00085
00087
00088
00089 CmnHead CvThumbNailDoc::TranslateData()
00090 {
00091 int i, j, k;
00092 CmnHead chd;
00093
00094
00095 if (msGraph.xs>0 && msGraph.ys>0) {
00096 if (msGraph.xs>msGraph.ys) {
00097 int ysize = THUMBNAIL_SIZE*msGraph.ys/msGraph.xs;
00098 SetSize(0, ysize, 0, 0, 0, 0);
00099 }
00100 else {
00101 int xsize = THUMBNAIL_SIZE*msGraph.xs/msGraph.ys;
00102 SetSize(xsize, 0, 0, 0, 0, 0);
00103 }
00104 }
00105
00106 colorMode = msGraph.color;
00107 chd.kind = CT_DATA;
00108 chd.xsize = xClientSize;
00109 chd.ysize = Max(((msGraph.zs+1)/2+1)*(yTNailSize+tNailBorder), yClientSize);
00110 chd.zsize = yClientSize;
00111 chd.depth = 8;
00112 chd.bsize = 0;
00113 chd.buf = NULL;
00114 chd.lsize = chd.xsize*chd.ysize;
00115 chd.grptr = (uByte*)malloc(chd.lsize);
00116 if (chd.grptr==NULL) {
00117 freeCmnHead(&chd);
00118 chd.xsize = -2;
00119 return chd;
00120 }
00121 for (i=0; i<chd.xsize*chd.ysize; i++) chd.grptr[i] = VIEW_8_MAX;
00122
00123
00124 CVCounter* counter = NULL;
00125 if (chd.zsize>10) {
00126 counter = GetUsableGlobalCounter();
00127 if (counter!=NULL) counter->SetMax(msGraph.zs*2/10);
00128 }
00129
00130
00131 int min = SINTMAX;
00132 int max = SINTMIN;
00133 int ks, js;
00134 for (k=0; k<msGraph.zs; k++) {
00135 ks = k*msGraph.xs*msGraph.ys;
00136 for (j=0; j<msGraph.ys; j++) {
00137 js = j*msGraph.xs;
00138 for (i=0; i<msGraph.xs; i++) {
00139 min = Min((int)msGraph.gp[i+js+ks], min);
00140 max = Max((int)msGraph.gp[i+js+ks], max);
00141 }
00142 }
00143 if (counter!=NULL && k%10==0) {
00144 counter->StepIt();
00145 if (counter->isCanceled()) {
00146 freeCmnHead(&chd);
00147 chd.xsize = -3;
00148 return chd;
00149 }
00150 }
00151 }
00152
00153 if (min>=0 && max<=VIEW_8_MAX && !ctrlCntrst) {
00154 max = VIEW_8_MAX;
00155 min = 0;
00156 }
00157 msGraph.max = (sWord)max;
00158 msGraph.min = (sWord)min;
00159
00160 RECT rect;
00161 int ii, jj;
00162 for (k=0; k<msGraph.zs; k++) {
00163 rect.left = (k%2)*(xTNailSize + tNailBorder) + 1;
00164 rect.right = rect.left + xTNailSize - 1;
00165 rect.top = (k/2)*(yTNailSize + tNailBorder) + 1;
00166 rect.bottom = rect.top + yTNailSize - 1;
00167
00168 for (i=rect.left-1; i<=rect.right +1; i++) CmnHeadBytePoint(chd, i, rect.top-1) = 0;
00169 for (i=rect.left-1; i<=rect.right +1; i++) CmnHeadBytePoint(chd, i, rect.bottom+1) = 0;
00170 for (j=rect.top-1; j<=rect.bottom+1; j++) CmnHeadBytePoint(chd, rect.left -1, j) = 0;
00171 for (j=rect.top-1; j<=rect.bottom+1; j++) CmnHeadBytePoint(chd, rect.right+1, j) = 0;
00172
00173 for (j=0; j<yTNailSize; j++) {
00174 jj = j*(msGraph.ys-1)/(yTNailSize-1);
00175 for (i=0; i<xTNailSize; i++) {
00176 ii = i*(msGraph.xs-1)/(xTNailSize-1);
00177 CmnHeadBytePoint(chd, rect.left+i, rect.top+j) = (uByte)((float)(msGraph.point(ii, jj, k)-min)/(max-min)*VIEW_8_MAX);
00178 }
00179 }
00180 if (counter!=NULL && k%10==0) {
00181 counter->StepIt();
00182 if (counter->isCanceled()) {
00183 freeCmnHead(&chd);
00184 chd.xsize = -3;
00185 return chd;
00186 }
00187 }
00188 }
00189
00190
00191 pView->colorMode = GRAPH_COLOR_MONO;
00192 pView->maxYSize = yMaxClientSize;
00193
00194 return chd;
00195 }
00196
00197
00198
00208 void CvThumbNailDoc::SetSize(int txs, int tys, int bds, int hrs, int vrs, int ymx)
00209 {
00210 if (txs>0) xTNailSize = txs;
00211 if (tys>0) yTNailSize = tys;
00212 if (bds>0) tNailBorder = bds;
00213 if (hrs>0) xTNailOrder = hrs;
00214 if (vrs>0) yTNailOrder = vrs;
00215 if (ymx>0) yMaxOrder = Max(yTNailOrder, ymx);
00216
00217 xClientSize = (xTNailSize + tNailBorder)*xTNailOrder;
00218 yClientSize = (yTNailSize + tNailBorder)*yTNailOrder;
00219 yMaxClientSize = (yTNailSize + tNailBorder)*yMaxOrder;
00220 }
00221
00222
00223
00224 int CvThumbNailDoc::GetTNailNum(POINT pt)
00225 {
00226 int xx = pt.x/(xTNailSize+ tNailBorder) + 1;
00227 int yy = pt.y/(yTNailSize+ tNailBorder) + 1;
00228 int ret = (yy - 1)*2 + xx;
00229
00230 if (ret<0 || ret>msGraph.zs) ret = -1;
00231 return ret;
00232 }
00233
00234