Fixed issue #68.

--HG--
branch : develop
This commit is contained in:
dismine 2014-02-12 12:55:24 +02:00
parent 8e4e48c0d7
commit abb541ba68
8 changed files with 186 additions and 61 deletions

View File

@ -64,6 +64,7 @@
<xs:attribute name="id" type="xs:long" use="required"></xs:attribute> <xs:attribute name="id" type="xs:long" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:long"></xs:attribute> <xs:attribute name="firstPoint" type="xs:long"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:long"></xs:attribute> <xs:attribute name="secondPoint" type="xs:long"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded"> <xs:element name="arc" minOccurs="0" maxOccurs="unbounded">

View File

@ -32,7 +32,7 @@
#include <QPushButton> #include <QPushButton>
DialogLine::DialogLine(const VContainer *data, QWidget *parent) DialogLine::DialogLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0) :DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString())
{ {
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -42,6 +42,7 @@ DialogLine::DialogLine(const VContainer *data, QWidget *parent)
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxTypeLine(ui->comboBoxLineType);
number = 0; number = 0;
} }
@ -62,6 +63,12 @@ void DialogLine::setSecondPoint(const qint64 &value)
} }
} }
void DialogLine::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
void DialogLine::setFirstPoint(const qint64 &value) void DialogLine::setFirstPoint(const qint64 &value)
{ {
firstPoint = value; firstPoint = value;
@ -80,6 +87,7 @@ void DialogLine::DialogAccepted()
firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index)); firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index));
index = ui->comboBoxSecondPoint->currentIndex(); index = ui->comboBoxSecondPoint->currentIndex();
secondPoint = qvariant_cast<qint64>(ui->comboBoxSecondPoint->itemData(index)); secondPoint = qvariant_cast<qint64>(ui->comboBoxSecondPoint->itemData(index));
typeLine = GetTypeLine(ui->comboBoxLineType);
DialogClosed(QDialog::Accepted); DialogClosed(QDialog::Accepted);
} }

View File

@ -70,6 +70,16 @@ public:
* @param value id * @param value id
*/ */
void setSecondPoint(const qint64 &value); void setSecondPoint(const qint64 &value);
/**
* @brief getTypeLine return type of line
* @return type
*/
inline QString getTypeLine() const {return typeLine;}
/**
* @brief setTypeLine set type of line
* @param value type
*/
void setTypeLine(const QString &value);
public slots: public slots:
/** /**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
@ -99,6 +109,10 @@ private:
* @brief secondPoint id second point * @brief secondPoint id second point
*/ */
qint64 secondPoint; qint64 secondPoint;
/**
* @brief typeLine type of line
*/
QString typeLine;
}; };
#endif // DIALOGLINE_H #endif // DIALOGLINE_H

View File

@ -6,32 +6,60 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>217</width> <width>267</width>
<height>137</height> <height>154</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Line</string> <string>Line</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../icon.qrc"> <iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset> <normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property> </property>
<property name="locale"> <property name="locale">
<locale language="English" country="UnitedStates"/> <locale language="English" country="UnitedStates"/>
</property> </property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>255</width>
<height>134</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>First point</string> <string>First point</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBoxFirstPoint"/> <widget class="QComboBox" name="comboBoxFirstPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -39,13 +67,68 @@
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Second point</string> <string>Second point</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBoxSecondPoint"/> <widget class="QComboBox" name="comboBoxSecondPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Type of line</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxLineType">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Show line from first point to this point</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -61,13 +144,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<tabstops> <tabstops>
<tabstop>comboBoxFirstPoint</tabstop> <tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop> <tabstop>comboBoxSecondPoint</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../icon.qrc"/> <include location="../../share/resources/icon.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -902,7 +902,15 @@ void MainWindow::ActionDetails(bool checked)
bool MainWindow::SaveAs() bool MainWindow::SaveAs()
{ {
QString filters(tr("Pattern files (*.val)")); QString filters(tr("Pattern files (*.val)"));
QString dir = QFileInfo(curFile).absolutePath() + tr("/pattern.val"); QString dir;
if (curFile.isEmpty())
{
dir = QDir::homePath() + tr("/pattern.val");
}
else
{
dir = QFileInfo(curFile).absolutePath() + tr("/pattern.val");
}
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters); QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters);
if (fileName.isEmpty()) if (fileName.isEmpty())

View File

