Esempio n. 1
0
double RS_InfoArea::getArea(const QPolygon& polygon)
{
    double ret= 0.0;
    if(polygon.size()<3) return ret;

    for(int i=0;i<polygon.size(); ++i){
        const QPoint& p0=polygon.at(i);
        const QPoint& p1=polygon.at((i+1)%polygon.size());
        ret += p0.x()*p1.y()-p0.y()*p1.x();
    }
    return 0.5*fabs(ret);
}
Esempio n. 2
0
bool Selection::isAxisAlignedRectangle() const
{
    if(m_shape.size() != 4)
        return false;

    // When we create a rectangular polygon (see above), the points
    // are in clockwise order, starting from the top left.
    // 0-----1
    // |     |
    // 3-----2
    // This can be rotated 90, 180 or 210 degrees and still remain an
    // axis aligned rectangle, so we need to check:
    // 0==1 and 2==3 (X plane) and 0==3 and 1==2 (Y plane)
    // OR
    // 0==3 and 1==2 (X plane) and 0==1 and 2==3 (Y plane)

    QPolygon p = m_shape.toPolygon();

    return
        (
            // case 1
            p.at(0).y() == p.at(1).y() &&
            p.at(2).y() == p.at(3).y() &&
            p.at(0).x() == p.at(3).x() &&
            p.at(1).x() == p.at(2).x()
        ) || (
            // case 2
            p.at(0).y() == p.at(3).y() &&
            p.at(1).y() == p.at(2).y() &&
            p.at(0).x() == p.at(1).x() &&
            p.at(2).x() == p.at(3).x()
        );
}
Esempio n. 3
0
Bot::Bot(const QPolygon &path, Map *map, Scene *scene)
	: Actor("resources/guard.spb", scene),
	  m_map(map),
	  m_currentLine(0),
	  m_positionInLine(0),
	  m_movingForward(true),
