void MatrixViewer::ShowZoom () { MatrixRaster* tmp_m_r_list[2]; double *tmp_mtr,*tmp_mtr_cur; const double *tmp_m_r_data; const MatrixRaster *tmp_m_r; const int from_x=ui->SB_xFrom->value(),from_y=ui->SB_yFrom->value(); const int to_x=ui->SB_xTo->value()+1,to_y=ui->SB_yTo->value()+1; const int r_low=from_y-_p_from.y(),r_high=to_y-from_y; const int c_low=from_x-_p_from.x(),c_high=to_x-from_x; int cols,r; tmp_m_r=static_cast<const MatrixRaster*>(&(_data[0]->data())); cols=tmp_m_r->GetCols(); tmp_mtr=static_cast<double*>(malloc(r_high*c_high*sizeof(double))); if (tmp_mtr==NULL) return; tmp_m_r_data=tmp_m_r->Data()+(r_low*cols+c_low); tmp_mtr_cur=tmp_mtr; for (r=0; r<r_high; ++r,tmp_m_r_data+=cols,tmp_mtr_cur+=c_high) memcpy(tmp_mtr_cur,tmp_m_r_data,c_high*sizeof(double)); tmp_m_r_list[0]=new MatrixRaster(tmp_mtr,r_high,c_high); if (_data[1]!=NULL) { tmp_m_r=static_cast<const MatrixRaster*>(&(_data[1]->data())); cols=tmp_m_r->GetCols(); tmp_mtr=static_cast<double*>(malloc(r_high*c_high*sizeof(double))); if (tmp_mtr==NULL) tmp_m_r_list[1]=NULL; else { tmp_m_r_data=tmp_m_r->Data()+(r_low*cols+c_low); tmp_mtr_cur=tmp_mtr; for (r=0; r<r_high; ++r,tmp_m_r_data+=cols,tmp_mtr_cur+=c_high) memcpy(tmp_mtr_cur,tmp_m_r_data,c_high*sizeof(double)); tmp_m_r_list[1]=new MatrixRaster(tmp_mtr,r_high,c_high); } } else tmp_m_r_list[1]=NULL; const QString &title=this->windowTitle(); const int zoomed_ind=title.lastIndexOf(tr(": zoomed")); QString z_title=(zoomed_ind>0)? title.left(zoomed_ind) : title; (z_title+=tr(": zoomed"))+=QString(" (%1,%2)-(%3,%4)").arg(from_x).arg(from_y).arg(to_x-1).arg(to_y-1); MatrixViewer *tmp_m_v=new MatrixViewer(static_cast<QMdiArea*>(parentWidget()),_cntrl,inv); tmp_m_v->Init(z_title,tmp_m_r_list); tmp_m_v->SetLength(_length); tmp_m_v->SetPointFrom(QPoint(from_x,from_y)); tmp_m_v->SetPointTo(QPoint(to_x,to_y)); emit ZoomMatrix(tmp_m_v); delete tmp_m_r_list[0]; if (tmp_m_r_list[1]!=NULL) delete tmp_m_r_list[1]; //ui->Plot->adjustSize(); }
void DXImage::Draw(int x,int y,int gx,int gy,int gwid,int ghei,float zoom,float rot,Color4f color){ if(lpd3ddev==NULL)return; if(myTexture==NULL)return; float alpha=255; float ux,uy,uw,uh; int wid=desc.Width; int hei=desc.Height; if(gwid==0)gwid=wid-gx; if(ghei==0)ghei=hei-gy; /* ux=(float)(gx+0.5f)/wid; uy=(float)(gy+0.5f)/hei; uw=(float)(gx+gwid+0.5f)/wid; uh=(float)(gy+ghei+0.5f)/hei;*/ ux=((float)gx)/wid; uy=((float)gy)/hei; uw=((float)gx+gwid)/wid; uh=((float)gy+ghei)/hei; if(alpha>255)alpha=255; if(alpha<0)alpha=0; if(ux<0.0f)ux=0.0f; if(uy<0.0f)uy=0.0f; if(ux>1.0f)ux=1.0f; if(uy>1.0f)uy=1.0f; float xf,yf,wf,hf; xf=(float)x-wid/2; yf=(float)y-hei/2; wf=(float)x+wid/2; hf=(float)y+hei/2; DWORD c = D3DCOLOR_RGBA( (int)(color.red), (int)(color.green), (int)(color.blue), (int)(color.alpha)); CUSTOMVERTEX vertex[4]={ {xf ,yf ,0.0f ,1.0f ,c ,ux ,uy }, {wf ,yf ,0.0f ,1.0f ,c ,uw ,uy }, {wf ,hf ,0.0f ,1.0f ,c ,uw ,uh }, {xf ,hf ,0.0f ,1.0f ,c ,ux ,uh } }; if(rot!=0)RotateMatrix(vertex,rot); if(zoom!=1.0f)ZoomMatrix(vertex,zoom,zoom,zoom); // void *pData; // if(FAILED(pVertex->Lock(0, sizeof(CUSTOMVERTEX)*4, (void**)&pData, 0))){ // return; // } // memcpy(pData,vertex, sizeof(CUSTOMVERTEX)*4); // pVertex->Unlock(); lpd3ddev->SetTexture(0,myTexture); lpd3ddev->SetFVF(FVF_CUSTOM); // lpd3ddev->SetStreamSource(0, pVertex, 0, sizeof(CUSTOMVERTEX)); // lpd3ddev->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2); lpd3ddev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,(void*)vertex,sizeof(CUSTOMVERTEX)); }