@ -32,9 +32,10 @@
const QString VToolLine::TagName = QStringLiteral("line"); const QString VToolLine::TagName = QStringLiteral("line");
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
const Tool::Sources &typeCreation, QGraphicsItem *parent) const QString &typeLine, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint) :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint)
{ {
this->typeLine = typeLine;
ignoreFullUpdate = true; ignoreFullUpdate = true;
//Line //Line
const VPointF *first = data->GeometricObject<const VPointF *>(firstPoint); const VPointF *first = data->GeometricObject<const VPointF *>(firstPoint);
@ -44,7 +45,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, widthHairLine/factor)); this->setPen(QPen(Qt::black, widthHairLine/factor, LineStyle()));
if (typeCreation == Tool::FromGui) if (typeCreation == Tool::FromGui)
{ {
@ -63,6 +64,7 @@ void VToolLine::setDialog()
Q_CHECK_PTR(dialogTool); Q_CHECK_PTR(dialogTool);
dialogTool->setFirstPoint(firstPoint); dialogTool->setFirstPoint(firstPoint);
dialogTool->setSecondPoint(secondPoint); dialogTool->setSecondPoint(secondPoint);
dialogTool->setTypeLine(typeLine);
} }
void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data)
@ -72,10 +74,11 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocume
Q_CHECK_PTR(dialogTool); Q_CHECK_PTR(dialogTool);
qint64 firstPoint = dialogTool->getFirstPoint(); qint64 firstPoint = dialogTool->getFirstPoint();
qint64 secondPoint = dialogTool->getSecondPoint(); qint64 secondPoint = dialogTool->getSecondPoint();
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui); QString typeLine = dialogTool->getTypeLine();
Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Tool::FromGui);
} }
void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, const QString &typeLine,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation) const Document::Documents &parse, const Tool::Sources &typeCreation)
{ {
@ -100,7 +103,7 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
VDrawTool::AddRecord(id, Tool::LineTool, doc); VDrawTool::AddRecord(id, Tool::LineTool, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation); VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, typeCreation);
Q_CHECK_PTR(line); Q_CHECK_PTR(line);
scene->addItem(line); scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@ -140,7 +143,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
selectable = false; selectable = false;
currentColor = Qt::gray; currentColor = Qt::gray;
} }
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
this->setAcceptHoverEvents (selectable); this->setAcceptHoverEvents (selectable);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
@ -156,6 +159,7 @@ void VToolLine::AddToFile()
SetAttribute(domElement, AttrId, id); SetAttribute(domElement, AttrId, id);
SetAttribute(domElement, AttrFirstPoint, firstPoint); SetAttribute(domElement, AttrFirstPoint, firstPoint);
SetAttribute(domElement, AttrSecondPoint, secondPoint); SetAttribute(domElement, AttrSecondPoint, secondPoint);
SetAttribute(domElement, AttrTypeLine, typeLine);
AddToCalculation(domElement); AddToCalculation(domElement);
} }
@ -167,19 +171,20 @@ void VToolLine::RefreshDataInFile()
{ {
SetAttribute(domElement, AttrFirstPoint, firstPoint); SetAttribute(domElement, AttrFirstPoint, firstPoint);
SetAttribute(domElement, AttrSecondPoint, secondPoint); SetAttribute(domElement, AttrSecondPoint, secondPoint);
SetAttribute(domElement, AttrTypeLine, typeLine);
} }
} }
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine/factor)); this->setPen(QPen(currentColor, widthMainLine/factor, LineStyle()));
} }
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
} }
void VToolLine::RemoveReferens() void VToolLine::RemoveReferens()
@ -226,6 +231,7 @@ void VToolLine::SaveDialog(QDomElement &domElement)
Q_CHECK_PTR(dialogTool); Q_CHECK_PTR(dialogTool);
SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint()));
SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint()));
SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine());
} }
void VToolLine::RefreshGeometry() void VToolLine::RefreshGeometry()
@ -233,11 +239,12 @@ void VToolLine::RefreshGeometry()
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement()) if (domElement.isElement())
{ {
firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong(); firstPoint = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong(); secondPoint = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
} }
const VPointF *first = VAbstractTool::data.GeometricObject<const VPointF *>(firstPoint); const VPointF *first = VAbstractTool::data.GeometricObject<const VPointF *>(firstPoint);
const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint); const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF())); this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
} }

View File

@ -47,11 +47,13 @@ public:
* @param id object id in container. * @param id object id in container.
* @param firstPoint id first line point. * @param firstPoint id first line point.
* @param secondPoint id second line point. * @param secondPoint id second line point.
* @param typeLine line type.
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
* @param parent parent object. * @param parent parent object.
*/ */
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); qint64 secondPoint, const QString &typeLine, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/** /**
* @brief setDialog set dialog when user want change tool option. * @brief setDialog set dialog when user want change tool option.
*/ */
@ -69,13 +71,14 @@ public:
* @param _id tool id, 0 if tool doesn't exist yet. * @param _id tool id, 0 if tool doesn't exist yet.
* @param firstPoint id first line point. * @param firstPoint id first line point.
* @param secondPoint id second line point. * @param secondPoint id second line point.
* @param typeLine line type.
* @param scene pointer to scene. * @param scene pointer to scene.
* @param doc dom document container. * @param doc dom document container.
* @param data container with variables. * @param data container with variables.
* @param parse parser file mode. * @param parse parser file mode.
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, const QString &typeLine,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation); const Document::Documents &parse, const Tool::Sources &typeCreation);
static const QString TagName; static const QString TagName;

View File

@ -1100,8 +1100,9 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
qint64 id = GetParametrId(domElement); qint64 id = GetParametrId(domElement);
qint64 firstPoint = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); qint64 firstPoint = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
qint64 secondPoint = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); qint64 secondPoint = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile); VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Tool::FromFile);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {