void clGUIWindow::PreRender() { clGUIDialogWindow::PreRender(); static const float ResizeCornerW = Env->GUI->GetDefaultResizeCornerWidth(); static const float ResizeCornerH = Env->GUI->GetDefaultResizeCornerHeight(); UpdateUniformsV( FResizeCornerShader, LVector4( GetX2(), GetY2(), GetX2() - ResizeCornerW, GetY2() + ResizeCornerH ) ); UpdateUniformsV( FResizeCornerHighlightShader, LVector4( GetX2(), GetY2(), GetX2() - ResizeCornerW, GetY2() + ResizeCornerH ) ); FResizeCornerHighlighted ? Env->Renderer->AddBuffer( FResizeCornerGeometry, FResizeCornerHighlightShader, 1, false ) : Env->Renderer->AddBuffer( FResizeCornerGeometry, FResizeCornerShader, 1, false ); static const float CloseButtonW = Env->GUI->GetDefaultCloseButtonWidth(); static const float CloseButtonH_D1 = Env->GUI->GetDefaultCloseButtonHeight_Delta1(); static const float CloseButtonH_D2 = Env->GUI->GetDefaultCloseButtonHeight_Delta2(); if ( FCloseButtonHighlighted ) { UpdateUniformsV( FCloseButtonHighlightShader, LVector4( GetX2() - CloseButtonW, GetY1() + CloseButtonH_D1, GetX2(), GetY1() + CloseButtonH_D2 ) ); Env->Renderer->AddBuffer( FCloseButtonGeometry, FCloseButtonHighlightShader, 1, false ); } else { UpdateUniformsV( FCloseButtonShader, LVector4( GetX2() - CloseButtonW, GetY1() + CloseButtonH_D1, GetX2(), GetY1() + CloseButtonH_D2 ) ); UpdateUniformsV( FCloseButtonCaptionHighlightedShader, LVector4( GetX2() - CloseButtonW, GetY1() + CloseButtonH_D1, GetX2(), GetY1() + CloseButtonH_D2 ) ); ContainsCaption( Local2Screen( GetMousePos() ) ) ? Env->Renderer->AddBuffer( FCloseButtonGeometry, FCloseButtonCaptionHighlightedShader, 1, false ) : Env->Renderer->AddBuffer( FCloseButtonGeometry, FCloseButtonShader, 1, false ); } }
void CGraphPanel::SetMaxY(double y, BOOL bRedraw) { if (__max(GetY1(), GetY2()) == GetY1()) { SetWorldCoords(GetX1(), GetX2(), y, GetY2(), bRedraw); } else { SetWorldCoords(GetX1(), GetX2(), GetY1(), y, bRedraw); }; }
void CGraphPanel::SetMinX(double x, BOOL bRedraw) { if (__min(GetX1(), GetX2()) == GetX1()) { SetWorldCoords(x, GetX2(), GetY1(), GetY2(), bRedraw); } else { SetWorldCoords(GetX1(), x, GetY1(), GetY2(), bRedraw); }; }
wxSVGRect wxSVGLineElement::GetBBox(wxSVG_COORDINATES coordinates) { wxSVGPoint p1 = wxSVGPoint(GetX1().GetAnimVal(), GetY1().GetAnimVal()); wxSVGPoint p2 = wxSVGPoint(GetX2().GetAnimVal(), GetY2().GetAnimVal()); if (coordinates != wxSVG_COORDINATES_USER) { wxSVGMatrix matrix = GetMatrix(coordinates); p1 = p1.MatrixTransform(matrix); p2 = p2.MatrixTransform(matrix); } double x1 = p1.GetX(); double y1 = p1.GetY(); double x2 = p2.GetX(); double y2 = p2.GetY(); wxSVGRect bbox(x1, y1, x2 - x1, y2 - y1); if (x1 > x2) { bbox.SetX(x2); bbox.SetWidth(x1 - x2); } if (y1 > y2) { bbox.SetY(y2); bbox.SetHeight(y1 - y2); } return bbox; }
void CGraphPanel::GetWorldCoords(double* x1, double* x2, double* y1, double* y2) { *x1 = GetX1(); *x2 = GetX2(); *y1 = GetY1(); *y2 = GetY2(); }
void CGraphPanel::SetWorldCoords(double _x1, double _x2, double _y1, double _y2, BOOL bRedraw) { if (_x1 != GetX1() || _x2 != GetX2() || _y1 != GetY1() || _y2 != GetY2()) { InitCoords(_x1, _x2, _y1, _y2); if (vruler != NULL) { vruler->SetMinMax(_y1, _y2, FALSE); if (bRedraw) { vruler->RedrawWindow(); }; }; if (hruler != NULL) { hruler->SetMinMax(_x1, _x2, FALSE); if (bRedraw) { hruler->RedrawWindow(); }; }; if (bRedraw) { UpdateGraphWindow(NULL); }; }; }
void CAccumulator::ComputeMeanP_Y1_Y2() { m_meanP = ComputeMeanPrecipitation(); m_X1 = ComputeCVPrecipitation(); m_X2 = ComputeAverageWaterDefecit(); m_Y1 = GetY1(m_X1); m_Y2 = GetY2(m_X2); }
void clGUIStaticRect::PreRender() { iGUIView::PreRender(); LVector4 Color( GetDefaultColor() ); Color.W = GetViewOpacity(); Env->Renderer->GetCanvas()->Rect( GetX1(), GetY1(), GetX2(), GetY2(), Color ); }
void CGraphPanel::OnSize(UINT nType, int cx, int cy) { InitCoords(GetX1(), GetX2(), GetY1(), GetY2()); CWnd::OnSize(nType, cx, cy); if(offscreen) {// update offscreen CRect r; GetClientRect(&r); CSize s = r.Size(); offscreen->ResizeDib( s.cx, s.cy ); } }
void CGraphPanel::AppendPropertyPage(CPropertySheet* prop_sheet) { graph_prop_page = new CGraphPropertyPage(); graph_prop_page->m_x1 = GetX1(); graph_prop_page->m_x2 = GetX2(); graph_prop_page->m_y1 = GetY1(); graph_prop_page->m_y2 = GetY2(); graph_prop_page->m_PointMarks = (GetGraphixFlags() & GRAPH_SQUAREPOINTS) != 0; graph_prop_page->m_MouseCoords = (GetGraphixFlags() & GRAPH_SHOW_TOOLTIP) != 0; graph_prop_page->m_ShowAxis = (GetGraphixFlags() & GRAPH_DRAW_AXIS) != 0; prop_sheet->AddPage(graph_prop_page); }
LVector4 clGUISlider::GetSliderCoords() { if ( FCurrentValue < 0 ) { FCurrentValue = 0; } if ( FCurrentValue > GetWidth() - SliderWidth ) { FCurrentValue = GetWidth() - SliderWidth; } float dX1 = FCurrentValue; float dX2 = FCurrentValue + SliderWidth; return LVector4( GetX1() + dX1, GetY1(), GetX1() + dX2, GetY2() ); }
void CGraphPanel::OnMouseMove(UINT nFlags, CPoint point) { //tooltips tipCount -= 1; if (tipCount<=0) { tooltip.Activate((m_grflags & GRAPH_SHOW_TOOLTIP) == GRAPH_SHOW_TOOLTIP); if ((m_grflags & GRAPH_SHOW_TOOLTIP) == GRAPH_SHOW_TOOLTIP) { CString str; GetToolTipString(point, str); tooltip.UpdateTipText(str, this); }; tipCount = MAX_TIP_COUNT; }; //panning if (m_bPanning) { m_PanStart = m_PanStop; m_PanStop = point; double dx = CurrentCoordsX->XtoW(m_PanStart.x) - CurrentCoordsX->XtoW(m_PanStop.x); double dy = CurrentCoordsY->XtoW(m_PanStart.y) - CurrentCoordsY->XtoW(m_PanStop.y); SetWorldCoords( GetX1()+dx, GetX2()+dx, GetY1()+dy, GetY2()+dy, TRUE); } else { //if on-the-fly zoom is active - redraw new rectangle if (bCreateZoomRect) { CRect old_rect(new_zoom_1.x, new_zoom_1.y, new_zoom_2.x, new_zoom_2.y); old_rect.NormalizeRect(); new_zoom_2 = point; CRect rect(new_zoom_1.x, new_zoom_1.y, new_zoom_2.x, new_zoom_2.y); rect.NormalizeRect(); zoomrect->m_rect = rect; old_rect.UnionRect(&old_rect, &rect); old_rect.InflateRect(2, 2); InvalidateRect(&old_rect, FALSE); }; }; CWnd::OnMouseMove(nFlags, point); }
void CGraphPanel::OnLButtonUp(UINT nFlags, CPoint point) { //panning if (m_bPanning) { m_bPanning = FALSE; m_PanStop = point; double dx = CurrentCoordsX->XtoW(m_PanStart.x) - CurrentCoordsX->XtoW(m_PanStop.x); double dy = CurrentCoordsY->XtoW(m_PanStart.y) - CurrentCoordsY->XtoW(m_PanStop.y); SetWorldCoords(GetX1()+dx, GetX2()+dx, GetY1()+dy, GetY2()+dy, TRUE); } else { //zoom if (bCreateZoomRect) { CRect old_rect(new_zoom_1.x, new_zoom_1.y, new_zoom_2.x, new_zoom_2.y); old_rect.NormalizeRect(); new_zoom_2 = point; bCreateZoomRect = FALSE; CRect rect(new_zoom_1.x, new_zoom_1.y, new_zoom_2.x, new_zoom_2.y); rect.NormalizeRect(); zoomrect->m_rect = rect; if (new_zoom_1 != new_zoom_2) { bZoomActive = TRUE; }; old_rect.UnionRect(&old_rect, &rect); old_rect.InflateRect(2, 2); InvalidateRect(&old_rect, FALSE); }; }; CWnd::OnLButtonUp(nFlags, point); }
void CGraphPanel::DoFit(UINT fitType) { CGraphWnd* main_wnd = get_main_graph_window(); if (main_wnd == NULL) return; double x1, x2, y1, y2; if (!main_wnd->GetBoundRect(&x1, &x2, &y1, &y2)) return; if (x1 == x2) x1 = x2 = x1*0.9; if (y1 == y2) y1 = y2 = y1*0.9; switch (fitType) { case GRAPH_RBMC_FIT_WIDTH: { y1 = GetY1(); y2 = GetY2(); }; break; case GRAPH_RBMC_FIT_HEIGHT: { x1 = GetX1(); x2 = GetX2(); }; break; case GRAPH_RBMC_FIT_PAGE: { }; break; }; SetWorldCoords(x1, x2, y1, y2, TRUE); }
LVector4 clGUIGauge::GetUniformsVec() const { static const float OffsetX = Env->GUI->GetDefaultGaugeXOffset(); static const float OffsetY = Env->GUI->GetDefaultGaugeYOffset(); float Percent = 1.0f; if ( FMaxValue > 0 ) { Percent = static_cast<float>( FCurrentValue ) / static_cast<float>( FMaxValue ); } float BarLen = ( GetX2() - GetX1() ) * Percent; return LVector4( GetX1() + OffsetX, GetY1() + OffsetY, GetX1() + BarLen/*-OffsetX*/, GetY2() - OffsetY ); }
void CGraphPanel::AddPoint(SGraphChange* sgc) { //get main view pointer if (sgc->main_wnd_ptr == NULL) return; SSinglePoint ssp; CGraphProps* sgp = sgc->main_wnd_ptr->GetGraph(sgc->graphnum); if (!sgp->IsVisible()) { //if graph is not visible - do not do anything here return; }; sgp->GetPoint(sgc->index, &ssp); BOOL bNeedRedraw = FALSE; if ((unsigned long)(m_grflags & GRAPH_AUTOSCALE)) { //if grafix is autoscaled - just recalc coordinates and redraw the window if (ssp.x<__min(GetX1(), GetX2())) { SetMinX(ssp.x, FALSE); bNeedRedraw = TRUE; }; if (ssp.x>__max(GetX1(), GetX2())) { SetMaxX(ssp.x, FALSE); bNeedRedraw = TRUE; }; if (ssp.y<__min(GetY1(), GetY2())) { SetMinY(ssp.y, FALSE); bNeedRedraw = TRUE; }; if (ssp.y>__max(GetY1(), GetY2())) { SetMaxY(ssp.y, FALSE); bNeedRedraw = TRUE; }; }; //draw new point if (bNeedRedraw) { if (sgc->bRedraw) { UpdateGraphWindow(NULL); }; return; }; if (!sgc->bRedraw || offscreen == NULL) return; //if point is inside the graph - we need invalidate the whole picture if (sgc->index!=0 && sgc->index!=sgp->GetSize()-1) { if (sgc->bRedraw) { UpdateGraphWindow(NULL); }; return; }; int x, y, x1, y1; x = (int)CurrentCoordsX->WtoX(ssp.x); y = (int)CurrentCoordsY->WtoX(ssp.y); CDC* dc = offscreen->GetDibCDC(); if (dc != NULL) { CDC* cdc = GetDC(); CPen* pen = sgp->GetPen(); CBrush* brush = sgp->GetBrush(); CPen* oldpen = (CPen*)dc->SelectObject(pen); CBrush* oldbrush = (CBrush*)dc->SelectObject(brush); if (sgp->GetSize()>1) { if (sgc->index == 0) sgp->GetPoint(1, &ssp); if (sgc->index == sgp->GetSize()-1) sgp->GetPoint(sgc->index-1, &ssp); x1 = (int)CurrentCoordsX->WtoX(ssp.x); y1 = (int)CurrentCoordsY->WtoX(ssp.y); if (x != x1 || y != y1) { if ((m_grflags & GRAPH_GRAPH_SCATTER) == 0) { dc->MoveTo(x, y); dc->LineTo(x1, y1); }; if ((m_grflags & GRAPH_SQUAREPOINTS) != 0) { DrawSquarePoint(dc, x, y); }; CRect update_rect(x, y, x1, y1); update_rect.NormalizeRect(); update_rect.InflateRect(GetSquareSide(dc) + 2, GetSquareSide(dc) + 2); DoRedraw(cdc, update_rect); }; } else { if ((m_grflags & GRAPH_SQUAREPOINTS) != 0) { DrawSquarePoint(dc, x, y); CRect update_rect(x, y, x, y); update_rect.NormalizeRect(); update_rect.InflateRect(GetSquareSide(dc) + 2, GetSquareSide(dc) + 2); DoRedraw(cdc, update_rect); }; }; dc->SelectObject(oldpen); dc->SelectObject(oldbrush); sgp->ReleasePen(pen); sgp->ReleaseBrush(brush); ReleaseDC(cdc); }; }