void FormEditorScene::resetScene() { foreach (QGraphicsItem *item, m_manipulatorLayerItem->childItems()) removeItem(item); setSceneRect(-canvasWidth()/2., -canvasHeight()/2., canvasWidth(), canvasHeight()); }
FormEditorScene::FormEditorScene(FormEditorWidget *view, FormEditorView *editorView) : QGraphicsScene(), m_editorView(editorView), m_showBoundingRects(true) { setupScene(); view->setScene(this); setItemIndexMethod(QGraphicsScene::NoIndex); setSceneRect(-canvasWidth()/2., -canvasHeight()/2., canvasWidth(), canvasHeight()); }
void Frame::updateLayoutGeometry() { ILOG_TRACE_W(ILX_FRAME); ILOG_DEBUG( ILX_FRAME, " -> R(%d, %d, %d, %d)\n", canvasX(), canvasY(), canvasWidth(), canvasHeight()); _layout->setGeometry(canvasX(), canvasY(), canvasWidth(), canvasHeight()); }
void QPaintWidget::drawCircle(QPainter *ppainter) { if (circle.radius !=0) { ppainter->save(); double posXCenter = scalePointX(circle.pos.x()); double posYCenter = scalePointY(circle.pos.y()); int sizeX = static_cast<int>(circle.radius/((maxX - minX) / canvasWidth())); int sizeY = static_cast<int>(circle.radius/((maxY - minY) / canvasHeight())); int size = kmin(sizeX, sizeY); ppainter->setPen(QPen(Qt::darkGreen, kDrawPenWidth)); ppainter->setBrush(QBrush(Qt::transparent)); ppainter->drawEllipse( posXCenter-size, posYCenter-size, 2*size+1, 2*size+1 ); ppainter->restore(); } }
void QPaintWidget::drawFrame(QPainter *ppainter){ QVector<QPointF> linePoints; linePoints << QPointF(kPadding,kPadding) << QPointF(kPadding,canvasHeight()+kPadding) << QPointF(kPadding,canvasHeight()+kPadding) << QPointF(canvasWidth()+kPadding,canvasHeight()+kPadding) << QPointF(canvasWidth()+kPadding,canvasHeight()+kPadding) << QPointF(canvasWidth()+kPadding,kPadding) << QPointF(canvasWidth()+kPadding,kPadding) << QPointF(kPadding,kPadding); ppainter->save(); ppainter->setPen(QPen(Qt::lightGray,1,Qt::DashLine)); ppainter->drawLines( linePoints ); ppainter->restore(); }
void QPaintWidget::drawAxis(QPainter *ppainter) { double w = canvasWidth()+kPadding; double h = canvasHeight()+kPadding; double step = 92; ppainter->save(); ppainter->setPen(QPen(Qt::lightGray,1,Qt::DashLine)); for (double x = kPadding; x <= w; x += step) { ppainter->drawLine(QPointF(x,h), QPointF(x,kPadding)); } for (double y = kPadding; y <= h; y += step) { ppainter->drawLine(QPointF(kPadding,y), QPointF(w,y)); } ppainter->restore(); }
double QPaintWidget::scalePointY(double y){ return ((y - minY)/ (maxY - minY)) * canvasHeight() *(-1) + canvasHeight() + kPadding; }
/*! Return an indicator of the closeness of this stroke to \a pen. Lower value is better. */ unsigned int QIMPenStroke::match( QIMPenStroke *pen ) { double lratio; if ( links.count() > pen->links.count() ) lratio = (links.count()+2) / (pen->links.count()+2); else lratio = (pen->links.count()+2) / (links.count()+2); lratio -= 1.0; createSignatures(); pen->createSignatures(); int ch = canvasHeight(); int pch = pen->canvasHeight(); int vdiff, evdiff; if (!useVertPos) { // if they are different, need a differnt way of measureing int h = boundingRect().height(); int ph = pen->boundingRect().height(); int sh = h * 75 / ch; int sph = ph * 75 / pch; if (((sh << 1) < sph && sph > 4) || ((sph << 1) < ph && ph > 4)) { return 400000; } vdiff = 0; evdiff = 0; } else { int sp = startPoint.y(); int psp = pen->startPoint.y(); vdiff = qAbs(sp - psp); // Insanely offset? if ( vdiff > 18 ) { return 400000; } vdiff -= 4; if ( vdiff < 0 ) vdiff = 0; // Ending point offset int lp = lastPoint.y(); int plp = pen->lastPoint.y(); evdiff = qAbs(lp - plp); // Insanely offset? if ( evdiff > 20 ) { return 400000; } evdiff -= 5; if ( evdiff < 0 ) evdiff = 0; } // do a correlation with the three available signatures. int err1 = INT_MAX; int err2 = INT_MAX; int err3 = INT_MAX; err1 = tsig.calcError(pen->tsig); if ( err1 > tsig.maxError() ) { // no need for more matching return 400000; } // maybe a sliding window is worthwhile for these too. err2 = dsig.calcError( pen->dsig ); if ( err2 > dsig.maxError() ) { return 400000; } err3 = asig.calcError( pen->asig, pen->dsig ); if ( err3 > asig.maxError() ) { return 400000; } // Some magic numbers here - the addition reduces the weighting of // the error and compensates for the different error scales. I // consider the tangent signature to be the best indicator, so it // has the most weight. This ain't rocket science. // Basically, these numbers are the tuning factors. unsigned int err = ( err1 + tsig.weight() ) * ( err2 + dsig.weight() ) * ( err3 + asig.weight() ) + vdiff * 1000 + evdiff * 500 + (unsigned int)(lratio * 5000.0); return err; }