예제 #1
0
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 );
    }
}
예제 #2
0
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);
}
예제 #3
0
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 );
}
예제 #4
0
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);
}
예제 #5
0
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);
}
예제 #6
0
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);
}
예제 #7
0
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);
    };
}