// TODO: eliminate the use of this function wxPoint ViewPort::GetPixFromLL( double lat, double lon ) { wxPoint2DDouble p = GetDoublePixFromLL(lat, lon); if(wxIsNaN(p.m_x) || wxIsNaN(p.m_y)) return wxPoint(INVALID_COORD, INVALID_COORD); return wxPoint(wxRound(p.m_x), wxRound(p.m_y)); }
void BITMAP_BASE::DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos ) { if( m_bitmap == NULL ) return; wxPoint pos = aPos; wxSize size = GetSize(); // To draw the bitmap, pos is the upper left corner position pos.x -= size.x / 2; pos.y -= size.y / 2; double scale; int logicalOriginX, logicalOriginY; aDC->GetUserScale( &scale, &scale ); aDC->GetLogicalOrigin( &logicalOriginX, &logicalOriginY ); aDC->SetUserScale( scale * GetScalingFactor(), scale * GetScalingFactor() ); aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(), logicalOriginY / GetScalingFactor() ); aDC->DrawBitmap( *m_bitmap, wxRound( pos.x / GetScalingFactor() ), wxRound( pos.y / GetScalingFactor() ), true ); aDC->SetUserScale( scale, scale ); aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY ); }
void wxGCDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { wxASSERT(n > 1); wxGraphicsPath path = m_graphicContext->CreatePath(); int i = 0; for ( int j = 0; j < n; ++j) { wxPoint start = points[i]; path.MoveToPoint( start.x+ xoffset, start.y+ yoffset); ++i; int l = count[j]; for ( int k = 1; k < l; ++k) { path.AddLineToPoint( points[i].x+ xoffset, points[i].y+ yoffset); ++i; } // close the polygon if ( start != points[i-1]) path.AddLineToPoint( start.x+ xoffset, start.y+ yoffset); } m_graphicContext->DrawPath( path , fillStyle); wxRect2DDouble box = path.GetBox(); CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); CalcBoundingBox(wxRound(box.m_x + box.m_width), wxRound(box.m_y + box.m_height)); }
// Deduce m_FromFrequency from the samples at the beginning of // the selection. Then set some other params accordingly. void EffectChangePitch::DeduceFrequencies() { // As a neat trick, attempt to get the frequency of the note at the // beginning of the selection. SelectedTrackListOfKindIterator iter(Track::Wave, inputTracks()); WaveTrack *track = (WaveTrack *) iter.First(); if (track) { double rate = track->GetRate(); // Auto-size window -- high sample rates require larger windowSize. // Aim for around 2048 samples at 44.1 kHz (good down to about 100 Hz). // To detect single notes, analysis period should be about 0.2 seconds. // windowSize must be a power of 2. const size_t windowSize = // windowSize < 256 too inaccurate std::max(256, wxRound(pow(2.0, floor((log(rate / 20.0)/log(2.0)) + 0.5)))); // we want about 0.2 seconds to catch the first note. // number of windows rounded to nearest integer >= 1. const unsigned numWindows = std::max(1, wxRound((double)(rate / (5.0f * windowSize)))); double trackStart = track->GetStartTime(); double t0 = mT0 < trackStart? trackStart: mT0; auto start = track->TimeToLongSamples(t0); auto analyzeSize = windowSize * numWindows; Floats buffer{ analyzeSize }; Floats freq{ windowSize / 2 }; Floats freqa{ windowSize / 2, true }; track->Get((samplePtr) buffer.get(), floatSample, start, analyzeSize); for(unsigned i = 0; i < numWindows; i++) { ComputeSpectrum(buffer.get() + i * windowSize, windowSize, windowSize, rate, freq.get(), true); for(size_t j = 0; j < windowSize / 2; j++) freqa[j] += freq[j]; } size_t argmax = 0; for(size_t j = 1; j < windowSize / 2; j++) if (freqa[j] > freqa[argmax]) argmax = j; auto lag = (windowSize / 2 - 1) - argmax; m_dStartFrequency = rate / lag; } double dFromMIDInote = FreqToMIDInote(m_dStartFrequency); double dToMIDInote = dFromMIDInote + m_dSemitonesChange; m_nFromPitch = PitchIndex(dFromMIDInote); m_nFromOctave = PitchOctave(dFromMIDInote); m_nToPitch = PitchIndex(dToMIDInote); m_nToOctave = PitchOctave(dToMIDInote); m_FromFrequency = m_dStartFrequency; Calc_PercentChange(); Calc_ToFrequency(); }
void wxSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const { if (width) *width = wxRound( (double)m_width / m_mm_to_pix_x ); if (height) *height = wxRound( (double)m_height / m_mm_to_pix_y ); }
void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); if ( text.empty() ) return; if ( !m_logicalFunctionSupported ) return; // we test that we have some font because otherwise we should still use the // "else" part below to avoid that DrawRotatedText(angle = 180) and // DrawRotatedText(angle = 0) use different fonts (we can't use the default // font for drawing rotated fonts unfortunately) if ( (angle == 0.0) && m_font.IsOk() ) { DoDrawText(text, x, y); // Bounding box already updated by DoDrawText(), no need to do it again. return; } // Get extent of whole text. wxCoord w, h, heightLine; GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine); // Compute the shift for the origin of the next line. const double rad = wxDegToRad(angle); const double dx = heightLine * sin(rad); const double dy = heightLine * cos(rad); // Draw all text line by line const wxArrayString lines = wxSplit(text, '\n', '\0'); for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ ) { // Calculate origin for each line to avoid accumulation of // rounding errors. if ( m_backgroundMode == wxTRANSPARENT ) m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle )); else m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) ); } // call the bounding box by adding all four vertices of the rectangle // containing the text to it (simpler and probably not slower than // determining which of them is really topmost/leftmost/...) // "upper left" and "upper right" CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); // "bottom left" and "bottom right" x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); }
wxSize wxGetDisplaySizeMM() { const wxSize ppi = wxGetDisplayPPI(); if ( !ppi.x || !ppi.y ) return wxSize(0, 0); const wxSize pixels = wxGetDisplaySize(); return wxSize(wxRound(pixels.x * inches2mm / ppi.x), wxRound(pixels.y * inches2mm / ppi.y)); }
wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const { wxPoint pos = m_crossHairPosition - m_DrawOrg; double scalar = GetScalingFactor(); pos.x = wxRound( (double) pos.x * scalar ); pos.y = wxRound( (double) pos.y * scalar ); return pos; }
void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; wxCoord dx = x + w / 2.0; wxCoord dy = y + h / 2.0; wxDouble factor = ((wxDouble) w) / h; m_graphicContext->PushState(); m_graphicContext->Translate(dx, dy); m_graphicContext->Scale(factor, 1.0); wxGraphicsPath path = m_graphicContext->CreatePath(); // If end angle equals start angle we want draw a full ellipse. if (ea == sa) { ea += 360.0; } // since these angles (ea,sa) are measured counter-clockwise, we invert them to // get clockwise angles if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT ) { path.MoveToPoint( 0, 0 ); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false ); path.AddLineToPoint( 0, 0 ); m_graphicContext->FillPath( path ); path = m_graphicContext->CreatePath(); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false ); m_graphicContext->StrokePath( path ); } else { path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false ); m_graphicContext->DrawPath( path ); } wxRect2DDouble box = path.GetBox(); // apply the transformation to the box box.m_x *= factor; box.m_width *= factor; box.m_x += dx; box.m_y += dy; CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); CalcBoundingBox(wxRound(box.m_x + box.m_width), wxRound(box.m_y + box.m_height)); m_graphicContext->PopState(); }
void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event)) { if ( !m_bitmap.IsOk() ) return; wxPaintDC dc(this); const wxSize drawSize = GetClientSize(); const wxSize bmpSize = m_bitmap.GetSize(); wxDouble w = 0; wxDouble h = 0; switch ( m_scaleMode ) { case Scale_None: dc.DrawBitmap(m_bitmap, 0, 0, true); return; case Scale_Fill: w = drawSize.x; h = drawSize.y; break; case Scale_AspectFill: case Scale_AspectFit: { wxDouble scaleFactor; wxDouble scaleX = (wxDouble)drawSize.x / (wxDouble)bmpSize.x; wxDouble scaleY = (wxDouble)drawSize.y / (wxDouble)bmpSize.y; if ( ( m_scaleMode == Scale_AspectFit && scaleY < scaleX ) || ( m_scaleMode == Scale_AspectFill && scaleY > scaleX ) ) scaleFactor = scaleY; else scaleFactor = scaleX; w = bmpSize.x * scaleFactor; h = bmpSize.y * scaleFactor; break; } } wxASSERT_MSG(w, wxS("Unknown scale mode")); wxDouble x = (drawSize.x - w) / 2; wxDouble y = (drawSize.y - h) / 2; #if wxUSE_GRAPHICS_CONTEXT wxScopedPtr<wxGraphicsContext> const gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc)); gc->DrawBitmap(m_bitmap, x, y, w, h); #else wxImage img = m_bitmap.ConvertToImage(); img.Rescale(wxRound(w), wxRound(h), wxIMAGE_QUALITY_HIGH); dc.DrawBitmap(wxBitmap(img), wxRound(x), wxRound(y), true); #endif }
bool wxUIActionSimulator::MouseMove(long x, long y) { // Because MOUSEEVENTF_ABSOLUTE takes measurements scaled between 0 & 65535 // we need to scale our input too int displayx, displayy; wxDisplaySize(&displayx, &displayy); int scaledx = wxRound(((float)x / displayx) * 65535); int scaledy = wxRound(((float)y / displayy) * 65535); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaledx, scaledy, 0, 0); return true; }
void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; double dx = x1 - xc; double dy = y1 - yc; double radius = sqrt((double)(dx * dx + dy * dy)); wxCoord rad = (wxCoord)radius; double sa, ea; if (x1 == x2 && y1 == y2) { sa = 0.0; ea = 360.0; } else if (radius == 0.0) { sa = ea = 0.0; } else { sa = (x1 - xc == 0) ? (y1 - yc < 0) ? 90.0 : -90.0 : -atan2(double(y1 - yc), double(x1 - xc)) * RAD2DEG; ea = (x2 - xc == 0) ? (y2 - yc < 0) ? 90.0 : -90.0 : -atan2(double(y2 - yc), double(x2 - xc)) * RAD2DEG; } bool fill = m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT; wxGraphicsPath path = m_graphicContext->CreatePath(); if ( fill && ((x1!=x2)||(y1!=y2)) ) path.MoveToPoint( xc, yc ); // since these angles (ea,sa) are measured counter-clockwise, we invert them to // get clockwise angles path.AddArc( xc, yc , rad, wxDegToRad(-sa), wxDegToRad(-ea), false ); if ( fill && ((x1!=x2)||(y1!=y2)) ) path.AddLineToPoint( xc, yc ); m_graphicContext->DrawPath(path); wxRect2DDouble box = path.GetBox(); CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); CalcBoundingBox(wxRound(box.m_x + box.m_width), wxRound(box.m_y + box.m_height)); }
/* Function GetSize * returns the actual size (in user units, not in pixels) of the image */ wxSize BITMAP_BASE::GetSize() const { wxSize size; if( m_bitmap ) { size.x = m_bitmap->GetWidth(); size.y = m_bitmap->GetHeight(); size.x = wxRound( size.x * GetScalingFactor() ); size.y = wxRound( size.y * GetScalingFactor() ); } return size; }
numberPopup::numberPopup(wxWindow* parent,int ratio, wxColour colourGreen, wxWindowID) { //wxSizerFlags flagsExpand(1); //flagsExpand.Expand().Border(wxALL, 2); //(*Initialize(numberPopup) wxBoxSizer* BoxSizer1; Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSTAY_ON_TOP|wxDEFAULT_FRAME_STYLE|wxFRAME_NO_TASKBAR|wxNO_BORDER, _T("wxID_ANY")); BoxSizer1 = new wxBoxSizer(wxHORIZONTAL); Button1 = new wxButton(this, ID_BUTTON1, _("Label"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON1")); BoxSizer1->Add(Button1, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); SetSizer(BoxSizer1); Timer1.SetOwner(this, ID_TIMER1); BoxSizer1->Fit(this); BoxSizer1->SetSizeHints(this); Center(); Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&numberPopup::OnButton1Click); Connect(ID_TIMER1,wxEVT_TIMER,(wxObjectEventFunction)&numberPopup::OnTimer1Trigger); //*) //find the screen size wxSize displaySize = wxGetDisplaySize(); this->SetSize(wxDefaultCoord,wxDefaultCoord,wxRound((double(displaySize.GetWidth()))*(((double)ratio)/100)), wxRound((double(displaySize.GetHeight()))*(((double)ratio)/100)),wxSIZE_FORCE); Button1->SetBackgroundColour(colourGreen); this->SetBackgroundColour(colourGreen); }
void SplitterWindow2::updateSashPosition(const wxSize& oldSize, const wxSize& newSize) { initSashPosition(); if (m_splitMode != SplitMode_Unset) { const wxSize diff = newSize - oldSize; const int actualDiff = wxRound(m_sashGravity * h(diff)); setSashPosition(sashPosition(m_currentSplitRatio, h(oldSize)) + actualDiff); } }
void wxNativeFontInfo::SetFractionalPointSize(float pointsize) { wxString s; if ( pointsize < 0 ) s = '*'; else s.Printf("%d", wxRound(10*pointsize)); SetXFontComponent(wxXLFD_POINTSIZE, s); }
/* * Function PlotImage * Only Postscript plotters can plot bitmaps * for plotters that cannot plot a bitmap, a rectangle is plotted * For GERBER_PLOTTER, draws a rectangle * param aImage = the bitmap * param aPos = position of the center of the bitmap * param aScaleFactor = the scale factor to apply to the bitmap size * (this is not the plot scale factor) */ void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor ) { wxSize size; size.x = aImage.GetWidth(); size.y = aImage.GetHeight(); size.x = wxRound( size.x * aScaleFactor ); size.y = wxRound( size.y * aScaleFactor ); wxPoint start = aPos; start.x -= size.x / 2; start.y -= size.y / 2; wxPoint end = start; end.x += size.x; end.y += size.y; rect( start, end, NO_FILL ); }
wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) { wxPoint pt; wxRealPoint gridSize; if( aGridSize ) gridSize = *aGridSize; else gridSize = GetGridSize(); wxPoint gridOrigin = m_GridOrigin; double offset = fmod( gridOrigin.x, gridSize.x ); int x = wxRound( (aPosition.x - offset) / gridSize.x ); pt.x = wxRound( x * gridSize.x + offset ); offset = fmod( gridOrigin.y, gridSize.y ); int y = wxRound( (aPosition.y - offset) / gridSize.y ); pt.y = wxRound ( y * gridSize.y + offset ); return pt; }
wxString GRIBTable::GetWindBf(GribRecord **recordarray) { wxString skn(wxEmptyString); int altitude = 0; double vkn, ang; if(GribRecord::getInterpolatedValues(vkn, ang, recordarray[Idx_WIND_VX + altitude], recordarray[Idx_WIND_VY + altitude], m_cursor_lon, m_cursor_lat)) { vkn = m_pGDialog->m_OverlaySettings.GetmstobfFactor(vkn)* vkn; skn.Printf( wxString::Format( _T("%2d bf"), (int)wxRound( vkn )) ); } return skn; }
void EffectChangeSpeed::Update_Vinyl() // Update Vinyl controls from percent change. { // Match Vinyl rpm when within 0.01% of a standard ratio. // Ratios calculated as: ((toRPM / fromRPM) - 1) * 100 * 100 int ratio = wxRound(m_PercentChange * 100); switch (ratio) { case 0: // toRPM is the same as fromRPM if (mFromVinyl != kVinyl_NA) { mpChoice_ToVinyl->SetSelection(mpChoice_FromVinyl->GetSelection()); } else { // Use the last saved option. GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, 0); mpChoice_FromVinyl->SetSelection(mFromVinyl); mpChoice_ToVinyl->SetSelection(mFromVinyl); } break; case 3500: mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird); mpChoice_ToVinyl->SetSelection(kVinyl_45); break; case 13400: mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird); mpChoice_ToVinyl->SetSelection(kVinyl_78); break; case -2593: mpChoice_FromVinyl->SetSelection(kVinyl_45); mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird); break; case 7333: mpChoice_FromVinyl->SetSelection(kVinyl_45); mpChoice_ToVinyl->SetSelection(kVinyl_78); break; case -5727: mpChoice_FromVinyl->SetSelection(kVinyl_78); mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird); break; case -4231: mpChoice_FromVinyl->SetSelection(kVinyl_78); mpChoice_ToVinyl->SetSelection(kVinyl_45); break; default: mpChoice_ToVinyl->SetSelection(kVinyl_NA); } // and update variables. mFromVinyl = mpChoice_FromVinyl->GetSelection(); mToVinyl = mpChoice_ToVinyl->GetSelection(); }
bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ) { if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; wxPoint relpos = aPosRef - aTransform.TransformCoordinate( m_Pos ); int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) ); if( abs( dist - m_Radius ) <= aThreshold ) return true; return false; }
wxPoint CalcNegPos(const wxRealPoint& pos, const wxPoint& pxPos, int w, int h, int lm, int tm, int rm, int bm, wxDC* dc) { double origX = pos.x; double origY = pos.y; int px_x = pxPos.x; int px_y = pxPos.y; wxSize pageSize = dc->GetSize(); double sx, sy; dc->GetUserScale(&sx, &sy); int pagex = wxRound((double)(pageSize.x)/sx - lm - rm); int pagey = wxRound((double)(pageSize.y)/sy - tm - bm); int x = px_x + lm; int y = px_y + tm; if(origX < 0) x = pagex + px_x - w + lm / sx; else if(origX == wxRP_LEFT) x = lm; else if(origX == wxRP_CENTER) x = (pagex - w) / 2. + lm; else if(origX == wxRP_RIGHT) x = pagex - w + lm; if(origY < 0) y = pagey + px_x - h + tm / sy; else if(origY == wxRP_TOP) y = tm; else if(origY == wxRP_CENTER) y = (pagey - h) / 2. + tm; else if(origY == wxRP_BOTTOM) y = pagey - h + tm; return wxPoint(x, y); }
void DIALOG_ORIENT_FOOTPRINTS::OnOkClick( wxCommandEvent& event ) { double d_orient; wxString text = m_OrientationCtrl->GetValue(); if ( ! text.ToDouble(&d_orient) ) { DisplayError(this, _("Bad value for footprints orientation")); return; } newOrientation = wxRound(d_orient * 10); NORMALIZE_ANGLE_180( newOrientation ); EndModal( wxID_OK ); }
/* static */ int wxFontBase::AdjustToSymbolicSize(wxFontSymbolicSize size, int base) { // Using a fixed factor (1.2, from CSS2) is a bad idea as explained at // http://www.w3.org/TR/CSS21/fonts.html#font-size-props so use the values // from http://style.cleverchimp.com/font_size_intervals/altintervals.html // instead. static const float factors[] = { 0.60f, 0.75f, 0.89f, 1.f, 1.2f, 1.5f, 2.f }; wxCOMPILE_TIME_ASSERT ( WXSIZEOF(factors) == wxFONTSIZE_XX_LARGE - wxFONTSIZE_XX_SMALL + 1, WrongFontSizeFactorsSize ); return wxRound(factors[size - wxFONTSIZE_XX_SMALL]*base); }
void LIB_CIRCLE::calcEdit( const wxPoint& aPosition ) { if( m_Flags == IS_NEW || m_Flags == IS_RESIZED ) { if( m_Flags == IS_NEW ) SetEraseLastDrawItem(); int dx = m_Pos.x - aPosition.x; int dy = m_Pos.y - aPosition.y; m_Radius = wxRound( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) ); } else { Move( m_initialPos + aPosition - m_initialCursorPos ); } }
void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) { EDA_UNITS_T ii; DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetParent()->GetDisplayOptions(); displ_opts->m_DisplayPolarCood = ( m_PolarDisplay->GetSelection() == 0 ) ? false : true; ii = g_UserUnit; g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES; if( ii != g_UserUnit ) GetParent()->ReCreateAuxiliaryToolbar(); GetParent()->SetCursorShape( m_CursorShape->GetSelection() ); GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 ); GetParent()->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) ); GetParent()->GetScreen()->SetMaxUndoItems( m_spinMaxUndoItems->GetValue() ); /* Updating the combobox to display the active layer. */ displ_opts->m_MaxLinksShowed = m_MaxShowLinks->GetValue(); g_Drc_On = m_DrcOn->GetValue(); if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() ) { GetParent()->SetElementVisibility( RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() ); GetParent()->GetCanvas()->Refresh(); GetParent()->OnModify(); } displ_opts->m_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); g_Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue(); g_Track_45_Only_Allowed = m_Track_45_Only_Ctrl->GetValue(); GetParent()->GetCanvas()->SetEnableZoomNoCenter( ! m_ZoomCenterOpt->GetValue() ); GetParent()->GetCanvas()->SetEnableMiddleButtonPan( m_MiddleButtonPANOpt->GetValue() ); GetParent()->GetCanvas()->SetMiddleButtonPanLimited( m_OptMiddleButtonPanLimited->GetValue() ); GetParent()->GetCanvas()->SetEnableAutoPan( m_AutoPANOpt->GetValue() ); g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue(); g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection(); g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection(); g_DumpZonesWhenFilling = m_DumpZonesWhenFilling->GetValue(); EndModal( wxID_OK ); }
wxString GRIBTable::GetWindBf(GribRecord **recordarray) { wxString skn(wxEmptyString); if( recordarray[Idx_WIND_VX] && recordarray[Idx_WIND_VY] ) { double vx = recordarray[Idx_WIND_VX]-> getInterpolatedValue(m_pGDialog->m_cursor_lon, m_pGDialog->m_cursor_lat, true ); double vy = recordarray[Idx_WIND_VY]-> getInterpolatedValue(m_pGDialog->m_cursor_lon, m_pGDialog->m_cursor_lat, true ); if( ( vx != GRIB_NOTDEF ) && ( vy != GRIB_NOTDEF ) ) { double vkn = sqrt( vx * vx + vy * vy ); vkn = m_pGDialog->m_OverlaySettings.GetmstobfFactor(vkn)* vkn; skn.Printf( wxString::Format( _T("%2d bf"), (int)wxRound( vkn )) ); } } return skn; }
bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) { if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; // TODO: use aTransMat to calculates parameters wxPoint relativePosition = aPosition; NEGATE( relativePosition.y ); // reverse Y axis int distance = wxRound( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) ); if( abs( distance - m_Radius ) > aThreshold ) return false; // We are on the circle, ensure we are only on the arc, i.e. between // m_ArcStart and m_ArcEnd wxPoint startEndVector = TwoPointVector( m_ArcStart, m_ArcEnd); wxPoint startRelativePositionVector = TwoPointVector( m_ArcStart, relativePosition ); wxPoint centerStartVector = TwoPointVector( m_Pos, m_ArcStart ); wxPoint centerEndVector = TwoPointVector( m_Pos, m_ArcEnd ); wxPoint centerRelativePositionVector = TwoPointVector( m_Pos, relativePosition ); // Compute the cross product to check if the point is in the sector int crossProductStart = CrossProduct( centerStartVector, centerRelativePositionVector ); int crossProductEnd = CrossProduct( centerEndVector, centerRelativePositionVector ); // The cross products need to be exchanged, depending on which side the center point // relative to the start point to end point vector lies if( CrossProduct( startEndVector, startRelativePositionVector ) < 0 ) { EXCHG( crossProductStart, crossProductEnd ); } // When the cross products have a different sign, the point lies in sector // also check, if the reference is near start or end point return HitTestPoints( m_ArcStart, relativePosition, MINIMUM_SELECTION_DISTANCE ) || HitTestPoints( m_ArcEnd, relativePosition, MINIMUM_SELECTION_DISTANCE ) || ( crossProductStart <= 0 && crossProductEnd >= 0 ); }
/** * Function circle * writes a non filled circle to output file * Plot one circle as segments (6 to 16 depending on its radius * @param aCentre = center coordinates * @param aDiameter = diameter of the circle * @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR) * not used here: circles are always not filled the gerber. Filled circles are flashed * @param aWidth = line width */ void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int aWidth ) { wxASSERT( output_file ); wxPoint start, end; double radius = aDiameter / 2; const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */ start.x = aCentre.x + wxRound( radius ); start.y = aCentre.y; set_current_line_width( aWidth ); move_to( start ); for( int ii = delta; ii < 3600; ii += delta ) { end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( (double)ii / 10.0 ) ) ); end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( (double)ii / 10.0 ) ) ); line_to( end ); } finish_to( start ); }
void LATITUDE::Write( SENTENCE& sentence ) { wxString temp_string; int neg = 0; int d; int m; if (Latitude < 0.0) { Latitude = -Latitude; neg = 1; } d = (int) Latitude; double m0 = (Latitude - (double) d) * 60000.0; m = (int)wxRound(m0); if (neg) d = -d; temp_string.Printf(_T("%02d%02d.%03d"), d, m / 1000, m % 1000); sentence += temp_string; if ( Northing == North ) { sentence += _T("N"); } else if ( Northing == South ) { sentence += _T("S"); } else { /* ** Add Nothing */ } }