/************************************************************************ ** ** @file vistoolheight.cpp ** @author Roman Telezhynskyi ** @date 13 8, 2014 ** ** @brief ** @copyright ** This source code is part of the Valentina project, a pattern making ** program, whose allow create and modeling patterns of clothing. ** Copyright (C) 2013-2015 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** Valentina is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with Valentina. If not, see . ** *************************************************************************/ #include "vistoolheight.h" #include #include #include #include #include #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visline.h" #include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent) : VisLine(data, parent) { base_point = InitPoint(supportColor, this); lineP1 = InitPoint(supportColor, this); lineP2 = InitPoint(supportColor, this); line = InitItem(supportColor, this); line_intersection = InitItem(supportColor, this); //-V656 point = InitPoint(mainColor, this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolHeight::RefreshGeometry() { if (object1Id > NULL_ID) { const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(base_point, static_cast(*first), supportColor); if (lineP1Id <= NULL_ID) { DrawLine(this, QLineF(static_cast(*first), Visualization::scenePos), mainColor); } else { const QSharedPointer second = Visualization::data->GeometricObject(lineP1Id); DrawPoint(lineP1, static_cast(*second), supportColor); QLineF base_line; if (lineP2Id <= NULL_ID) { base_line = QLineF(static_cast(*second), Visualization::scenePos); DrawLine(line, base_line, supportColor); } else { const QSharedPointer third = Visualization::data->GeometricObject(lineP2Id); DrawPoint(lineP2, static_cast(*third), supportColor); base_line = QLineF(static_cast(*second), static_cast(*third)); } DrawLine(line, base_line, supportColor); QPointF height = VToolHeight::FindPoint(base_line, static_cast(*first)); DrawPoint(point, height, mainColor); QLineF height_line(static_cast(*first), height); DrawLine(this, height_line, mainColor, lineStyle); ShowIntersection(height_line, base_line); } } } //--------------------------------------------------------------------------------------------------------------------- void VisToolHeight::setLineP1Id(const quint32 &value) { lineP1Id = value; } //--------------------------------------------------------------------------------------------------------------------- void VisToolHeight::setLineP2Id(const quint32 &value) { lineP2Id = value; } //--------------------------------------------------------------------------------------------------------------------- void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line) { QPointF p; QLineF::IntersectType intersect = Intersects(height_line, base_line, &p); if (intersect == QLineF::UnboundedIntersection) { line_intersection->setVisible(true); DrawLine(line_intersection, QLineF(base_line.p1(), height_line.p2()), supportColor, Qt::DashLine); } else if (intersect == QLineF::BoundedIntersection) { line_intersection->setVisible(false); } }