//	  m_directionSwitchDelay(0),
	  m_visionCone(this, map, scene)
{
	for(int i = 0; i < path.count() - 1; i++)
		m_path.append(QLineF(path.at(i), path.at(i + 1)));

//	m_alarmSound.setSource(QUrl::fromLocalFile("resources/sound/alarm.wav"));
//	m_alarmSound.setVolume(0.5);
//	m_alarmSound.setLoopCount(3);
}
QRect toRect(QPolygon polygon)
{
    if(polygon.size() != 4)
        return QRect();

    return QRect(polygon.first(), polygon.at(2));
}
Esempio n. 5
0
QDebug operator<<(QDebug dbg, const QPolygon &a)
{
    dbg.nospace() << "QPolygon(";
    for (int i = 0; i < a.count(); ++i)
        dbg.nospace() << a.at(i);
    dbg.nospace() << ')';
    return dbg.space();
}
Esempio n. 6
0
QPolygon Zoomer::getZoomedPolygon(const QPolygon &poly)
{
   QPolygon newPoly;
   for(int i=0; i<poly.size(); i++)
   {
      newPoly << getZoomedPoint(poly.at(i));
   }
   return newPoly;
}
Esempio n. 7
0
QDebug operator<<(QDebug dbg, const QPolygon &a)
{
#ifndef Q_BROKEN_DEBUG_STREAM
    dbg.nospace() << "QPolygon(";
    for (int i = 0; i < a.count(); ++i)
        dbg.nospace() << a.at(i);
    dbg.nospace() << ')';
    return dbg.space();
#else
    qWarning("This compiler doesn't support streaming QPolygon to QDebug");
    return dbg;
    Q_UNUSED(a);
#endif
}
Esempio n. 8
0
static void qDrawWinArrow(QPainter *p, Qt::ArrowType type, bool down,
                           int x, int y, int w, int h,
                           const QPalette &pal, bool enabled)
{
    QPolygon a;                                // arrow polygon
    switch (type) {
    case Qt::UpArrow:
        a.setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
        break;
    case Qt::DownArrow:
        a.setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
        break;
    case Qt::LeftArrow:
        a.setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
        break;
    case Qt::RightArrow:
        a.setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
        break;
    default:
        break;
    }
    if (a.isEmpty())
        return;

    if (down) {
        x++;
        y++;
    }

    QPen savePen = p->pen();                        // save current pen
    if (down)
        p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
    p->fillRect(x, y, w, h, pal.brush(QPalette::Button));
    if (down)
        p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
    if (enabled) {
        a.translate(x+w/2, y+h/2);
        p->setPen(pal.foreground().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
    } else {
        a.translate(x+w/2+1, y+h/2+1);
        p->setPen(pal.light().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
        a.translate(-1, -1);
        p->setPen(pal.mid().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
    }
    p->setPen(savePen);                        // restore pen
}
Esempio n. 9
0
/*!
 * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen)
 * \see drawPolygons(QPainter *aPainter, QPen *aPen)
 *
 * It contains drawing of the confirmed and not confirmed selections either.
 */
void
ImageHolder::paintEvent(QPaintEvent *anEvent)
{
	QLabel::paintEvent(anEvent);

	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);
	//painter.setRenderHint(QPainter::SmoothPixmapTransform);
	QPen pen;

	if (NoTool != tool_) {
		pen.setWidth(1);
		pen.setColor(QColor(Qt::black));
		pen.setStyle(Qt::DashLine);
		painter.setPen(pen);

		if (BoundingBoxTool == tool_) {
			/* scaling */
			QRect bbox = bounding_box_.rect;
			QPoint bboxTopLeft = bbox.topLeft() * scale_;
			QPoint bboxBottomRight = bbox.bottomRight() * scale_;

			bbox.setTopLeft(bboxTopLeft);
			bbox.setBottomRight(bboxBottomRight);

			painter.drawRect(bbox);
		}
		else if (PolygonTool == tool_) {
			/* scaling */
			QPoint point;
			QPolygon poly = polygon_.poly;
			for (int i = 0; i < poly.size(); i++) {
				point.setX(poly.at(i).x());
				point.setY(poly.at(i).y());
				point *= scale_;
				poly.remove(i);
				poly.insert(i, point);
			}
			painter.drawPolygon(poly);
		}
	}

	/* drawing bounding boxes */
	drawBoundingBoxes(&painter, &pen);
	drawPolygons(&painter, &pen);
}
Esempio n. 10
0
void tst_QPolygon::makeEllipse()
{
    // create an ellipse with R1 = R2 = R, i.e. a circle
    QPolygon pa;
    const int R = 50; // radius
    QPainterPath path;
    path.addEllipse(0, 0, 2*R, 2*R);
    pa = path.toSubpathPolygons().at(0).toPolygon();

    int i;
    // make sure that all points are R+-1 away from the center
    bool err = FALSE;
    for (i = 1; i < pa.size(); i++) {
        QPoint p = pa.at( i );
        double r = sqrt( pow( double(p.x() - R), 2.0 ) + pow( double(p.y() - R), 2.0 ) );
        // ### too strict ? at least from visual inspection it looks
        // quite odd around the main axes. 2.0 passes easily.
        err |= ( qAbs( r - double(R) ) > 2.0 );
    }
    QVERIFY( !err );
}
Esempio n. 11
0
void Storage::paintEvent(QPaintEvent *anEvent)
{
    QLabel::paintEvent(anEvent);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    //painter.setRenderHint(QPainter::SmoothPixmapTransform);
    QPen pen;

    if (NoTool != tool_) {
        pen.setWidth(5);
        pen.setColor(QColor(Qt::white));
        pen.setStyle(Qt::DashLine);
        painter.setPen(pen);

        if (BoundingBoxTool == tool_) {
            /* с учётом масштаба */
            QRect bbox = rect.getCoordinates();
            QPoint bboxTopLeft = bbox.topLeft() * scale_;
            QPoint bboxBottomRight = bbox.bottomRight() * scale_;

            bbox.setTopLeft(bboxTopLeft);
            bbox.setBottomRight(bboxBottomRight);

            painter.drawRect(bbox);
        }
        else if (EllipseTool == tool_) {
            /* с учётом масштаба */
            QRect elli = ell.getCoordinates().normalized();
            QPoint ellTopLeft = elli.topLeft() * scale_;
            QPoint ellBottomRight = elli.bottomRight() * scale_;

            elli.setTopLeft(ellTopLeft);
            elli.setBottomRight(ellBottomRight);

            if(1 < elli.height() && 1 < elli.width() )
            {
                painter.drawEllipse(elli);
            }
//            painter.drawRect(ell);
        }
        else if (ArrowTool == tool_) {
            /* с учётом масштаба */
            QLineF line = arrow.getCoordinates();
            QPointF p1 = line.p1() * scale_;
            QPointF p2 = line.p2() * scale_;

            line.setP1(p1);
            line.setP2(p2);

            if(1 < line.length())
            {
                double angle = ::acos(line.dx() / line.length());
                qreal Pi = atan(1)*4;
                if (line.dy() >= 0)
                    angle = (Pi * 2) - angle;

                QPointF arrowP1 = line.p1() + QPointF(sin(angle + Pi / 3) * arrow_size_,
                                                cos(angle + Pi / 3) * arrow_size_);
                QPointF arrowP2 = line.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrow_size_,
                                                cos(angle + Pi - Pi / 3) * arrow_size_);

                QPolygonF arrowTop;
                arrowTop.clear();
                arrowTop << line.p1() << arrowP1 << arrowP2;

                painter.drawLine(line);
                painter.drawPolygon(arrowTop);///111
                qDebug() << "arrowTop" << arrowTop;
                arrow_top_ = arrowTop;
            }

            }
        else if (PolygonTool == tool_) {
            /* с учётом масштаба */
            QPoint point;
            QPolygon pol = poly.getCoordinates();
            for (int i = 0; i < pol.size(); i++) {
                point.setX(pol.at(i).x());
                point.setY(pol.at(i).y());
                point *= scale_;
                pol.remove(i);
                pol.insert(i, point);
            }
            painter.drawPolygon(pol);
        }
    }

    /* рисуем фигуры */
    drawBoundingBoxes(&painter, &pen);
    drawPolygons(&painter, &pen);
    drawEllipses(&painter, &pen);
    drawArrows(&painter, &pen);
}
Esempio n. 12
0
void ModelExportHelper::exportToPNG(ObjectsScene *scene, const QString &filename, float zoom, bool show_grid, bool show_delim)
{
	if(!scene)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	try
	{
		QPixmap pix;
		QRectF ret=scene->itemsBoundingRect();
		bool shw_grd, shw_dlm, align_objs;
		QGraphicsView viewp(scene);
		QRect retv;
		QPolygon pol;

		//Clear the object scene selection to avoid drawing the selectoin rectangle of the objects
		scene->clearSelection();

		//Make a backup of the current scene options
		ObjectsScene::getGridOptions(shw_grd, align_objs, shw_dlm);

		//Sets the options passed by the user
		ObjectsScene::setGridOptions(show_grid, false, show_delim);

		//Updates the scene to apply the change on grid and delimiter
		scene->update();

		//Configures the viewport alignment to top-left coordinates.
		viewp.setAlignment(Qt::AlignLeft | Qt::AlignTop);

		//Apply the zoom factor on the viewport
		viewp.resetTransform();
		viewp.centerOn(0,0);
		viewp.scale(zoom, zoom);

		//Convert the objects bounding rect to viewport coordinates to correctly draw them onto pixmap
		pol=viewp.mapFromScene(ret);

		//Configure the viewport area to be copied
		retv.setTopLeft(pol.at(0));
		retv.setTopRight(pol.at(1));
		retv.setBottomRight(pol.at(2));
		retv.setBottomLeft(pol.at(3));

		//Creates the output pixmap
		pix=QPixmap(retv.size());
		pix.fill();
		QPainter p(&pix);

		//Setting optimizations on the painter
		p.setRenderHint(QPainter::Antialiasing, true);
		p.setRenderHint(QPainter::TextAntialiasing, true);
		p.setRenderHint(QPainter::SmoothPixmapTransform, true);

		emit s_progressUpdated(50, trUtf8("Rendering objects onto the output pixmap..."), BASE_OBJECT);

		//Render the entire viewport onto the pixmap
		viewp.render(&p, QRectF(QPointF(0,0), pix.size()), retv);

		//Restore the scene options
		ObjectsScene::setGridOptions(shw_grd, align_objs, shw_dlm);

		//Updates the scene to apply the restoration of grid and delimiter statuses
		scene->update();

		//If the pixmap is not saved raises an error
		if(!pix.save(filename))
			throw Exception(Exception::getErrorMessage(ERR_FILE_NOT_WRITTEN).arg(Utf8String::create(filename)),
											ERR_FILE_NOT_WRITTEN,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		emit s_exportFinished();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Esempio n. 13
0
C2DPixmapSegment* CDraw2D::createSubpixmapFromPolygon(QPolygon &polygon, EPolygonConversion conv)
{
   if(polygon.size() < 2)
   {
      return 0;
   }

   

   int sizeOffset = qFloor(static_cast<qreal>(CDrawSettings_2D::getInstance()->penSettings().getWidth())/2.);

   // get the polygons relative to its bounding rectangle
   QPolygon normalizedPolygon = normalizePolygon(polygon, sizeOffset);
   QRect boundingRect = polygon.boundingRect();
   QRect normalizedBoundingRect = normalizedPolygon.boundingRect();
   QSize segmentSize(
      boundingRect.size().width() +  2 * sizeOffset + 1, 
      boundingRect.size().height() + 2 * sizeOffset + 1
      );

   // create segment
   QPixmap segmentContent(segmentSize);
   segmentContent.fill(Qt::transparent);
   QPainter segmentPainter(&segmentContent);
   segmentPainter.setPen(CDrawSettings_2D::getInstance()->penSettings().getPen());
   segmentPainter.setRenderHint(QPainter::Antialiasing,_settings.getAntialiasing());
   
   QPoint firstPt;
   QPoint secondPt;
   switch(conv)
   {
   case(NO_CONVERSION):
      segmentPainter.drawPolyline(normalizedPolygon);
      break;

   case(TO_LINES):
      firstPt = normalizedPolygon.at(0);
      for (int i = 1; i<normalizedPolygon.size(); i++)
      {
         secondPt = normalizedPolygon.at(i);
         if(firstPt == secondPt)
         {
            continue;
         }
         segmentPainter.drawLine(firstPt, secondPt);
         firstPt = secondPt;
      }
      break;

   case(TO_RECT):
      segmentPainter.drawRect(normalizedBoundingRect);
      break;

   case(TO_ROUNDED_RECT):
      segmentPainter.drawRoundedRect(
      normalizedBoundingRect,
      CDrawSettings_2D::getInstance()->getRoundedRectRadius_X(),
      CDrawSettings_2D::getInstance()->getRoundedRectRadius_Y()
      );
      break;

   case(TO_ELLIPSE):
      segmentPainter.drawEllipse(normalizedBoundingRect);
      break;

   case(TO_PIE):
      segmentPainter.drawPie(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   case(TO_ARC):
      segmentPainter.drawArc(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   case(TO_CHORD):
      segmentPainter.drawChord(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   default:
      segmentPainter.drawPolyline(normalizedPolygon);
      break;
   }

   segmentPainter.end();

   //DebugImageDialog DBG(segmentContent);
   //DBG.exec();

   C2DPixmapSegment *segment = new C2DPixmapSegment(&segmentContent, &boundingRect, 1, sizeOffset);
   return segment;
}
Esempio n. 14
0
void Airspace::drawRegion( QPainter* targetP, qreal opacity )
{
  // qDebug("Airspace::drawRegion(): TypeId=%d, opacity=%f, Name=%s",
  //         typeID, opacity, getInfoString().toLatin1().data() );

  if( ! GeneralConfig::instance()->getItemDrawingEnabled(typeID) ||
      ! glConfig->isBorder(typeID) || ! isVisible())
    {
      return;
    }

  if( m_flarmAlertZone.isValid() )
    {
      // A Flarm Alert zone has to be drawn.
      drawFlarmAlertZone( targetP, opacity );
      return;
    }

  QPolygon mP = glMapMatrix->map(projPolygon);

  if( mP.size() < 3 )
    {
      return;
    }

  QPainterPath pp;

  pp.moveTo( mP.at(0) );

  for( int i = 1; i < mP.size(); i++ )
    {
      pp.lineTo( mP.at(i) );
    }

  pp.closeSubpath();

  QBrush drawB( glConfig->getDrawBrush(typeID) );

  if( opacity <= 100.0 )
    {
      // use solid filled air regions
      drawB.setStyle( Qt::SolidPattern );
    }

  QPen drawP = glConfig->getDrawPen(typeID);
  drawP.setJoinStyle(Qt::RoundJoin);

  int lw = GeneralConfig::instance()->getAirspaceLineWidth();

  extern MapConfig* _globalMapConfig;

  if( lw > 1 && _globalMapConfig->useSmallIcons() )
    {
      lw = (lw + 1) / 2;
    }

  drawP.setWidth(lw);

  targetP->setPen(drawP);
  targetP->setBrush(drawB);

  if( opacity <= 100.0 && opacity > 0.0 )
    {
      // Draw airspace filled with opacity factor
      targetP->setOpacity( opacity/100.0 );
      targetP->drawPolygon(mP);

      // Reset opacity, that a solid line is drawn as next
      targetP->setBrush(Qt::NoBrush);
      targetP->setOpacity( 1.0 );
    }
  else if( opacity == 0.0 )
    {
      // draw only airspace borders without any filling inside
      targetP->setBrush(Qt::NoBrush);
      targetP->setOpacity( 1.0 );
    }

  // Draw the outline of the airspace with the selected brush
  targetP->drawPath(pp);
}
Esempio n. 15
0
QPolygonF::QPolygonF(const QPolygon &a)
{
    reserve(a.size());
    for (int i=0; i<a.size(); ++i)
        append(a.at(i));
}
Esempio n. 16
0
void GlyphDelegate::glyphRendering(QPainter * painter,
                                   const QStyleOptionViewItem &option,
                                   QVector<QString> names,
                                   QVector<double> coeffs, //absolute values;
                                   QVector<bool> signs,
                                   QVector<int> index,
                                   int start,
                                   int size) const
{

    int width= 0.5*(option.rect.height()+option.rect.width());
    QPoint origin = option.rect.center();

    QPolygon meshes;
    QPolygon surfaces;

    float minRadian = M_PI;
    float maxRadian = 0;

    for(int i = 0; i< index.size(); i++){

        double ratio = (double)(i-start)/(double)(index.size() - start);

        double maxcoe = this->max(coeffs);

        double mincoe = this->min(coeffs);



        float length;

        if(abs(maxcoe-mincoe)<0.001){
            length =
                           (double)(width*0.05)+
                           (double)(width*0.20);
        }else{
            length =
                           (double)(width*0.05)+
                           (double)(width*0.20)*(double)(coeffs.at(i)-mincoe)/(double)(maxcoe-mincoe);
        }

        float degree = (ratio*M_PI*2);

        if(minRadian>degree) minRadian=degree;

        if(maxRadian<degree) maxRadian=degree;

        int x = length*std::sin(degree)+origin.x();
        int y = origin.y()+length*std::cos(degree);

        meshes << QPoint(x,y) << origin;

        surfaces << QPoint(x,y);

        //float textRadius = (double)(width*0.30);
        int txt_x = (length+(double)width*0.05)*std::sin(degree)+origin.x();

        if(degree>M_PI){
            txt_x-=names.at(i).size()*5;
        }

        int txt_y = origin.y()+(length+(double)width*0.05)*std::cos(degree);

        painter->setPen(Qt::black);
        painter->drawText(txt_x,txt_y,names.at(i));
    }

    if(surfaces.size()>0&&(maxRadian-minRadian)>M_PI){
        //surfaces << origin;
        surfaces << surfaces.at(0);
    }

    painter->setPen(QColor(200,0,0,200));

    painter->drawPolyline(meshes);
}
Esempio n. 17
0
/*!
 * \see hovered_point_
 * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen)
 * \see drawPolygons(QPainter *aPainter, QPen *aPen)
 *
 * It simply checks all the points of all objects if mouse
 * pointer is hovered above any of them
 */
void
ImageHolder::checkForPoints(QPoint *aPos)
{
	if ((!list_polygon_->count() &&
		!list_bounding_box_->count()) ||
		!aPos) {
		return;
		/* NOTREACHED */
	}

	int newRadius = 0;
	int x = aPos->x();
	int y = aPos->y();
	/* center coordinates */
	int xc = 0;
	int yc = 0;
	for (int i = 0; i < list_polygon_->count(); i++) {
		QPolygon poly = list_polygon_->at(i)->poly;
		for (int j = 0; j < poly.count(); j++) {
			xc = poly.at(j).x();
			yc = poly.at(j).y();
			newRadius = qSqrt(qPow(x - xc, 2) + qPow(y - yc, 2));
			if (newRadius <= point_radius_) {
				hovered_point_.figure = PolyFigure;
				hovered_point_.figureID = i;
				hovered_point_.pointID = j;
				repaint_needed_ = 1;
				return;
				/* NOTREACHED */
			}
		}
	}

	for (int i = 0; i < list_bounding_box_->count(); i++) {
		QRect rect = list_bounding_box_->at(i)->rect;

		for (int j = 0; j < 4; j++) {
			if (!j) {
				xc = rect.left();
				yc = rect.top();
			}
			else if (1 == j)
			{
				xc = rect.right();
				yc = rect.top();
			}
			else if (2 == j)
			{
				xc = rect.right();
				yc = rect.bottom();
			}
			else if (3 == j)
			{
				xc = rect.left();
				yc = rect.bottom();
			}


			newRadius = qSqrt(qPow(x - xc, 2) + qPow(y - yc, 2));
			if (newRadius <= point_radius_) {
				hovered_point_.figure = RectFigure;
				hovered_point_.figureID = i;
				hovered_point_.pointID = j;
				repaint_needed_ = 1;
				return;
				/* NOTREACHED */
			}
		}
	}

	hovered_point_.figure = NoFigure;
	hovered_point_.figureID = -1;
	hovered_point_.pointID = -1;
	repaint_needed_ = 1;
}
Esempio n. 18
0
/*!
 * parameters of polygons may vary depending on whether poly is selected or not or
 * whether it's label is main or not.
 */
void
ImageHolder::drawPolygons(
	QPainter *aPainter,
	QPen *aPen
) const
{
	if (0 == list_polygon_)
	{
		return;
		/* NOTREACHED */
	}

	Qt::PenStyle penStyle = Qt::SolidLine;
	/* default width is hardcoded */
	int width = 2;
	/* drawing all the polygons */
	for (int i = 0; i < list_polygon_->size(); i++) {
		penStyle = Qt::SolidLine;
		int labelID = list_polygon_->at(i)->label_ID_;

		/* setting color for the label of current bbox */
		if (labelID < list_label_color_->count())
			aPen->setColor(QColor(list_label_color_->at(labelID)));
		/* in case there is no color for such label */
		else
			aPen->setColor(QColor(Qt::white));

		/* checking whether labeled area is of main object or not */
		if (labelID == *main_label_)
			width = 3;
		else
			width = 2;

		/* changing the line style and width if current area is selected(focused) */
		if (PolyFigure == focused_selection_type_ &&
			focused_selection_ == i) {
			penStyle = Qt::DotLine;
			width = 3;
		}

		QPoint point;
		QPolygon poly = list_polygon_->at(i)->poly;
		for (int j = 0; j < poly.size(); j++) {
			point.setX(poly.at(j).x());
			point.setY(poly.at(j).y());
			/* scaling */
			point *= scale_;
			poly.remove(j);
			poly.insert(j, point);

			/* in case if it's focused */
			if (focused_selection_ == i &&
				focused_selection_type_ == PolyFigure) {
				QPen circPen;
				circPen.setWidth(2);
				circPen.setStyle(Qt::SolidLine);
				circPen.setColor(aPen->color());
				aPainter->setPen(circPen);
				/* filling the point if it is hovered */
				if ((j == hovered_point_.pointID &&
					i == hovered_point_.figureID &&
					PolyFigure == hovered_point_.figure) ||
					j == selected_point_) {
					QBrush brush;
					brush.setColor(aPen->color());
					brush.setStyle(Qt::SolidPattern);
					aPainter->setBrush(brush);
				}
				aPainter->drawEllipse(point, point_radius_, point_radius_);
				aPainter->setBrush(Qt::NoBrush);
			}
		}

		aPen->setWidth(width);
		aPen->setStyle(penStyle);
		aPainter->setPen(*aPen);

		aPainter->drawPolygon(poly);
		/* drawing label IDs of these polygons */
		QString labelIDText =
			QString("%1").arg(labelID);
		QRect rect = poly.boundingRect();
		int x = rect.center().x();
		int y = rect.center().y();

		aPainter->drawText(
			x,
			y,
			20,
			20,
			Qt::AlignHCenter,
			labelIDText
			);
	}

}