New tool line intersect axis.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-20 20:41:02 +03:00
parent f9e6b7f07d
commit a21ad603ef
23 changed files with 1719 additions and 12 deletions

View File

@ -49,6 +49,7 @@
#include "tools/dialoguniondetails.h"
#include "tools/dialogtriangle.h"
#include "tools/dialogpointofintersection.h"
#include "tools/dialoglineintersectaxis.h"
#include "app/dialoghistory.h"
#include "app/dialogincrements.h"

View File

@ -21,6 +21,8 @@ HEADERS += \
dialogs/tools/dialogcutsplinepath.h \
dialogs/tools/dialoguniondetails.h \
dialogs/tools/dialogcutarc.h \
dialogs/tools/dialogeditwrongformula.h \
dialogs/tools/dialoglineintersectaxis.h \
dialogs/app/dialogincrements.h \
dialogs/app/dialoghistory.h \
dialogs/app/configdialog.h \
@ -30,7 +32,6 @@ HEADERS += \
dialogs/app/dialogstandardmeasurements.h \
dialogs/app/dialogindividualmeasurements.h \
dialogs/app/dialogaboutapp.h \
dialogs/tools/dialogeditwrongformula.h \
dialogs/app/dialogpatternxmledit.h \
dialogs/app/configpages/configurationpage.h \
dialogs/app/configpages/patternpage.h \
@ -60,6 +61,8 @@ SOURCES += \
dialogs/tools/dialogcutsplinepath.cpp \
dialogs/tools/dialoguniondetails.cpp \
dialogs/tools/dialogcutarc.cpp \
dialogs/tools/dialogeditwrongformula.cpp \
dialogs/tools/dialoglineintersectaxis.cpp \
dialogs/app/dialogincrements.cpp \
dialogs/app/dialoghistory.cpp \
dialogs/app/configdialog.cpp \
@ -69,7 +72,6 @@ SOURCES += \
dialogs/app/dialogindividualmeasurements.cpp \
dialogs/app/dialogaboutapp.cpp \
dialogs/app/dialogpatternxmledit.cpp \
dialogs/tools/dialogeditwrongformula.cpp \
dialogs/app/configpages/configurationpage.cpp \
dialogs/app/configpages/patternpage.cpp \
dialogs/app/configpages/communitypage.cpp \
@ -97,6 +99,8 @@ FORMS += \
dialogs/tools/dialogcutsplinepath.ui \
dialogs/tools/dialoguniondetails.ui \
dialogs/tools/dialogcutarc.ui \
dialogs/tools/dialogeditwrongformula.ui \
dialogs/tools/dialoglineintersectaxis.ui \
dialogs/app/dialogincrements.ui \
dialogs/app/dialoghistory.ui \
dialogs/app/dialogpatternproperties.ui \
@ -105,5 +109,4 @@ FORMS += \
dialogs/app/dialogindividualmeasurements.ui \
dialogs/app/dialogaboutapp.ui \
dialogs/app/dialogpatternxmledit.ui \
dialogs/tools/dialogeditwrongformula.ui \
dialogs/app/dialogundo.ui
dialogs/app/dialogundo.ui \

View File

@ -112,7 +112,7 @@ void DialogEndLine::FormulaTextChanged()
void DialogEndLine::AngleTextChanged()
{
labelEditFormula = ui->labelEditAngle;
ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula);
ValFormulaChanged(flagError, ui->plainTextEditAngle, timerFormula);
labelEditFormula = ui->labelEditFormula;
}

View File

