Ejemplo n.º 1
0
void graphics::InterpolationPlot::replot(){
    QVector<double> xIn,yIn;
    points.getPointsAsSeperateVectors(xIn,yIn);
    setKeyPoints(xIn,yIn);
    int i=1;
    if(points.size() > 2){
        int n =1000;
        custom_types::PointsVector PointsOut;
        QVector<double> xOut, yOut;
        double xMin,xMax,yMin,yMax;
        getRange(xMin,xMax,yMin,yMax);
        QList<QString>::iterator it = activeITypes.begin();
        for(;it != activeITypes.end(); ++it){
            PointsOut.clear();
            IType * tmpIType = iTypes[*it];
            tmpIType->algorithm->calculateInterpolation(points,PointsOut,xMin,xMax,n);
            PointsOut.getPointsAsSeperateVectors(xOut,yOut);
            setPoints(xOut,yOut,i,tmpIType->color);
            ++i;
        }
    }
    int oldActiveITypesCount = activeITypesCount;
    activeITypesCount = i-1;
    xIn.clear();
    yIn.clear();
    for(; i <= oldActiveITypesCount; ++i) setPoints(xIn,yIn,i);
    graphics::QStcePlot::replot();
}
Ejemplo n.º 2
0
void FlowContainer::setFullBounds( bool full )
{
	if ( full || !b_expanded )
	{
		QRect bounds = b_expanded ? m_sizeRect : QRect( m_sizeRect.x(), m_sizeRect.y(), m_sizeRect.width(), topStrip );
		setPoints( QPolygon(bounds) );
		return;
	}
	
// 	kDebug() << k_funcinfo << "width="<<width()<<" height="<<height()<<endl;
	
	QPolygon pa(10);
	pa[0] = QPoint( 0, 0 );
	pa[1] = QPoint( width(), 0 );
	pa[2] = QPoint( width(), height() );
	pa[3] = QPoint( 0, height() );
	pa[4] = QPoint( 0, 0 );
	pa[5] = QPoint( 8, topStrip );
	pa[6] = QPoint( 8, height()-botStrip );
	pa[7] = QPoint( width()-8, height()-botStrip );
	pa[8] = QPoint( width()-8, topStrip );
	pa[9] = QPoint( 8, topStrip );
	pa.translate( offsetX(), offsetY() );
	setPoints(pa);
}
Ejemplo n.º 3
0
void Game::onTaskAnswered()
{
    bool oldFinished = isFinished();
    m_tasksAnswered++;
    if(m_currentTask->isCorrect())
        m_tasksAnsweredCorrectly++;
    emit tasksAnsweredChanged(m_tasksAnswered);


    // Adding points
    if (getMode()==Mode::DRAG) {
        setPoints(getPoints() + m_currentTask->getScore());
    }
    else {
        if(m_currentTask->isCorrect()){
            int receivedPoints = 50 * getMultiplier();
            setPoints(getPoints() + receivedPoints);
            setMultiplier(getMultiplier()+1);
        } else {
            setMultiplier(1);
        }
    }

    bool newFinished = isFinished();
    if(oldFinished != newFinished)emit finishedChanged(newFinished);
}
Ejemplo n.º 4
0
//-------------------------------------------------------------
void ConeGeometry::init(DolfinGui *ui)
{
    setPointCount(6);
    setRadiusCount(2);
    setCreated(false);
    setGuiWindow(ui);
    setPoints(new double[getPointCount()]);
    setPoints(new double[getRadiusCount()]);
    setMyType("Cone");
}
Ejemplo n.º 5
0
Triangle::Triangle(const QPoint& p1, const QPoint& p2, const QPoint& p3) {
    QList<QPoint> list;
    list.append(p1);
    list.append(p2);
    list.append(p3);
    setPoints(&list);
}
Ejemplo n.º 6
0
    SwaptionVolCube1::Cube::Cube(
                                    const std::vector<Date>& optionDates,
                                    const std::vector<Period>& swapTenors,
                                    const std::vector<Time>& optionTimes,
                                    const std::vector<Time>& swapLengths,
                                    Size nLayers,
                                    bool extrapolation)
    : optionTimes_(optionTimes), swapLengths_(swapLengths),
      optionDates_(optionDates), swapTenors_(swapTenors),
      nLayers_(nLayers), extrapolation_(extrapolation) {

        QL_REQUIRE(optionTimes.size()>1,"Cube::Cube(...): optionTimes.size()<2");
        QL_REQUIRE(swapLengths.size()>1,"Cube::Cube(...): swapLengths.size()<2");

        QL_REQUIRE(optionTimes.size()==optionDates.size(),
                   "Cube::Cube(...): optionTimes/optionDates mismatch");
        QL_REQUIRE(swapTenors.size()==swapLengths.size(),
                   "Cube::Cube(...): swapTenors/swapLengths mismatch");

        std::vector<Matrix> points(nLayers_, Matrix(optionTimes_.size(),
                                                    swapLengths_.size(), 0.0));

        for (Size k=0;k<nLayers_;k++) {
            transposedPoints_.push_back(transpose(points[k]));

            boost::shared_ptr<Interpolation2D> interpolation (new
                BilinearInterpolation (optionTimes_.begin(), optionTimes_.end(),
                                       swapLengths_.begin(), swapLengths_.end(),
                                       transposedPoints_[k]));
            interpolators_.push_back(boost::shared_ptr<Interpolation2D>(
                new FlatExtrapolator2D(interpolation)));
            interpolators_[k]->enableExtrapolation();
        }
        setPoints(points);
     }
