1
/***************************************************************************
2
* Copyright (c) 2012-2014 Luke Parry <l.parry@warwick.ac.uk> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
# include <QPainterPath>
28
#include <Mod/TechDraw/App/Geometry.h>
29
#include <Mod/TechDraw/App/DrawParametricTemplate.h>
31
#include "QGIDrawingTemplate.h"
34
using namespace TechDrawGui;
36
QGIDrawingTemplate::QGIDrawingTemplate(QGSPage* scene) : QGITemplate(scene),
39
pathItem = new QGraphicsPathItem;
41
// Invert the Y for the QGraphicsPathItem with Y pointing upwards
43
qtrans.scale(1., -1.);
45
pathItem->setTransform(qtrans);
50
QGIDrawingTemplate::~QGIDrawingTemplate()
55
void QGIDrawingTemplate::clearContents()
60
TechDraw::DrawParametricTemplate * QGIDrawingTemplate::getParametricTemplate()
62
if(pageTemplate && pageTemplate->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId()))
63
return static_cast<TechDraw::DrawParametricTemplate *>(pageTemplate);
68
void QGIDrawingTemplate::draw()
71
TechDraw::DrawParametricTemplate *tmplte = getParametricTemplate();
73
throw Base::RuntimeError("Template Feuature not set for QGIDrawingTemplate");
77
// Clear the previous geometry stored
79
// Get a list of geometry and iterate
80
const TechDraw::BaseGeomPtrVector &geoms = tmplte->getGeometry();
82
TechDraw::BaseGeomPtrVector::const_iterator it = geoms.begin();
87
// iterate through all the geometries
88
for(; it != geoms.end(); ++it) {
89
switch((*it)->getGeomType()) {
90
case TechDraw::GENERIC: {
92
TechDraw::GenericPtr geom = std::static_pointer_cast<TechDraw::Generic>(*it);
94
path.moveTo(geom->points[0].x, geom->points[0].y);
95
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
97
for(++it; it != geom->points.end(); ++it) {
98
path.lineTo((*it).x, (*it).y);
107
pathItem->setPath(path);
110
void QGIDrawingTemplate::updateView(bool update)
116
#include <Mod/TechDraw/Gui/moc_QGIDrawingTemplate.cpp>