Ejemplo n.º 1
0
bool Graph::SelectPoint(QString const &CurveName, int sel)
{
	QString str;
	CCurve *pCurve = NULL;
	
	if(sel<0) 
	{
//		pCurve->SetSelected(-1);
		return false;				
	}		
	
	for(int i=0; i<m_oaCurves.size(); i++)
	{
		pCurve = (CCurve*)m_oaCurves.at(i);
		pCurve->GetTitle(str);
		if(str == CurveName)
		{
			if(sel>pCurve->GetCount())
			{
				pCurve->SetSelected(-1);
				return false;				
			}
			else
			{
				pCurve->SetSelected(sel);
				return true;
			}
		}
	}
//	pCurve->SetSelected(-1);
	return false;
}
Ejemplo n.º 2
0
CCurve* Graph::GetCurvePoint(const int &xClt, const int &yClt,int &nSel)
{
	static int i, n, xc, yc;
	static double dist, x1, y1, x,y;
	CCurve *pOldCurve;

	x= ClientTox(xClt);
	y= ClientToy(yClt);
	for(i=0; i<m_oaCurves.size(); i++)
	{
		pOldCurve = (CCurve*)m_oaCurves.at(i);
		pOldCurve->GetClosestPoint(x, y, x1, y1, dist, n);

		xc = xToClient(x1);
		yc = yToClient(y1);

		if((xClt-xc)*(xClt-xc) + (yClt-yc)*(yClt-yc) <16)//sqrt(16) pixels distance
		{
			nSel = n;
			return pOldCurve;
		}
	}
	nSel = -1;
	return  NULL;
}
Ejemplo n.º 3
0
void Graph::DeselectPoint()
{
	CCurve *pCurve;
	for(int i=0; i<m_oaCurves.size(); i++)
	{
		pCurve = (CCurve*)m_oaCurves.at(i);
		pCurve->SetSelected(-1);
	}
}
Ejemplo n.º 4
0
void Graph::ResetCurves()
{
	CCurve *pCurve;
	for(int i=0; i<m_oaCurves.size(); i++)
	{
		pCurve = (CCurve*)m_oaCurves.at(i);
		pCurve->ResetCurve();
	}
}
Ejemplo n.º 5
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CFuncRandom
//  - Prototype : float Evaluate(float fTime)
//
//  - Purpose   : Returns a float value as a result of evaluating the function
//                given a time value.
//
// -----------------------------------------------------------------------------
float CFuncRandom::Evaluate(float fTime)
{
	ComputeLoop(0.0f, LOOPLENGTH - (1.0f / m_fFrequency), &fTime);
	CVector3 v3Val;

	CCurve* pCurve;
	
	if(m_bSmooth) pCurve = &m_crvFunctionSmooth; else pCurve = &m_crvFunctionLinear;
	pCurve->Evaluate(fTime, &v3Val);

	return v3Val.X();
}
Ejemplo n.º 6
0
static CCurve MakeCCurve(const geoff_geometry::Kurve& k)
{
	CCurve c;
	int n = k.nSpans();
	for(int i = 0; i<= n; i++)
	{
		geoff_geometry::spVertex spv;
		k.Get(i, spv);
		c.append(CVertex(spv.type, Point(spv.p.x, spv.p.y), Point(spv.pc.x, spv.pc.y)));
	}
	return c;
}
Ejemplo n.º 7
0
CCurve* Graph::AddCurve()
{
	CCurve *pCurve = new CCurve();
	if(pCurve)
	{
        int nIndex = m_oaCurves.size();
		pCurve->SetColor(m_CurveColors[nIndex%10]);
        pCurve->SetStyle(0);
		pCurve->m_pParentGraph = this;
        m_oaCurves.append(pCurve);
	}
	return pCurve;
}
Ejemplo n.º 8
0
CCurve* Graph::GetCurve(QString CurveTitle)
{
	QString strong;
	CCurve * pCurve;
	for(int i=0; i<m_oaCurves.size(); i++)
	{
		pCurve = (CCurve*)m_oaCurves.at(i);
		if(pCurve)
		{
			pCurve->GetTitle(strong);
			if(strong==CurveTitle) return pCurve;
		}
	}
	return NULL;
}
Ejemplo n.º 9
0
static boost::python::tuple nearest_point_to_curve(CCurve& c1, const CCurve& c2)
{
	double dist;
	Point p = c1.NearestPoint(c2, &dist);

	return bp::make_tuple(p, dist);
}
Ejemplo n.º 10
0
void QGraph::ExportToFile(QFile &XFile, int FileType)
{
	int i,j, maxpoints;
	CCurve *pCurve;
	QString strong;
	QTextStream out(&XFile);

	maxpoints = 0;
	for(i=0; i<m_oaCurves.size(); i++)
	{
		pCurve = GetCurve(i);
		if(pCurve) 
		{
			maxpoints = qMax(maxpoints,pCurve->n); 

			pCurve->GetTitle(strong);
			if(FileType==1)	out << "     "<<m_XTitle<<"       "<< strong <<"    ";
			else            out << m_XTitle<<","<< strong << ", , ";

		}
	}
	out<<"\n"; //end of title line

	for(j=0; j<maxpoints; j++)
	{
		for(i=0; i<m_oaCurves.size(); i++)
		{
			pCurve = GetCurve(i);
			if(pCurve && j<pCurve->n)
			{
				if(FileType==1)	strong= QString("%1     %2  ")
												.arg(pCurve->x[j],13,'g',7).arg(pCurve->y[j],13,'g',7);
				else            strong= QString("%1, %2, , ")
												.arg(pCurve->x[j],13,'g',7).arg(pCurve->y[j],13,'g',7);
			}
			else
			{
				if(FileType==1)	strong= "                                 ";
				else            strong= ", , , ";
			}
			out << strong;
		}
		out<<"\n"; //end of data line
	}
	out<<"\n"; //end of file
	XFile.close();
}
Ejemplo n.º 11
0
void CArea::InsideCurves(const CCurve& curve, std::list<CCurve> &curves_inside)const
{
	//1. find the intersectionpoints between these two curves.
	std::list<Point> pts;
	CurveIntersections(curve, pts);

	//2.seperate curve2 in multiple curves between these intersections.
	std::list<CCurve> separate_curves;
	curve.ExtractSeparateCurves(pts, separate_curves);

	//3. if the midpoint of a seperate curve lies in a1, then we return it.
	for(std::list<CCurve>::iterator It = separate_curves.begin(); It != separate_curves.end(); It++)
	{
		CCurve &curve = *It;
		double length = curve.Perim();
		Point mid_point = curve.PerimToPoint(length * 0.5);
		if(IsInside(mid_point, *this))curves_inside.push_back(curve);
	}
}
Ejemplo n.º 12
0
static CArea make_obround(const Point& p0, const Point& p1, double radius)
{
    Point dir = p1 - p0;
    double d = dir.length();
    dir.normalize();
    Point right(dir.y, -dir.x);
    CArea obround;
    CCurve c;
    if(fabs(radius) < 0.0000001)radius = (radius > 0.0) ? 0.002 : (-0.002);
    Point vt0 = p0 + right * radius;
    Point vt1 = p1 + right * radius;
    Point vt2 = p1 - right * radius;
    Point vt3 = p0 - right * radius;
    c.append(vt0);
    c.append(vt1);
    c.append(CVertex(1, vt2, p1));
    c.append(vt3);
    c.append(CVertex(1, vt0, p0));
    obround.append(c);
    return obround;
}
Ejemplo n.º 13
0
static void SetFromResult( CCurve& curve, const TPolygon& p, bool reverse = true )
{
	for(unsigned int j = 0; j < p.size(); j++)
	{
		const IntPoint &pt = p[j];
		DoubleAreaPoint dp(pt);
		CVertex vertex(0, Point(dp.X / CArea::m_units, dp.Y / CArea::m_units), Point(0.0, 0.0));
		if(reverse)curve.m_vertices.push_front(vertex);
		else curve.m_vertices.push_back(vertex);
	}
	// make a copy of the first point at the end
	if(reverse)curve.m_vertices.push_front(curve.m_vertices.back());
	else curve.m_vertices.push_back(curve.m_vertices.front());

	if(CArea::m_fit_arcs)curve.FitArcs();
}
Ejemplo n.º 14
0
void QGraph::DrawLegend(QPainter &painter, QPoint &Place, QFont &LegendFont, QColor &LegendColor)
{
	painter.save();
	int LegendSize, ypos;
	QString strong;

	LegendSize = 30;
	ypos = 12;

	painter.setFont(LegendFont);

	CCurve* pCurve;

	QPen TextPen(LegendColor);
	QPen LegendPen(Qt::gray);

	int npos = 0;
	for (int nc=0; nc< m_oaCurves.size(); nc++)
	{
		pCurve = (CCurve*) m_oaCurves[nc];
		if(pCurve->IsVisible())
		{
			pCurve->GetTitle(strong);
			if(pCurve->n>0 && strong.length())//is there anything to draw ?
			{

				LegendPen.setColor(pCurve->GetColor());
				LegendPen.setStyle(GetStyle(pCurve->GetStyle()));
				LegendPen.setWidth(pCurve->GetWidth());

				painter.setPen(LegendPen);

				painter.drawLine(Place.x(),                     Place.y() + ypos*npos,
								 Place.x() + (int)(LegendSize), Place.y() + ypos*npos);

				painter.setPen(TextPen);
				painter.drawText(Place.x() + (int)(1.5*LegendSize),    Place.y()  + ypos*npos+(int)(ypos/2),
								 strong);

				npos++;
			}
		}
	}

	painter.restore();

}
Ejemplo n.º 15
0
void CArea::CurveIntersections(const CCurve& curve, std::list<Point> &pts)const
{
	// this returns all the intersections of this area with the given curve, ordered along the curve
	std::list<Span> spans;
	curve.GetSpans(spans);
	for(std::list<Span>::iterator It = spans.begin(); It != spans.end(); It++)
	{
		Span& span = *It;
		std::list<Point> pts2;
		SpanIntersections(span, pts2);
		for(std::list<Point>::iterator It = pts2.begin(); It != pts2.end(); It++)
		{
			Point &pt = *It;
			if(pts.size() == 0)
			{
				pts.push_back(pt);
			}
			else
			{
				if(pt != pts.back())pts.push_back(pt);
			}
		}
	}
}
Ejemplo n.º 16
0
void QGraph::DrawCurve(int nIndex, QPainter &painter)
{
	painter.save();
	static double scaley;
	static int i, ptside;
	static QPoint From, To, Min, Max;
	static QRect rViewRect;

	ptside = 2;
	CCurve* pCurve = GetCurve(nIndex);

	scaley = m_scaley;

	QBrush FillBrush(m_BkColor);
	painter.setBrush(FillBrush);

	QPen CurvePen(pCurve->GetColor());
	CurvePen.setStyle(GetStyle(pCurve->GetStyle()));
	CurvePen.setWidth((int)pCurve->GetWidth());
	painter.setPen(CurvePen);

	Min.setX(int(xmin/m_scalex) +m_ptoffset.x());
	Min.setY(int(ymin/scaley) +m_ptoffset.y());
	Max.setX(int(xmax/m_scalex) +m_ptoffset.x());
	Max.setY(int(ymax/scaley) +m_ptoffset.y());
	rViewRect.setTopLeft(Min);
	rViewRect.setBottomRight(Max);

	if(pCurve->n>=1)
	{
		From.setX(int(pCurve->x[0]/m_scalex+m_ptoffset.x()));
		From.setY(int(pCurve->y[0]/scaley  +m_ptoffset.y()));

		if(pCurve->IsVisible())
		{
			for (i=1; i<pCurve->n;i++)
			{
				To.setX(int(pCurve->x[i]/m_scalex+m_ptoffset.x()));
				To.setY(int(pCurve->y[i]/scaley  +m_ptoffset.y()));
				painter.drawLine(From, To);
	
				From = To;
			}
		}

		if(pCurve->PointsVisible())
		{
			for (i=0; i<pCurve->n;i++)
			{
				if(pCurve->GetSelected() !=i)
					painter.drawRect(int(pCurve->x[i]/m_scalex+m_ptoffset.x())-ptside,
									 int(pCurve->y[i]/  scaley+m_ptoffset.y())-ptside,
									 2*ptside,2*ptside);
			}
		}
	}

	if(m_bHighlightPoint)
	{
		int point = pCurve->GetSelected();
		if(point>=0)
		{
			//highlight
			QColor HighColor(0,40, 150);
			CurvePen.setWidth((int)pCurve->GetWidth());
			CurvePen.setColor(HighColor);
			painter.setPen(CurvePen);
			To.setX(int(pCurve->x[point]/m_scalex+m_ptoffset.x()));
			To.setY(int(pCurve->y[point]/scaley  +m_ptoffset.y()));
			painter.drawRect(To.x()-ptside-1,To.y()-ptside-1, 2*(ptside+1),2*(ptside+1));
		}
	}
	painter.restore();
}
Ejemplo n.º 17
0
bool Graph::SetXScale()
{
	CCurve *pCurve;
	int nc;

	if(m_bAutoX)
	{
		bool bCurve = false;

		if (m_oaCurves.size())
		{
			//init only if we have a curve
			for (nc=0; nc < m_oaCurves.size(); nc++)
			{
				pCurve = (CCurve*)m_oaCurves[nc];
				if ((pCurve->IsVisible() ||pCurve->PointsVisible()) && pCurve->n>1)
				{
					bCurve = true;
					break;//there is something to draw
				}
			}
		}
		if (bCurve)
		{
			Cxmin =  9999999.0;
			Cxmax = -9999999.0;
			for (nc=0; nc < m_oaCurves.size(); nc++)
			{
				pCurve = (CCurve*)m_oaCurves[nc];
				if ((pCurve->IsVisible() ||pCurve->PointsVisible())  && pCurve->n>0)
				{
					Cxmin = qMin(Cxmin, pCurve->GetxMin());
					Cxmax = qMax(Cxmax, pCurve->GetxMax());
				}
			}

			if(Cxmax<=Cxmin)
				Cxmax = (Cxmin+1.0)*2.0;

			if(m_Type == 1)
			{
				xmin = qMin(xmin, Cxmin);
				xmax = qMax(xmax, Cxmax);
			}
			else
			{
				xmin = Cxmin;
				xmax = Cxmax;
			}
			if(Cxmin>=0.0) xmin = 0.0;
			if(Cxmax<=0.0) xmax = 0.0;

		}
		else
		{
			// until things are made clear
			for (nc=0; nc < m_oaCurves.size(); nc++)
			{
				pCurve = (CCurve*)m_oaCurves[nc];
				if ((pCurve->IsVisible() ||pCurve->PointsVisible())  && pCurve->n>0)
				{
					xmin = qMin(xmin, pCurve->x[0]);
					xmax = qMax(xmax, pCurve->x[0]);
				}
			}
		}
		xo=0.0;

		if(fabs((xmin-xmax)/xmin)<0.001)
		{
			if(fabs(xmin)<0.00001) xmax = 1.0;
			else
			{
				xmax = 2.0 * xmin;
				if(xmax < xmin)
				{
					double tmp = xmax;
					xmax = xmin;
					xmin = tmp;
				}
			}
		}

		if(m_w<=0.0) return false;

		m_scalex   = (xmax-xmin)/m_w;


		//try to set an automatic scale for X Axis

		SetAutoXUnit();
	}
	else
	{
		//scales are set manually
		if(m_w<=0.0) return false;

//		m_scalex   =  (xmax-xmin)/m_w;
		if (xunit<1.0)
		{
			exp_x = (int)log10(xunit*1.00001)-1;
			exp_x = qMax(-4, exp_x);
		}
		else exp_x = (int)log10(xunit*1.00001);

	}
	m_scalex   =  (xmax-xmin)/m_w;

	//graph center position
	int Xg = (m_rCltRect.right() + m_rCltRect.left())/2;
	// curves center position
	int Xc = (int)((xmin+xmax)/2.0/m_scalex);
	// center graph in drawing rectangle
	m_ptoffset.rx() = (Xg-Xc);
	return true;
}
Ejemplo n.º 18
0
void CurveTree::MakeOffsets2()
{
    // make offsets

    if(CArea::m_please_abort)return;
    CArea smaller;
    smaller.m_curves.push_back(curve);
    smaller.Offset(pocket_params->stepover);

    if(CArea::m_please_abort)return;

    // test islands
    for(std::list<const IslandAndOffset*>::iterator It = offset_islands.begin(); It != offset_islands.end();)
    {
        const IslandAndOffset* island_and_offset = *It;

        if(GetOverlapType(island_and_offset->offset, smaller) == eInside)
            It++; // island is still inside
        else
        {
            inners.push_back(new CurveTree(*island_and_offset->island));
            islands_added.push_back(inners.back());
            inners.back()->point_on_parent = curve.NearestPoint(*island_and_offset->island);
            if(CArea::m_please_abort)return;
            Point island_point = island_and_offset->island->NearestPoint(inners.back()->point_on_parent);
            if(CArea::m_please_abort)return;
            inners.back()->curve.ChangeStart(island_point);
            if(CArea::m_please_abort)return;

            // add the island offset's inner curves
            for(std::list<CCurve>::const_iterator It2 = island_and_offset->island_inners.begin(); It2 != island_and_offset->island_inners.end(); It2++)
            {
                const CCurve& island_inner = *It2;
                inners.back()->inners.push_back(new CurveTree(island_inner));
                inners.back()->inners.back()->point_on_parent = inners.back()->curve.NearestPoint(island_inner);
                if(CArea::m_please_abort)return;
                Point island_point = island_inner.NearestPoint(inners.back()->inners.back()->point_on_parent);
                if(CArea::m_please_abort)return;
                inners.back()->inners.back()->curve.ChangeStart(island_point);
                to_do_list_for_MakeOffsets.push_back(inners.back()->inners.back()); // do it later, in a while loop
                if(CArea::m_please_abort)return;
            }

            smaller.Subtract(island_and_offset->offset);

            std::set<const IslandAndOffset*> added;

            std::list<IslandAndOffsetLink> touching_list;
            for(std::list<IslandAndOffset*>::const_iterator It2 = island_and_offset->touching_offsets.begin(); It2 != island_and_offset->touching_offsets.end(); It2++)
            {
                const IslandAndOffset* touching = *It2;
                touching_list.push_back(IslandAndOffsetLink(touching, inners.back()));
                added.insert(touching);
            }

            while(touching_list.size() > 0)
            {
                IslandAndOffsetLink touching = touching_list.front();
                touching_list.pop_front();
                touching.add_to->inners.push_back(new CurveTree(*touching.island_and_offset->island));
                islands_added.push_back(touching.add_to->inners.back());
                touching.add_to->inners.back()->point_on_parent = touching.add_to->curve.NearestPoint(*touching.island_and_offset->island);
                Point island_point = touching.island_and_offset->island->NearestPoint(touching.add_to->inners.back()->point_on_parent);
                touching.add_to->inners.back()->curve.ChangeStart(island_point);
                smaller.Subtract(touching.island_and_offset->offset);

                // add the island offset's inner curves
                for(std::list<CCurve>::const_iterator It2 = touching.island_and_offset->island_inners.begin(); It2 != touching.island_and_offset->island_inners.end(); It2++)
                {
                    const CCurve& island_inner = *It2;
                    touching.add_to->inners.back()->inners.push_back(new CurveTree(island_inner));
                    touching.add_to->inners.back()->inners.back()->point_on_parent = touching.add_to->inners.back()->curve.NearestPoint(island_inner);
                    if(CArea::m_please_abort)return;
                    Point island_point = island_inner.NearestPoint(touching.add_to->inners.back()->inners.back()->point_on_parent);
                    if(CArea::m_please_abort)return;
                    touching.add_to->inners.back()->inners.back()->curve.ChangeStart(island_point);
                    to_do_list_for_MakeOffsets.push_back(touching.add_to->inners.back()->inners.back()); // do it later, in a while loop
                    if(CArea::m_please_abort)return;
                }

                for(std::list<IslandAndOffset*>::const_iterator It2 = touching.island_and_offset->touching_offsets.begin(); It2 != touching.island_and_offset->touching_offsets.end(); It2++)
                {
                    if(added.find(*It2)==added.end() && ((*It2) != island_and_offset))
                    {
                        touching_list.push_back(IslandAndOffsetLink(*It2, touching.add_to->inners.back()));
                        added.insert(*It2);
                    }
                }
            }

            if(CArea::m_please_abort)return;
            It = offset_islands.erase(It);

            for(std::set<const IslandAndOffset*>::iterator It2 = added.begin(); It2 != added.end(); It2++)
            {
                const IslandAndOffset* i = *It2;
                offset_islands.remove(i);
            }

            if(offset_islands.size() == 0)break;
            It = offset_islands.begin();
        }
    }

    CArea::m_processing_done += CArea::m_MakeOffsets_increment;
    if(CArea::m_processing_done > CArea::m_after_MakeOffsets_length)CArea::m_processing_done = CArea::m_after_MakeOffsets_length;

    std::list<CArea> separate_areas;
    smaller.Split(separate_areas);
    if(CArea::m_please_abort)return;
    for(std::list<CArea>::iterator It = separate_areas.begin(); It != separate_areas.end(); It++)
    {
        CArea& separate_area = *It;
        CCurve& first_curve = separate_area.m_curves.front();

        CurveTree* nearest_curve_tree = NULL;
        Point near_point = GetNearestPoint(this, islands_added, first_curve, &nearest_curve_tree);

        nearest_curve_tree->inners.push_back(new CurveTree(first_curve));

        for(std::list<const IslandAndOffset*>::iterator It = offset_islands.begin(); It != offset_islands.end(); It++)
        {
            const IslandAndOffset* island_and_offset = *It;
            if(GetOverlapType(island_and_offset->offset, separate_area) == eInside)
                nearest_curve_tree->inners.back()->offset_islands.push_back(island_and_offset);
            if(CArea::m_please_abort)return;
        }

        nearest_curve_tree->inners.back()->point_on_parent = near_point;

        if(CArea::m_please_abort)return;
        Point first_curve_point = first_curve.NearestPoint(nearest_curve_tree->inners.back()->point_on_parent);
        if(CArea::m_please_abort)return;
        nearest_curve_tree->inners.back()->curve.ChangeStart(first_curve_point);
        if(CArea::m_please_abort)return;
        to_do_list_for_MakeOffsets.push_back(nearest_curve_tree->inners.back()); // do it later, in a while loop
        if(CArea::m_please_abort)return;
    }
}
Ejemplo n.º 19
0
bool Graph::SetYScale()
{
	int nc;
	CCurve *pCurve;

	if(m_bAutoY)
	{
		bool bCurve = false;
		if (m_oaCurves.size())
		{
			//init only if we have a curve
			for (nc=0; nc < m_oaCurves.size(); nc++)
			{
				pCurve = (CCurve*)m_oaCurves[nc];
				if ((pCurve->IsVisible() ||pCurve->PointsVisible())  && pCurve->n>0)
					{
						bCurve = true;
						break;
					}
			}
		}
		if(bCurve)
		{
			Cymin =  9999999.0;
			Cymax = -9999999.0;
			for (nc=0; nc < m_oaCurves.size(); nc++)
			{
				pCurve = (CCurve*)m_oaCurves[nc];
				if ((pCurve->IsVisible() ||pCurve->PointsVisible()) && pCurve->n>0)
				{
					Cymin = qMin(Cymin, pCurve->GetyMin());
					Cymax = qMax(Cymax, pCurve->GetyMax());
				}
			}
			if(Cymax<=Cymin)
			{
				Cymax = (Cymin+1.0)*2.0;
			}

			if(m_Type == 1)
			{
				ymin = qMin(ymin, Cymin);
				ymax = qMax(ymax, Cymax);
			}
			else
			{
				ymin = Cymin;
				ymax = Cymax;
			}
			if(Cymin>=0.0) ymin = 0.0;
			if(Cymax<=0.0) ymax = 0.0;
		}
		else
		{
			// until things are made clear
			for (int nc=0; nc < m_oaCurves.size(); nc++)
			{
				pCurve = (CCurve*)m_oaCurves[nc];
				if ((pCurve->IsVisible() ||pCurve->PointsVisible())  && pCurve->n>0)
				{
					ymin = qMin(ymin, pCurve->y[0]);
					ymax = qMax(ymax, pCurve->y[0]);
				}
			}
		}
		yo=0.0;

		if (fabs((ymin-ymax)/ymin)<0.001)
		{
			if(fabs(ymin)<0.00001) ymax = 1.0;
			else
			{
				ymax = 2.0 * ymin;
				if(ymax < ymin)
				{
					double tmp = ymax;
					ymax = ymin;
					ymin = tmp;
				}
			}
		}

		if(m_h<=0.0) return false;

		if (!m_bYInverted)
		{
			m_scaley   = -(ymax-ymin)/m_h;
		}
		else
		{
			m_scaley   =  (ymax-ymin)/m_h;
		}

		//try to set an automatic scale for Y Axis
		SetAutoYUnit();
	}
	else
	{
		//scales are set manually
		if(m_h<=0) return false;

		if (!m_bYInverted)
		{
			m_scaley   = -(ymax-ymin)/m_h;
		}
		else
		{
			m_scaley   =  (ymax-ymin)/m_h;
		}

		if (yunit<1.0)
		{
			exp_y = (int)log10(yunit*1.00001)-1;
			exp_y = qMax(-4, exp_y);
		}
		else  exp_y = (int)log10(yunit*1.00001);

	}

	//graph center position
	int Yg = (m_rCltRect.top() + m_rCltRect.bottom())/2;
	// curves center position
	int Yc = (int)((ymin+ymax)/2.0/m_scaley);
	// center graph in drawing rectangle
	m_ptoffset.ry() = (Yg-Yc);

	return true;
}