Ejemplo n.º 7
0
    void SwaptionVolCube1::Cube::expandLayers(
                                                 Size i, bool expandOptionTimes,
                                                 Size j, bool expandSwapLengths) {
        QL_REQUIRE(i<=optionTimes_.size(),"Cube::expandLayers: incompatible size 1");
        QL_REQUIRE(j<=swapLengths_.size(),"Cube::expandLayers: incompatible size 2");

        if (expandOptionTimes) {
            optionTimes_.insert(optionTimes_.begin()+i,0.);
            optionDates_.insert(optionDates_.begin()+i, Date());
        }
        if (expandSwapLengths) {
            swapLengths_.insert(swapLengths_.begin()+j,0.);
            swapTenors_.insert(swapTenors_.begin()+j, Period());
        }

        std::vector<Matrix> newPoints(nLayers_,Matrix(optionTimes_.size(),
                                                      swapLengths_.size(), 0.));

        for (Size k=0; k<nLayers_; ++k) {
            for (Size u=0; u<points_[k].rows(); ++u) {
                 Size indexOfRow = u;
                 if (u>=i && expandOptionTimes) indexOfRow = u+1;
                 for (Size v=0; v<points_[k].columns(); ++v) {
                      Size indexOfCol = v;
                      if (v>=j && expandSwapLengths) indexOfCol = v+1;
                      newPoints[k][indexOfRow][indexOfCol]=points_[k][u][v];
                 }
            }
        }
        setPoints(newPoints);
    }
Ejemplo n.º 8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    iScore1(0), iScore2(0)
{
    ui->setupUi(this);

    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setSceneRect(0, 0, ui->boardView->size().width()-30, ui->boardView->size().height()-30);

    QGraphicsRectItem *p1 = new QGraphicsRectItem(0, 0, 20, 80);
    p1->setBrush(QBrush(Qt::blue));
    QGraphicsRectItem *p2 = new QGraphicsRectItem(0, 0, 20, 80);
    p2->setBrush(QBrush(Qt::green));

    QGraphicsEllipseItem *ball = new QGraphicsEllipseItem(0, 0, 15, 15);
    ball->setBrush(QBrush(Qt::magenta));

    ui->boardView->setScene(scene);

    iLoop = new Gameplay(*scene, p1, p2, ball, this);
    QSize m(scene->sceneRect().size().width() + 10, scene->sceneRect().size().height() + 10);
    ui->boardView->setMinimumSize(m);
    ui->boardView->installEventFilter(iLoop);

    QObject::connect(iLoop, SIGNAL(goal(int)),
                     this, SLOT(addScore(int)));


    panel =  new ControlPanel(this);
    connect(panel, SIGNAL(pointsReady(std::vector<glm::vec2>)), iLoop, SLOT(setPoints(std::vector<glm::vec2>)));

    panel->show();
}
Ejemplo n.º 9
0
void BoxGeom::setSize(double width, double height, double depth) {

	if(width >= 0.0) {
		mWidth = width;
	}
	if(height >= 0.0) {
		mHeight = height;
	}
	if(depth >= 0.0) {
		mDepth = depth;
	}
		
	width = width / 2.0;
	height = height / 2.0;
	depth = depth / 2.0;

	QVector<Vector3D> points;

	points.append(Vector3D(-width, -height,  depth));
	points.append(Vector3D(-width,  height,  depth));
	points.append(Vector3D( width,  height,  depth));
	points.append(Vector3D( width, -height,  depth));
	points.append(Vector3D(-width,  height, -depth));
	points.append(Vector3D(-width, -height, -depth));
	points.append(Vector3D( width, -height, -depth));
	points.append(Vector3D( width,  height, -depth));
	
	setPoints(points);
}
Ejemplo n.º 10
0
 LineString::LineString(QList<Point*> const points, QString name, QPen* pen)
         :Curve(name)
 {
     mypen = pen;
     LineString();
     setPoints(points);
 }
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// KviCanvasLine
	//
	KviCanvasLine::KviCanvasLine(QCanvas * c,int x1,int y1,int x2,int y2)
	: QCanvasLine(c)
	{
		setPoints(x1,y1,x2,y2);
		m_properties.insert("uLineWidth",QVariant((unsigned int)0));
		m_properties.insert("clrForeground",QVariant(QColor()));
	}