@ -0,0 +1,290 @@
/************************************************************************
**
** @file dialoglineintersectaxis.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialoglineintersectaxis.h"
#include "ui_dialoglineintersectaxis.h"
#include "../../geometry/vpointf.h"
#include "../../container/vcontainer.h"
#include "../../visualization/vistoollineintersectaxis.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../tools/vabstracttool.h"
#include <QTimer>
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), number(0), typeLine(QString()),
formulaAngle(QString()), basePointId(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID),
formulaBaseHeightAngle(0), line(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
CheckState();
FillComboBoxPoints(ui->comboBoxAxisPoint);
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::PutAngle);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogLineIntersectAxis::PutVal);
connect(ui->toolButtonEqualAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::EvalAngle);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersectAxis::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogLineIntersectAxis::AngleTextChanged);
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::DeployAngleTextEdit);
connect(timerFormula, &QTimer::timeout, this, &DialogLineIntersectAxis::EvalAngle);
line = new VisToolLineIntersectAxis(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersectAxis::~DialogLineIntersectAxis()
{
delete line;
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogLineIntersectAxis::getPointName() const
{
return pointName;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogLineIntersectAxis::getTypeLine() const
{
return typeLine;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogLineIntersectAxis::getAngle() const
{
return qApp->FormulaFromUser(formulaAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setAngle(const QString &value)
{
formulaAngle = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line
// of this PlainTextEdit to change 80 to this value
if (formulaAngle.length() > 80)
{
this->DeployAngleTextEdit();
}
ui->plainTextEditFormula->setPlainText(formulaAngle);
line->setAngle(formulaAngle);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogLineIntersectAxis::getBasePointId() const
{
return basePointId;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setBasePointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxAxisPoint, basePointId, value);
line->setAxisPointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogLineIntersectAxis::getFirstPointId() const
{
return firstPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstLinePoint, firstPointId, value);
line->setPoint1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogLineIntersectAxis::getSecondPointId() const
{
return secondPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondLinePoint, secondPointId, value);
line->setPoint2Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ShowDialog(bool click)
{
if (prepare)
{
if (click)
{
/*We will ignore click if poinet is in point circle*/
VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(basePointId);
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
if (line.length() <= radius)
{
return;
}
}
this->setModal(true);
this->setAngle(line->Angle());//Show in dialog angle what user choose
emit ToolTip("");
timerFormula->start();
this->show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{
if (type == SceneObject::Point)
{
switch (number)
{
case (0):
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second point of line")))
{
number++;
line->VisualMode(id);
}
break;
case (1):
if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point")))
{
number++;
line->setPoint2Id(id);
line->RefreshGeometry();
}
break;
case (2):
if (SetObject(id, ui->comboBoxAxisPoint, ""))
{
basePointId = id;
line->setAxisPointId(id);
line->RefreshGeometry();
prepare = true;
}
break;
default:
break;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::PutAngle()
{
PutValHere(ui->plainTextEditFormula, ui->listWidget);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::EvalAngle()
{
const QString postfix = QStringLiteral("°");
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, postfix, false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::AngleTextChanged()
{
ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::DeployAngleTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ShowVisualization()
{
if (prepare == false)
{
//TODO move to parent class!
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLineIntersectAxis::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::SaveData()
{
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formulaAngle = ui->plainTextEditFormula->toPlainText();
formulaAngle.replace("\n", " ");
basePointId = getCurrentObjectId(ui->comboBoxAxisPoint);
firstPointId = getCurrentObjectId(ui->comboBoxFirstLinePoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondLinePoint);
line->setPoint1Id(firstPointId);
line->setPoint2Id(secondPointId);
line->setAxisPointId(basePointId);
line->setAngle(formulaAngle);
line->setLineStyle(VAbstractTool::LineStyle(typeLine));
line->RefreshGeometry();
}

View File

@ -0,0 +1,98 @@
/************************************************************************
**
** @file dialoglineintersectaxis.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGLINEINTERSECTAXIS_H
#define DIALOGLINEINTERSECTAXIS_H
#include "dialogtool.h"
namespace Ui {
class DialogLineIntersectAxis;
}
class VisToolLineIntersectAxis;
class DialogLineIntersectAxis : public DialogTool
{
Q_OBJECT
public:
DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLineIntersectAxis();
QString getPointName() const;
void setPointName(const QString &value);
QString getTypeLine() const;
void setTypeLine(const QString &value);
QString getAngle() const;
void setAngle(const QString &value);
quint32 getBasePointId() const;
void setBasePointId(const quint32 &value);
quint32 getFirstPointId() const;
void setFirstPointId(const quint32 &value);
quint32 getSecondPointId() const;
void setSecondPointId(const quint32 &value);
virtual void ShowDialog(bool click);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type);
void PutAngle();
void EvalAngle();
void AngleTextChanged();
void DeployAngleTextEdit();
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
virtual void SaveData();
private:
Q_DISABLE_COPY(DialogLineIntersectAxis)
Ui::DialogLineIntersectAxis *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
QString formulaAngle;
quint32 basePointId;
quint32 firstPointId;
quint32 secondPointId;
int formulaBaseHeightAngle;
VisToolLineIntersectAxis *line;
};
#endif // DIALOGLINEINTERSECTAXIS_H

View File

@ -0,0 +1,532 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogLineIntersectAxis</class>
<widget class="QDialog" name="DialogLineIntersectAxis">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>457</width>
<height>532</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="labelEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Angle</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHereAngle">
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqualAngle">
<property name="toolTip">
<string>Calculate value</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultCalculation">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value of angle</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="baseSize">
<size>
<width>4</width>
<height>0</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthAngle">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Axis point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxAxisPoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>First line point</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxFirstLinePoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Second line point</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxSecondLinePoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Point label</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Type of line</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBoxLineType">
<property name="toolTip">
<string>Show line from first point to this point</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Input data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonAngleLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBoxHideEmpty">
<property name="text">
<string>Hide empty measurements</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="toolTip">
<string>Variables</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>
<tabstop>toolButtonPutHereAngle</tabstop>
<tabstop>toolButtonEqualAngle</tabstop>
<tabstop>comboBoxAxisPoint</tabstop>
<tabstop>comboBoxFirstLinePoint</tabstop>
<tabstop>comboBoxSecondLinePoint</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogLineIntersectAxis</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogLineIntersectAxis</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -665,6 +665,16 @@ void MainWindow::ToolCutArc(bool checked)
&MainWindow::ApplyDialog<VToolCutArc>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolLineIntersectAxis(bool checked)
{
SetToolButtonWithApply<DialogLineIntersectAxis>(checked, Tool::LineIntersectAxis,
":/cursor/line_intersect_axis_cursor.png",
tr("Select first point of line"),
&MainWindow::ClosedDialogWithApply<VToolLineIntersectAxis>,
&MainWindow::ApplyDialog<VToolLineIntersectAxis>);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief About show widows about.
@ -930,6 +940,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath);
connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails);
connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc);
connect(ui->toolButtonLineIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolLineIntersectAxis);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1069,6 +1080,11 @@ void MainWindow::CancelTool()
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::LineIntersectAxis:
ui->toolButtonLineIntersectAxis->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::NodePoint:
case Tool::NodeArc:
case Tool::NodeSpline:
@ -1772,6 +1788,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonSplineCutPoint->setEnabled(drawTools);
ui->toolButtonSplinePathCutPoint->setEnabled(drawTools);
ui->toolButtonArcCutPoint->setEnabled(drawTools);
ui->toolButtonLineIntersectAxis->setEnabled(drawTools);
//Modeling Tools
ui->toolButtonUnionDetails->setEnabled(modelingTools);

View File

@ -106,6 +106,7 @@ public slots:
void ToolPointOfIntersection(bool checked);
void ToolUnionDetails(bool checked);
void ToolCutArc(bool checked);
void ToolLineIntersectAxis(bool checked);
void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result);

View File

@ -40,7 +40,7 @@
<string/>
</property>
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -301,6 +301,32 @@
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QToolButton" name="toolButtonLineIntersectAxis">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Point of intersection line and axis</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="share/resources/icon.qrc">
<normaloff>:/icon/32x32/line_intersect_axis.png</normaloff>:/icon/32x32/line_intersect_axis.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">

View File

@ -80,7 +80,9 @@ enum class Tool : unsigned char
NodeSplinePath,
Height,
Triangle,
LineIntersectAxis,
PointOfIntersection,
UnionDetails
};
@ -107,7 +109,8 @@ enum class Vis : unsigned char
ToolTriangle,
ToolCutSpline,
ToolSplinePath,
ToolCutSplinePath
ToolCutSplinePath,
ToolLineIntersectAxis
};
enum class Source : char { FromGui, FromFile, FromTool };

View File

@ -21,5 +21,6 @@
<file>cursor/arc_cut_cursor.png</file>
<file>cursor/cursor-arrow-closehand.png</file>
<file>cursor/cursor-arrow-openhand.png</file>
<file>cursor/line_intersect_axis_cursor.png</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -58,5 +58,6 @@
<file>icon/path_config.png</file>
<file>icon/16x16/info.png</file>
<file>icon/16x16/measurement.png</file>
<file>icon/32x32/line_intersect_axis.png</file>
</qresource>
</RCC>

View File

@ -47,5 +47,6 @@
#include "vtoolcutspline.h"
#include "vtoolcutsplinepath.h"
#include "vtoolcutarc.h"
#include "vtoollineintersectaxis.h"
#endif // DRAWTOOLS_H

View File

@ -0,0 +1,335 @@
/************************************************************************
**
** @file vtoollineintersectaxis.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vtoollineintersectaxis.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialoglineintersectaxis.h"
#include "../../dialogs/tools/dialogeditwrongformula.h"
#include "../../geometry/vpointf.h"
#include "./../visualization/vistoollineintersectaxis.h"
const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAxis");
//---------------------------------------------------------------------------------------------------------------------
VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id,
const QString &typeLine, const QString &formulaAngle,
const quint32 &basePointId, const quint32 &firstPointId,
const quint32 &secondPointId, const Source &typeCreation,
QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
firstPointId(firstPointId), secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
}
//---------------------------------------------------------------------------------------------------------------------
VToolLineIntersectAxis::~VToolLineIntersectAxis()
{}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::setDialog()
{
SCASSERT(dialog != nullptr);
dialog->setModal(true);
DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog);
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine);
dialogTool->setAngle(formulaAngle);
dialogTool->setBasePointId(basePointId);
dialogTool->setFirstPointId(firstPointId);
dialogTool->setSecondPointId(secondPointId);
dialogTool->setPointName(p->name());
}
//---------------------------------------------------------------------------------------------------------------------
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog);
SCASSERT(dialogTool);
const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine();
QString formulaAngle = dialogTool->getAngle();
const quint32 basePointId = dialogTool->getBasePointId();
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
VToolLineIntersectAxis *point = nullptr;
point=Create(0, pointName, typeLine, formulaAngle, basePointId, firstPointId, secondPointId, 5, 10, scene, doc,
data, Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName,
const QString &typeLine, QString &formulaAngle,
const quint32 &basePointId, const quint32 &firstPointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
QLineF axis = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
axis.setAngle(CheckFormula(_id, formulaAngle, data));
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
QLineF line(firstPoint->toQPointF(), secondPoint->toQPointF());
QPointF fPoint = FindPoint(axis, line);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
data->AddLine(basePointId, id);
data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId);
}
else
{
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
data->AddLine(basePointId, id);
data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::LineIntersectAxis, doc);
if (parse == Document::FullParse)
{
VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, formulaAngle,
basePointId, firstPointId, secondPointId,
typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line)
{
QPointF fPoint;
QLineF::IntersectType intersect = axis.intersect(line, &fPoint);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
return fPoint;
}
else
{
return QPointF();
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolLineIntersectAxis::getFormulaAngle() const
{
VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(id);
fAngle.setPostfix(QStringLiteral("°"));
return fAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::setFormulaAngle(const VFormula &value)
{
if (value.error() == false)
{
formulaAngle = value.getFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersectAxis::getFirstPointId() const
{
return firstPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::setFirstPointId(const quint32 &value)
{
if (value != NULL_ID)
{
firstPointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersectAxis::getSecondPointId() const
{
return secondPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::setSecondPointId(const quint32 &value)
{
if (value != NULL_ID)
{
secondPointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolLineIntersectAxis * visual = new VisToolLineIntersectAxis(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(firstPointId);
visual->setPoint2Id(secondPointId);
visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
firstPointId = domElement.attribute(AttrP1Line, "").toUInt();
secondPointId = domElement.attribute(AttrP2Line, "").toUInt();
formulaAngle = domElement.attribute(AttrAngle, "");
}
RefreshGeometry();
if (vis != nullptr)
{
VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis);
visual->setPoint1Id(firstPointId);
visual->setPoint2Id(secondPointId);
visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogLineIntersectAxis>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogLineIntersectAxis>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine());
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId()));
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getFirstPointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getSecondPointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrP1Line, firstPointId);
doc->SetAttribute(tag, AttrP2Line, secondPointId);
}

View File

@ -0,0 +1,82 @@
/************************************************************************
**
** @file vtoollineintersectaxis.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VTOOLLINEINTERSECTAXIS_H
#define VTOOLLINEINTERSECTAXIS_H
#include "vtoollinepoint.h"
class VToolLineIntersectAxis : public VToolLinePoint
{
Q_OBJECT
public:
VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formulaAngle, const quint32 &basePointId, const quint32 &firstPointId,
const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual ~VToolLineIntersectAxis();
virtual void setDialog();
static VToolLineIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data);
static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formulaAngle, const quint32 &basePointId,
const quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static QPointF FindPoint(const QLineF &axis, const QLineF &line);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LineIntersectAxis)};
VFormula getFormulaAngle() const;
void setFormulaAngle(const VFormula &value);
quint32 getFirstPointId() const;
void setFirstPointId(const quint32 &value);
quint32 getSecondPointId() const;
void setSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolLineIntersectAxis)
QString formulaAngle;
quint32 firstPointId;
quint32 secondPointId;
};
#endif // VTOOLLINEINTERSECTAXIS_H

View File

@ -33,7 +33,8 @@ HEADERS += \
tools/vtooluniondetails.h \
tools/drawTools/vtoolcutarc.h \
tools/drawTools/vabstractspline.h \
tools/drawTools/vtoolcut.h
tools/drawTools/vtoolcut.h \
tools/drawTools/vtoollineintersectaxis.h
SOURCES += \
tools/vtooldetail.cpp \
@ -67,4 +68,5 @@ SOURCES += \
tools/vtooluniondetails.cpp \
tools/drawTools/vtoolcutarc.cpp \
tools/drawTools/vabstractspline.cpp \
tools/drawTools/vtoolcut.cpp
tools/drawTools/vtoolcut.cpp \
tools/drawTools/vtoollineintersectaxis.cpp

View File

@ -0,0 +1,142 @@
/************************************************************************
**
** @file vislineintersectaxis.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vistoollineintersectaxis.h"
#include "../container/vcontainer.h"
#include "../geometry/vpointf.h"
#include "../tools/drawTools/vtoollineintersectaxis.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent), point2Id(NULL_ID), axisPointId(NULL_ID), angle(-1), point(nullptr), lineP1(nullptr),
lineP2(nullptr), basePoint(nullptr), baseLine(nullptr), axisLine(nullptr), line_intersection(nullptr)
{
this->mainColor = Qt::red;
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
basePoint = InitPoint(supportColor, this);
baseLine = InitItem<QGraphicsLineItem>(supportColor, this);
axisLine = InitItem<QGraphicsLineItem>(supportColor, this);
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolLineIntersectAxis::~VisToolLineIntersectAxis()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::RefreshGeometry()
{
if (point1Id > 0)
{
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(point1Id);
DrawPoint(lineP1, first->toQPointF(), supportColor);
if (point2Id <= 0)
{
DrawLine(baseLine, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(point2Id);
DrawPoint(lineP2, second->toQPointF(), supportColor);
const QLineF base_line(first->toQPointF(), second->toQPointF());
DrawLine(baseLine, base_line, supportColor);
if (axisPointId > NULL_ID)
{
QLineF axis;
const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(axisPointId);
if (qFuzzyCompare(angle, -1))
{
axis = Axis(third->toQPointF(), Visualization::scenePos);
}
else
{
axis = Axis(third->toQPointF(), angle);
}
DrawPoint(basePoint, third->toQPointF(), mainColor);
DrawLine(axisLine, axis, supportColor, Qt::DashLine);
QPointF p = VToolLineIntersectAxis::FindPoint(axis, base_line);
QLineF axis_line(third->toQPointF(), p);
DrawLine(this, axis_line, mainColor, lineStyle);
DrawPoint(point, p, mainColor);
ShowIntersection(axis_line, base_line);
Visualization::toolTip = QString(tr("<b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - "
"sticking angle, <b>Enter</b> - finish creation"))
.arg(this->line().angle());
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VisToolLineIntersectAxis::Angle() const
{
return QString("%1").arg(this->line().angle());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::setAngle(const QString &expression)
{
angle = FindVal(expression);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::setPoint2Id(const quint32 &value)
{
point2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value)
{
axisPointId = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line)
{
QPointF p;
QLineF::IntersectType intersect = axis_line.intersect(base_line, &p);
if (intersect == QLineF::UnboundedIntersection)
{
line_intersection->setVisible(true);
DrawLine(line_intersection, QLineF(base_line.p1(), axis_line.p2()), supportColor, Qt::DashLine);
}
else if (intersect == QLineF::BoundedIntersection || intersect == QLineF::NoIntersection)
{
line_intersection->setVisible(false);
}
}

View File

@ -0,0 +1,67 @@
/************************************************************************
**
** @file vistoollineintersectaxis.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2014
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2014 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VISTOOLLINEINTERSECTAXIS_H
#define VISTOOLLINEINTERSECTAXIS_H
#include "visline.h"
class QGraphicsEllipseItem;
class VisToolLineIntersectAxis : public VisLine
{
Q_OBJECT
public:
VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolLineIntersectAxis();
virtual void RefreshGeometry();
QString Angle() const;
void setAngle(const QString &expression);
void setPoint2Id(const quint32 &value);
void setAxisPointId(const quint32 &value);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
private:
Q_DISABLE_COPY(VisToolLineIntersectAxis)
quint32 point2Id;
quint32 axisPointId;
qreal angle;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *lineP1;
QGraphicsEllipseItem *lineP2;
QGraphicsEllipseItem *basePoint;
QGraphicsLineItem *baseLine;
QGraphicsLineItem *axisLine;
QGraphicsLineItem *line_intersection;
void ShowIntersection(const QLineF &axis_line, const QLineF &base_line);
};
#endif // VISTOOLLINEINTERSECTAXIS_H

View File

@ -21,7 +21,8 @@ HEADERS += \
visualization/vistoolspline.h \
visualization/vistoolcutspline.h \
visualization/vistoolsplinepath.h \
visualization/vistoolcutsplinepath.h
visualization/vistoolcutsplinepath.h \
visualization/vistoollineintersectaxis.h
SOURCES += \
visualization/vgraphicssimpletextitem.cpp \
@ -46,4 +47,5 @@ SOURCES += \
visualization/vistoolspline.cpp \
visualization/vistoolcutspline.cpp \
visualization/vistoolsplinepath.cpp \
visualization/vistoolcutsplinepath.cpp
visualization/vistoolcutsplinepath.cpp \
visualization/vistoollineintersectaxis.cpp

View File

@ -131,6 +131,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
currentItem = item->parentItem();
ShowItemOptions(currentItem);
break;
case VToolLineIntersectAxis::Type:
ShowOptionsToolLineIntersectAxis(item);
break;
default:
break;
}
@ -206,6 +209,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VControlPointSpline::Type:
ShowItemOptions(currentItem->parentItem());
break;
case VToolLineIntersectAxis::Type:
UpdateOptionsToolLineIntersectAxis();
break;
default:
break;
}
@ -288,6 +294,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolTriangle::Type:
ChangeDataToolTriangle(prop);
break;
case VToolLineIntersectAxis::Type:
ChangeDataToolLineIntersectAxis(prop);
break;
default:
break;
}
@ -842,6 +851,33 @@ void VToolOptionsPropertyBrowser::ChangeDataToolTriangle(VProperty *property)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolLineIntersectAxis(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolLineIntersectAxis *i = qgraphicsitem_cast<VToolLineIntersectAxis *>(currentItem);
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 0: // VAbstractTool::AttrName
SetPointName<VToolLineIntersectAxis>(value.toString());
break;
case 3: // VAbstractTool::AttrTypeLine
i->setTypeLine(value.toString());
break;
case 5: // VAbstractTool::AttrAngle
i->setFormulaAngle(value.value<VFormula>());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
{
@ -1065,6 +1101,18 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolTriangle(QGraphicsItem *item)
AddPropertyPointName(i, tr("Point label"));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersectAxis(QGraphicsItem *item)
{
VToolLineIntersectAxis *i = qgraphicsitem_cast<VToolLineIntersectAxis *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Point intersection line and axis"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"));
AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint()
{
@ -1288,6 +1336,21 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolTriangle()
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis()
{
VToolLineIntersectAxis *i = qgraphicsitem_cast<VToolLineIntersectAxis *>(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
QStringList styles = VAbstractTool::Styles();
qint32 index = styles.indexOf(i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
QVariant valueAngle;
valueAngle.setValue(i->getFormulaAngle());
idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
{

View File

@ -94,6 +94,7 @@ private:
void ChangeDataToolSpline(VPE::VProperty *property);
void ChangeDataToolSplinePath(VPE::VProperty *property);
void ChangeDataToolTriangle(VPE::VProperty *property);
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
void ShowOptionsToolEndLine(QGraphicsItem *item);
@ -113,6 +114,7 @@ private:
void ShowOptionsToolSpline(QGraphicsItem *item);
void ShowOptionsToolSplinePath(QGraphicsItem *item);
void ShowOptionsToolTriangle(QGraphicsItem *item);
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
void UpdateOptionsToolSinglePoint();
void UpdateOptionsToolEndLine();
@ -132,6 +134,7 @@ private:
void UpdateOptionsToolSpline();
void UpdateOptionsToolSplinePath();
void UpdateOptionsToolTriangle();
void UpdateOptionsToolLineIntersectAxis();
};
#endif // VTOOLOPTIONSPROPERTYBROWSER_H

View File

@ -1077,7 +1077,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
<< VToolLineIntersect::ToolType << VToolPointOfContact::ToolType
<< VNodePoint::ToolType << VToolHeight::ToolType << VToolTriangle::ToolType
<< VToolPointOfIntersection::ToolType << VToolCutSpline::ToolType
<< VToolCutSplinePath::ToolType << VToolCutArc::ToolType;
<< VToolCutSplinePath::ToolType << VToolCutArc::ToolType
<< VToolLineIntersectAxis::ToolType;
switch (points.indexOf(type))
{
case 0: //VToolSinglePoint::ToolType
@ -1489,6 +1490,42 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
throw excep;
}
break;
case 15: //VToolLineIntersectAxis::ToolType
try
{
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0");
QString angleFix = angle;
VToolLineIntersectAxis::Create(id, name, typeLine, angleFix, basePointId, firstPointId, secondPointId,
mx, my, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (angleFix != angle)
{
SetAttribute(domElement, VAbstractTool::AttrAngle, angleFix);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"),
domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
catch (qmu::QmuParserError &e)
{
VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"),
domElement);
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
throw excep;
}
break;
default:
qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
break;