ribi::QtToolSurfacePlotterMainDialog::QtToolSurfacePlotterMainDialog(QWidget *parent) : QtHideAndShowDialog(parent), ui(new Ui::QtToolSurfacePlotterMainDialog) { #ifndef NDEBUG Test(); #endif ui->setupUi(this); #ifndef NDEBUG assert(Rescale(2.0,1.0,5.0,0.0,100.0) >= 24.9999 && Rescale(2.0,1.0,5.0,0.0,100.0) < 25.0001); #endif QObject::connect(this->ui->edit_equation,SIGNAL(textChanged(QString)),this,SLOT(OnAnyChange())); QObject::connect(this->ui->edit_minx,SIGNAL(textChanged(QString)),this,SLOT(OnAnyChange())); QObject::connect(this->ui->edit_miny,SIGNAL(textChanged(QString)),this,SLOT(OnAnyChange())); QObject::connect(this->ui->edit_maxx,SIGNAL(textChanged(QString)),this,SLOT(OnAnyChange())); QObject::connect(this->ui->edit_maxy,SIGNAL(textChanged(QString)),this,SLOT(OnAnyChange())); ui->edit_minx->setText(boost::lexical_cast<std::string>(-1.0).c_str()); ui->edit_miny->setText(boost::lexical_cast<std::string>(-1.0).c_str()); ui->edit_maxx->setText(boost::lexical_cast<std::string>( 1.0).c_str()); ui->edit_maxy->setText(boost::lexical_cast<std::string>( 1.0).c_str()); ui->edit_equation->setText("cos(x*y*100)"); { //Put the dialog in the screen center at 50% x 50% of its size const QRect screen = QApplication::desktop()->screenGeometry(); this->setGeometry(0,0,screen.width() / 2,screen.height() /2 ); this->move( screen.center() - this->rect().center() ); } }
/* * Here we do the actual rendering. I put it in a separate * method so that it can work no matter what type of DC * (e.g. wxPaintDC or wxClientDC) is used. */ void wxImagePanel::render(wxDC& dc) { int neww, newh; dc.GetSize(&neww, &newh); // Adjust aspect ratio. if (BackgroundWidth * newh > neww * BackgroundHeight) newh = (neww * BackgroundHeight) / BackgroundWidth; else neww = (newh * BackgroundWidth) / BackgroundHeight; if (neww != w || newh != h) { //static int Count = 0; //printf ("Rescale %d: %d %d -> %d %d\n", ++Count, w, h, neww, newh); w = neww; h = newh; resized = wxBitmap(image.Scale(neww, newh, wxIMAGE_QUALITY_HIGH)); int i; for (i = 1; i < NumGraphics; i++) // Skip initial dummy entry. Rescale(Graphics[i].UnscaledImage, Graphics[i].ScaledImage); for (i = 0; i < MAX_CLOCK_ANGLES; i++) { Rescale(HandsHours[i].UnscaledImage, HandsHours[i].ScaledImage); Rescale(HandsMinutes[i].UnscaledImage, HandsMinutes[i].ScaledImage); Rescale(HandsSeconds[i].UnscaledImage, HandsSeconds[i].ScaledImage); } } wxMemoryDC wdc(resized); wxBitmap Buffer(resized.GetWidth(), resized.GetHeight()); wxMemoryDC bdc(Buffer); bdc.DrawBitmap(resized, 0, 0, false); int i; for (i = 0; i < NumFields; i++) if (Fields[i].Type == FT_OUT && Fields[i].State != gi_none) BufferedComposite(&bdc, Graphics[Fields[i].State].ScaledImage, Fields[i].x, Fields[i].y); // Do the accutron clock hands. time_t t; struct tm *tm_struct; time(&t); tm_struct = gmtime(&t); /* printf("%d %d %d %d %d %p %p %p\n", Fields[trs_ac_hands].x, Fields[trs_ac_hands].y, tm_struct->tm_hour * 5, tm_struct->tm_min * 2, tm_struct->tm_sec * 2, HandsHours[tm_struct->tm_hour * 5].ScaledImage, HandsMinutes[tm_struct->tm_min * 2].ScaledImage, HandsSeconds[tm_struct->tm_sec * 2].ScaledImage); */ BufferedComposite(&bdc, HandsHours[tm_struct->tm_hour * 5].ScaledImage, Fields[trs_ac_hands].x, Fields[trs_ac_hands].y); BufferedComposite(&bdc, HandsMinutes[tm_struct->tm_min * 2].ScaledImage, Fields[trs_ac_hands].x, Fields[trs_ac_hands].y); BufferedComposite(&bdc, HandsSeconds[tm_struct->tm_sec * 2].ScaledImage, Fields[trs_ac_hands].x, Fields[trs_ac_hands].y); // Now actually write the buffer to the screen. dc.DrawBitmap(Buffer, 0, 0, false); }
static int EmitRescaledYUV(const VP8Io* const io, WebPDecParams* const p) { const int mb_h = io->mb_h; const int uv_mb_h = (mb_h + 1) >> 1; const int num_lines_out = Rescale(io->y, io->y_stride, mb_h, &p->scaler_y); Rescale(io->u, io->uv_stride, uv_mb_h, &p->scaler_u); Rescale(io->v, io->uv_stride, uv_mb_h, &p->scaler_v); return num_lines_out; }
void cTSDemuxer::SendPacket(sStreamPacket *pkt) { int64_t dts = (pkt->dts == DVD_NOPTS_VALUE) ? pkt->dts : Rescale(pkt->dts); int64_t pts = (pkt->pts == DVD_NOPTS_VALUE) ? pkt->pts : Rescale(pkt->pts); // Rescale pkt->type = m_type; pkt->content = m_content; pkt->pid = GetPID(); pkt->dts = dts; pkt->pts = pts; pkt->duration = Rescale(pkt->duration); m_Streamer->sendStreamPacket(pkt); }
void C2DMap::SetGrid(bool b) { bGrid = b; Rescale(); Invalidate(TRUE); UpdateWindow(); }
void C2DMap::OnRButtonDblClk(UINT nFlags, CPoint point) { if (igcmap == NULL) return; if (dragsector) // cancel drag sector { dragsector = NULL; Rescale(); Invalidate(TRUE); UpdateWindow(); } else { // start an aleph creation if (IsOverSector(point)) { AfxMessageBox("Cant create sector over a sector"); } else { float x = MAP2DUNSCALEX(point.x,maxx); float y = MAP2DUNSCALEY(point.y,maxy,MapH); // dont allow neg values for now if (x <0.0) x = 0.0; if (y <0.0) y = 0.0; CMAPDlg *pdlg = (CMAPDlg *) CWnd::GetParent(); pdlg->NewSector(x,y); } } CWnd::OnRButtonDblClk(nFlags, point); }
void C2DMap::SetSnap(bool b) { bSnap = b; Rescale(); Invalidate(TRUE); UpdateWindow(); }
void C2DMap::OnLButtonDown(UINT nFlags, CPoint point) { //CString mes; //mes.Format("HIT AT %d,%d",point.x,point.y); //AfxMessageBox(_T(mes)); if (createaleph) // cancel creating an aleph { createaleph = NULL; Rescale(); Invalidate(TRUE); UpdateWindow(); } else { if (dragsector=IsOverSector(point)) { CMAPDlg *pdlg = (CMAPDlg *)CWnd::GetParent(); pdlg->SetSector(dragsector); dragpoint.x = point.x - dragsector->pos2D.x; dragpoint.y = point.y - dragsector->pos2D.y; dragorigin = dragsector->pos2D; SetCapture(); } } CWnd::OnLButtonDown(nFlags, point); }
void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) { int Width = pCommand->m_Width; int Height = pCommand->m_Height; int Depth = 1; void *pTexData = pCommand->m_pData; // resample if needed if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB) { int MaxTexSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexSize); if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_TEXTURE3D) { int Max3DTexSize; glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &Max3DTexSize); if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_TEXTURE2D) MaxTexSize = min(MaxTexSize, Max3DTexSize*16); else MaxTexSize = Max3DTexSize*16; } if(Width > MaxTexSize || Height > MaxTexSize) { do { Width>>=1; Height>>=1; } while(Width > MaxTexSize || Height > MaxTexSize); void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData)); mem_free(pTexData); pTexData = pTmpData; } else if(Width > 16 && Height > 16 && (pCommand->m_Flags&CCommandBuffer::TEXFLAG_QUALITY) == 0)
void tile(BMP& Input, BMP& Output) { if (Input.TellHeight() == 1) { Output.SetPixel(Output.TellWidth() - 1, 0, Input.GetPixel(0, 0)); } else { BMP* ScaledInput = new BMP(Input); Rescale(*ScaledInput, 'p', 50); // SW quadrant RangedPixelToPixelCopy(*ScaledInput, 0, ScaledInput -> TellWidth(), 0, ScaledInput -> TellHeight(), Output, Output.TellWidth() - 2 * ScaledInput -> TellWidth(), ScaledInput -> TellHeight()); // NE quadrant tile(*ScaledInput, Output); // NW quadrant RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - ScaledInput -> TellWidth() / 2 - 1, 0, ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - 2 * ScaledInput -> TellWidth(), 0); RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - ScaledInput -> TellWidth() / 2 - 1, 0, ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - 3 * ScaledInput -> TellWidth() / 2, 0); // SE quadrant RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - 1, ScaledInput -> TellHeight() / 2, ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - ScaledInput -> TellWidth(), ScaledInput -> TellHeight()); RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - 1, ScaledInput -> TellHeight() / 2, ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - ScaledInput -> TellWidth(), 3 * ScaledInput -> TellHeight() / 2); } }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { w.DrawRect(r, paper); Image m = q; if(!IsNull(m)) w.DrawImage(r.left, r.top, Rescale(m, r.GetSize())); }
ribi::FunctionPlotterMainDialog::FunctionPlotterMainDialog( const std::string& formula, const double x_min, const double x_max, const int n_cols ) : m_x(std::vector<double>(n_cols,0.0)), m_y(std::vector<double>(n_cols,0.0)) { #ifndef NDEBUG assert(Rescale(2.0,1.0,5.0,0.0,100.0) >= 24.9999 && Rescale(2.0,1.0,5.0,0.0,100.0) < 25.0001); #endif FunctionParser f; f.Parse(formula,"x"); if (f.GetParseErrorType()!= FunctionParser::FP_NO_ERROR) { throw std::runtime_error("Function cannot not be parsed"); } if (x_min >= x_max) { throw std::runtime_error("Value of x_min must be smaller than x_max"); } //Evaluate the function in a 2D std::vector const double n_cols_d = static_cast<double>(n_cols); for (int x = 0; x!=n_cols; ++x) { const double xD = static_cast<double>(x); const double x_scaled = Rescale(xD,0.0,n_cols_d,x_min,x_max); const double xs[1] = { x_scaled }; const double y = f.Eval(xs); if (!f.EvalError()) { m_y[x] = y; } else { m_y[x] = 0.0; } m_x[x] = x_scaled; } }
Image Rescale(const Image& src, Size sz, const Rect& src_rc, Gate<int, int> progress) { if(src.GetSize() == sz && src_rc == sz) return src; ImageRaster isrc(src); ImageEncoder tgt; Rescale(tgt, sz, isrc, src_rc); return tgt; }
void ResourceLibraryDialog::ConstructList() { wxLogNull noLogPlease; listCtrl->ClearAll(); wxImageList * imageList = new wxImageList(40,40); imageList->Add(gd::CommonBitmapProvider::Get()->parentFolder40); //If we are in the root path, do not display Parent folder item wxFileName currentDirPath(currentDir); currentDirPath.Normalize(); wxFileName rootPath(wxGetCwd()+"/Free resources/"); rootPath.Normalize(); if ( currentDirPath.GetFullPath() != rootPath.GetFullPath() ) listCtrl->InsertItem(0, _("Parent folder"), 0); //Browse file and directories wxDir dir(currentDir); wxString filename; bool cont = dir.GetFirst(&filename, "", wxDIR_DEFAULT); while ( cont ) { if ( wxDirExists(currentDir+"/"+filename) ) { //Only add a directory if there is a GDLibrary.txt file inside it. if ( wxFileExists(currentDir+"/"+filename+"/GDLibrary.txt") ) { wxBitmap folderBmp = gd::CommonBitmapProvider::Get()->folder40; if ( wxFileExists(currentDir+"/"+filename+"/GDLibraryIcon.png") ) PasteBitmap(folderBmp, wxBitmap(currentDir+"/"+filename+"/GDLibraryIcon.png", wxBITMAP_TYPE_ANY), 20,20 ); imageList->Add(folderBmp); listCtrl->InsertItem(1, filename, imageList->GetImageCount()-1); } } else { //Do not display the library icon if ( filename != "GDLibraryIcon.png" ) { wxLogNull noLogPlease; wxBitmap bmp(currentDir+"/"+filename, wxBITMAP_TYPE_ANY); if ( bmp.IsOk() ) { wxBitmap resizedBmp = Rescale(bmp,40,40); imageList->Add(resizedBmp); listCtrl->InsertItem(listCtrl->GetItemCount(), filename, imageList->GetImageCount()-1); } } } cont = dir.GetNext(&filename); } listCtrl->AssignImageList(imageList, wxIMAGE_LIST_NORMAL); }
static int EmitRescaledYUV(const VP8Io* const io, WebPDecParams* const p) { const int mb_h = io->mb_h; const int uv_mb_h = (mb_h + 1) >> 1; WebPRescaler* const scaler = p->scaler_y; int num_lines_out = 0; if (WebPIsAlphaMode(p->output->colorspace) && io->a != NULL) { // Before rescaling, we premultiply the luma directly into the io->y // internal buffer. This is OK since these samples are not used for // intra-prediction (the top samples are saved in cache_y_/u_/v_). // But we need to cast the const away, though. WebPMultRows((uint8_t*)io->y, io->y_stride, io->a, io->width, io->mb_w, mb_h, 0); } num_lines_out = Rescale(io->y, io->y_stride, mb_h, scaler); Rescale(io->u, io->uv_stride, uv_mb_h, p->scaler_u); Rescale(io->v, io->uv_stride, uv_mb_h, p->scaler_v); return num_lines_out; }
Image RichPNG::ToImage(const Value& data, Size sz, void *) const { if(IsString(data)) { ImageAnyDraw iw(sz); Paint(data, iw, sz); return iw; } Image x = Image(data); Size outsz(min(sz.cx, 4 * x.GetWidth()), min(sz.cy, 4 * x.GetHeight())); return Rescale(x, outsz); }
Image RichRawImage::ToImage(const Value& data, Size sz, void *) const { String s = data; StringStream ss(s); One<StreamRaster> r = StreamRaster::OpenAny(ss); if(r) { Image x = r->GetImage(); return Rescale(x, sz); } return Null; }
static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p) { if (io->a != NULL) { const WebPYUVABuffer* const buf = &p->output->u.YUVA; uint8_t* dst_y = buf->y + p->last_y * buf->y_stride; const uint8_t* src_a = buf->a + p->last_y * buf->a_stride; const int num_lines_out = Rescale(io->a, io->width, io->mb_h, &p->scaler_a); if (num_lines_out > 0) { // unmultiply the Y WebPMultRows(dst_y, buf->y_stride, src_a, buf->a_stride, p->scaler_a.dst_width, num_lines_out, 1); } } return 0; }
//--------------------------------------------------------------------------- void __fastcall TFormMain::ButtonDoClick( TObject *Sender) { const std::vector<std::vector<int> > source_int = ImageToVector(ImageSource); const std::vector<std::vector<double> > source = Convert<int,double>(source_int); const std::vector<std::vector<double> > result_unscaled = DoFilterOperation(source,mFilter); const std::vector<std::vector<double> > result_scaled = Rescale(result_unscaled,0.0,255.9); const std::vector<std::vector<int> > result = Convert<double,int>(result_scaled); VectorToImage(result,ImageTarget); ImageTarget->Visible = true; ImageTarget->Refresh(); ButtonSaveResult->Enabled = true; ++PageControl->ActivePageIndex; }
//From http://www.richelbilderbeek.nl/CppRescale.htm const std::vector<double> Rescale( std::vector<double> v, const double newMin, const double newMax) { const double oldMin = *std::min_element(v.begin(),v.end()); const double oldMax = *std::max_element(v.begin(),v.end()); typedef std::vector<double>::iterator Iter; Iter i = v.begin(); const Iter j = v.end(); for ( ; i!=j; ++i) { *i = Rescale(*i,oldMin,oldMax,newMin,newMax); } return v; }
void RichRawImage::Paint(const Value& data, Draw& w, Size sz, void *) const { String s = data; StringStream ss(s); One<StreamRaster> r = StreamRaster::OpenAny(ss); if(r) { Size isz = r->GetSize(); if(isz.cx * isz.cy > sz.cx * sz.cy) { // conserve memory by scaling down from source ImageEncoder m; Rescale(m, sz, *r, r->GetSize()); w.DrawImage(0, 0, sz.cx, sz.cy, m); } else w.DrawImage(0, 0, sz.cx, sz.cy, r->GetImage()); // scale up by Draw to give e.g. PDF chance to store unscaled } }
int AseFile::Init(char *file_name, int MipLevels, int rotateX90, float scale, int loadNormalMap, int loadHeightMap) { char strMessage[255]={0}; DeleteAll(); file = fopen( file_name, "rb"); if(!file) { sprintf(strMessage, "Unable to find the file: %s!", file_name); MessageBox(NULL, strMessage, "Error", MB_OK); return 0; } char *pdest = strrchr( file_name, '/' ); if( pdest==NULL)directory[0]=NULL; else { strncpy( directory, file_name, pdest-file_name+1); directory[pdest-file_name+1]=NULL; } int ret = ReadAseFile(); fclose( file ); if(!ret)return 0; if(!LoadTexturesDiffuse(MipLevels))return 0; if(loadNormalMap) if(!LoadTexturesNormal(MipLevels))return 0; if(loadHeightMap) if(!LoadTexturesHeight(MipLevels))return 0; if(rotateX90)RotateX90(); if(scale!=1.0f)Rescale( scale); MakeBoundingBoxs(); for(int i=0; i<objects.size(); i++) // if(objects[i].pFaceNormals==NULL || objects[i].pNormals==NULL) ComputeNormals(objects[i]); if(loadNormalMap) ComputeTangentBinormal(); return 1; }
bool KPboardView::CreateTexture(unsigned int TextureSize, const std::string &file, bool Nearest, unsigned int *pId) { // define a Display List WOOD_TEXTURE containing light and texture stuff auto pTexture = std::make_unique<BTexture>(); auto *texels = pTexture->ReadTextureFromFile(file, 0); if (texels == nullptr) { return false; } texels = pTexture->Rescale(BTexture::GetExpToBase2(TextureSize), TEX_SMALLER | TEX_RESCALE_AVG); auto width = pTexture->GetWidth(); auto height = pTexture->GetHeight(); if (!BTexture::IsPowerOf2(width) || !BTexture::IsPowerOf2(height)) { message(MsgType::Warning, "Width or Height of '", file, "' is not a power of 2\n"); } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, *pId); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (Nearest ? GL_NEAREST : GL_LINEAR)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (Nearest ? GL_NEAREST : GL_LINEAR)); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texels); // Avoid to bind the texture by another glTexImage2D: glBindTexture(GL_TEXTURE_2D, 0); return true; }
void C2DMap::OnRButtonDown(UINT nFlags, CPoint point) { if (dragsector) // cancel drag sector { dragsector = NULL; Rescale(); Invalidate(TRUE); UpdateWindow(); } else { // start an aleph creation if (createaleph = IsOverSector(point)) { createalephTOpos2D = point; SetCapture(); } } CWnd::OnRButtonDown(nFlags, point); }
static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p, int expected_num_lines_out) { const WebPYUVABuffer* const buf = &p->output->u.YUVA; uint8_t* const dst_a = buf->a + p->last_y * buf->a_stride; if (io->a != NULL) { uint8_t* const dst_y = buf->y + p->last_y * buf->y_stride; const int num_lines_out = Rescale(io->a, io->width, io->mb_h, p->scaler_a); assert(expected_num_lines_out == num_lines_out); if (num_lines_out > 0) { // unmultiply the Y WebPMultRows(dst_y, buf->y_stride, dst_a, buf->a_stride, p->scaler_a->dst_width, num_lines_out, 1); } } else if (buf->a != NULL) { // the user requested alpha, but there is none, set it to opaque. assert(p->last_y + expected_num_lines_out <= io->scaled_height); FillAlphaPlane(dst_a, io->scaled_width, expected_num_lines_out, buf->a_stride); } return 0; }
// ----------------------------------------------------------------------------- // SIconButton class constructor // ----------------------------------------------------------------------------- SIconButton::SIconButton(wxWindow* parent, Icons::Type icon_type, const wxString& icon, const wxString& tooltip) : wxBitmapButton{ parent, -1, wxNullBitmap } { // Create icon auto bmp = Icons::getIcon(icon_type, icon.ToStdString(), UI::scaleFactor() > 1.); // Scale icon if required auto size = UI::scalePx(16); if (bmp.GetWidth() != size) { auto img = bmp.ConvertToImage(); img.Rescale(size, size, wxIMAGE_QUALITY_BICUBIC); bmp = wxBitmap(img); } // Set button image and tooltip SetBitmap(bmp); if (!tooltip.empty()) SetToolTip(tooltip); }
//-------------------------------------------------------------------------- void C2DMap::BuildMapTables(void) { mapalephs.RemoveAll(); SMapAleph *pmapaleph; if (igcmap == NULL) return; POSITION pos = igcmap->cl_alephs.GetHeadPosition(); for (int i=0;i < igcmap->cl_alephs.GetCount();i++) { CIGCAleph *paleph; paleph = &(igcmap->cl_alephs.GetNext(pos)); if (!KnownAleph(paleph)) { pmapaleph = new SMapAleph; pmapaleph->aleph1 = paleph; pmapaleph->sect1 = FindSector(paleph); pmapaleph->aleph2 = FindConnectingAleph(paleph); pmapaleph->sect2 = FindSector(pmapaleph->aleph2); mapalephs.AddTail(*pmapaleph); } } Rescale(); }
//--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppRescale.htm const std::vector<std::vector<double> > Rescale( std::vector<std::vector<double> > v, const double newMin, const double newMax) { const double oldMin = MinElement(v); const double oldMax = MaxElement(v); typedef std::vector<std::vector<double> >::iterator RowIter; RowIter y = v.begin(); const RowIter maxy = v.end(); for ( ; y!=maxy; ++y) { typedef std::vector<double>::iterator ColIter; ColIter x = y->begin(); const ColIter maxx = y->end(); for ( ; x!=maxx; ++x) { *x = Rescale(*x,oldMin,oldMax,newMin,newMax); } } return v; }
void C2DMap::OnLButtonUp(UINT nFlags, CPoint point) { ReleaseCapture(); if (dragsector) { if (dragorigin != dragsector->pos2D) { dragsector->igcsector.posx = MAP2DUNSCALEX(dragsector->pos2D.x,maxx); dragsector->igcsector.posy = MAP2DUNSCALEY(dragsector->pos2D.y,maxy,MapH); // dont allow neg values for now if (dragsector->igcsector.posx <0.0) dragsector->igcsector.posx = 0.0; if (dragsector->igcsector.posy <0.0) dragsector->igcsector.posy = 0.0; } dragsector = NULL; Rescale(); Invalidate(TRUE); UpdateWindow(); } CWnd::OnLButtonUp(nFlags, point); }
void C2DMap::OnRButtonUp(UINT nFlags, CPoint point) { ReleaseCapture(); if (createaleph) { CIGCSector *destaleph = IsOverSector(point); if (destaleph) // mouse was released over a sector so create an aleph { if (destaleph != createaleph) // dont create to self :) { CMAPDlg *cdlg = (CMAPDlg *) CWnd::GetParent(); cdlg->CreateAleph(createaleph,destaleph); BuildMapTables(); } } createaleph = NULL; Rescale(); Invalidate(TRUE); UpdateWindow(); } CWnd::OnRButtonUp(nFlags, point); }