Ejemplo n.º 12
0
Format::Format (QTextCharFormat tcf, QObject* parent):QObject (parent)
{
	setBackground( tcf.background().color() );
	setForeground( tcf.foreground().color() );
	setBold( tcf.fontWeight() >= QFont::Bold );
	setItalic( tcf.fontItalic() );
	setPoints ( tcf.fontPointSize() );
}
Ejemplo n.º 13
0
Polygon& Polygon::operator=(const Polygon& val)
{

	//vertices and color
	setPoints(val.m_points, val.m_colors);

	return *this;
}
Ejemplo n.º 14
0
//=====================================================
void GlRegularPolygon::computePolygon() {
  boundingBox = BoundingBox();
  boundingBox.expand(position+size/2.f);
  boundingBox.expand(position-size/2.f);

  setPoints(computeRegularPolygon(numberOfSides, position, size, startAngle));

  clearGenerated();
}
Ejemplo n.º 15
0
Shell::Shell()
{
	setKillsBottom(true);
	setKillsSide(true);
	setKillsTop(false);
	setPoints(0);
	setXVelocity(2.0);
	setYVelocity(0.0);
}
Ejemplo n.º 16
0
void Node::initPoints() {
	// Bounding rectangle, facing right
	QPointArray pa(QRect(0, -8, m_length, 16));

	QWMatrix m;
	m.rotate(m_dir);
	pa = m.map(pa);
	setPoints(pa);
}
Ejemplo n.º 17
0
Star::Star()
{
	setKillsBottom(false);
	setKillsSide(false);
	setKillsTop(false);
	setPoints(0);
	setXVelocity(2.0);
	setYVelocity(0.0);
}
Ejemplo n.º 18
0
Mushroom::Mushroom()
{
	setKillsBottom(false);
	setKillsSide(false);
	setKillsTop(false);
	setPoints(0);
	setXVelocity(2.0);
	setYVelocity(0.0);
}
Ejemplo n.º 19
0
EnemyFireball::EnemyFireball()
{
	setKillsBottom(true);
	setKillsSide(true);
	setKillsTop(true);
	setPoints(0);
	setXVelocity(0.0);
	setYVelocity(0.0);
}
Ejemplo n.º 20
0
// Adds a card which is one in a move to this player.
void Player::addWonCard(int card)
{
    // Store card
    mWonCards.append(card);

    // Add points
    int value = mDeck->getCardValue(card);
    setPoints(points() + value);
}
Ejemplo n.º 21
0
// Set and publish landmarks.
void Publisher::publishLandmarksAsCallback(
    const okvis::Time & /*t*/, const okvis::MapPointVector & actualLandmarks,
    const okvis::MapPointVector & transferredLandmarks)
{
  if(parameters_.publishing.publishLandmarks){
    okvis::MapPointVector empty;
    setPoints(actualLandmarks, empty, transferredLandmarks);
    publishPoints();
  }
}
Ejemplo n.º 22
0
	LineString::LineString(QList<Point*> const points, QString name, QPen* pen)
	:Curve(name)
	{
		mypen = pen;
		LineString();
		setPoints(points);
	
	//TODO: bremst stark
// 	pen.setStyle(Qt::DashDotDotLine);
	}
Ejemplo n.º 23
0
 std::shared_ptr<LineRenderer> Scene::createLine(GameObject *gameObject, const vector<glm::vec3> &points, kick::MeshType meshType, const std::vector<GLushort> &indices) {
     if (!gameObject) {
         gameObject = createGameObject("Plane");
     }
     auto lineRenderer = gameObject->addComponent<LineRenderer>();
     if (points.size()){
         lineRenderer->setPoints(points, meshType, indices);
     }
     return lineRenderer;
 }
