Home

Download

Features

Screenshots

Handbook

Browse Source

Authors

SourceForge.net Logo
Hosted by SourceForge.net

OSI Certified


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Search  

distancefunction.cpp

00001 /***************************************************************************
00002                           distancefunction.cpp  -  description
00003                              -------------------
00004     begin                : Mon Nov 11 2002
00005     copyright            : (C) 2002 by Fungmeista
00006     email                : mizunoami44@users.sourceforge.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "distancefunction.h"
00019 
00020 #include <cmath>
00021 
00022 #include <qpainter.h>
00023 #include <qobject.h>
00024 
00025 DistanceFunction::DistanceFunction(BasicGraph *graph, int expressions) : MathFunction(graph,expressions)
00026 {
00027 }
00028 DistanceFunction::~DistanceFunction()
00029 {
00030 
00031 }
00032 
00033 void DistanceFunction::calculate_and_draw(QPainter *painter)
00034 {
00035     double distance = sqrt( (arg1x-arg2x)*
00036                 (arg1x-arg2x)+
00037                 (arg1y-arg2y)*
00038                 (arg1y-arg2y)
00039                   );
00040                   
00041     QString s = QString(QObject::tr("Distance = %1")).arg(distance);
00042     setResult(s);
00043 
00044     draw_stored(painter);
00045 }
00046 
00047 void DistanceFunction::draw_stored(QPainter *painter)
00048 {
00049     painter->drawLine(lowerBounds.x(),lowerBounds.y(),upperBounds.x(),upperBounds.y());
00050 }