Ejemplo n.º 24
0
BasisTriangle::BasisTriangle(FigureEditor* xfedit, QTransform& t)
: coordinateTransform(t), canvas(xfedit)
{
	QPolygonF p;
	p << QPointF(0.0,0.0) << QPointF(1.0,0.0) << QPointF(0.0,1.0);
	setPoints(p);
	setZValue(0);
	setPen( QPen(Qt::gray) );
	setTransform(t);
}
Ejemplo n.º 25
0
Plant::Plant()
{
	setKillsBottom(true);
	setKillsSide(true);
	setKillsTop(true);
	setPoints(0);
	setXVelocity(0.0);
	setYVelocity(1.0);
    count_ = 720;
    sprite();
}
Ejemplo n.º 26
0
EdgeItem::EdgeItem( NodeItem *from, NodeItem *to, QCanvas *canvas ) // 初始化建構子
    : QCanvasLine( canvas )
{
    c++; // 增加一個count,表示多了一個邊
    setPen( *tp );
    setBrush( *tb );
    from->addOutEdge( this );
    to->addInEdge( this );
    setPoints( int(from->x()), int(from->y()), int(to->x()), int(to->y()) );
    setZ( 127 );
}
Ejemplo n.º 27
0
Turtle::Turtle()
{
	setKillsBottom(true);
	setKillsSide(true);
	setKillsTop(false);
	setPoints(0);
	setXVelocity(-0.5);
	setYVelocity(0.0);
    
    sprite();
    
    }
Ejemplo n.º 28
0
void PinNode::initPoints()
{
	int l = - m_length;

	// Bounding rectangle, facing right
	Q3PointArray pa( QRect( 0, -8, l, 16 ) );

	QWMatrix m;
	m.rotate( m_dir );
	pa = m.map(pa);
	setPoints(pa);
}
Ejemplo n.º 29
0
TrackCameraLookatCurve::TrackCameraLookatCurve(){

	const int numLookat = 13;
	glm::vec3 arrpoints[numLookat] = {
			glm::vec3(32,	-5,		0),
			glm::vec3(0,	-0,		100),
			glm::vec3(0,	-0,		3),
			glm::vec3(12,	-12,		4),
			glm::vec3(0,	15,		12),
			glm::vec3(0,	10,		0),
			glm::vec3(51,	-10,	0),
			glm::vec3(0,	-0,		13),
			glm::vec3(2,	-5,		0),
			glm::vec3(15,	-3,		1),
			glm::vec3(23,	-0,		3),
			glm::vec3(0,	12,		4),
			glm::vec3(0,	-15,		12),


	};
	const int numpoints = 17;
	glm::vec3 arrpoints2[numpoints] = {
			glm::vec3(64,	12,		4),
			glm::vec3(2,	20,		13),
			glm::vec3(-32,	15,		75),
			glm::vec3(0,	75,		0),
			glm::vec3(0,	66,		3),
			glm::vec3(-21,	15,		-12),
			glm::vec3(-31,	16,		0),
			glm::vec3(15,	20,		0),
			glm::vec3(-1,	15,		23),
			glm::vec3(-15,	100,	23),
			glm::vec3(23,	55,		64),
			glm::vec3(64,	12,		0),
			glm::vec3(0,	15,		-64),
			glm::vec3(-64,	10,		0),
			glm::vec3(0,	-30,	64),
			glm::vec3(64,	42,		0),
			glm::vec3(0,	20,		-64),

	};	
	std::vector<glm::vec3> lookatpoints		= std::vector<glm::vec3>(0);
	std::vector<glm::vec3> positionpoints	= std::vector<glm::vec3>(0);

	for(int i = 0; i < numLookat; i++){
		lookatpoints.push_back(arrpoints[i]);
	}
	for(int i = 0; i < numpoints; i++){
		positionpoints.push_back(arrpoints2[i]);
	}
	lookatCurve = new BSplineCurve(lookatpoints);
	setPoints(positionpoints);
}
Ejemplo n.º 30
0
Tetromino::Tetromino(vec4 points[T_POINTS], vec4 color, vec4 pivotPoint) {
    int i;
    //Set points

    setPoints(points);

    //Set color and pivot point
    for (i = 0; i < 4; i++) {
        this->color[i] = color[i];
        this->pivotPoint[i] = pivotPoint[i];
    }
}