Merge with feature
--HG-- branch : develop
This commit is contained in:
commit
7c268f2544
|
@ -579,7 +579,6 @@ QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const
|
|||
/*We found loop.*/
|
||||
ekvPoints.append(points.at(i));
|
||||
ekvPoints.append(crosPoint);
|
||||
ekvPoints.append(points.at(j+1));
|
||||
i = j + 2;
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +773,7 @@ void VContainer::UpdateGObject(qint64 id, VGObject* obj)
|
|||
UpdateObject(gObjects, id, obj);
|
||||
}
|
||||
|
||||
void VContainer::UpdateDetail(qint64 id, VDetail detail)
|
||||
void VContainer::UpdateDetail(qint64 id, const VDetail &detail)
|
||||
{
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
details[id] = detail;
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
* @param id id of existing detail
|
||||
* @param detail detail
|
||||
*/
|
||||
void UpdateDetail(qint64 id, VDetail detail);
|
||||
void UpdateDetail(qint64 id, const VDetail &detail);
|
||||
/**
|
||||
* @brief UpdateStandartTableCell update standart table row by name
|
||||
* @param name name of row
|
||||
|
@ -279,6 +279,7 @@ public:
|
|||
* @brief ClearLineAngles clear angles of lines
|
||||
*/
|
||||
inline void ClearLineAngles() {lineAngles.clear();}
|
||||
inline void ClearDetails() {details.clear();}
|
||||
/**
|
||||
* @brief SetSize set value of size
|
||||
* @param size value of size in mm
|
||||
|
|
|
@ -56,6 +56,8 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
|
|||
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
|
||||
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
|
||||
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
|
||||
|
||||
connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem);
|
||||
}
|
||||
|
||||
void DialogDetail::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
||||
|
@ -80,6 +82,7 @@ void DialogDetail::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
qWarning()<<tr("Got wrong scene object. Ignore.");
|
||||
break;
|
||||
}
|
||||
ui.toolButtonDelete->setEnabled(true);
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
|
@ -165,9 +168,12 @@ void DialogDetail::setDetails(const VDetail &value)
|
|||
ui.lineEditNameDetail->setText(details.getName());
|
||||
ui.checkBoxSeams->setChecked(details.getSupplement());
|
||||
ui.checkBoxClosed->setChecked(details.getClosed());
|
||||
ClickedClosed(details.getClosed());
|
||||
ClickedSeams(details.getSupplement());
|
||||
ui.doubleSpinBoxSeams->setValue(details.getWidth());
|
||||
ui.listWidget->setCurrentRow(0);
|
||||
ui.listWidget->setFocus(Qt::OtherFocusReason);
|
||||
ui.toolButtonDelete->setEnabled(true);
|
||||
}
|
||||
|
||||
void DialogDetail::BiasXChanged(qreal d)
|
||||
|
@ -213,3 +219,9 @@ void DialogDetail::ObjectChanged(int row)
|
|||
ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx()));
|
||||
ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy()));
|
||||
}
|
||||
|
||||
void DialogDetail::DeleteItem()
|
||||
{
|
||||
qint32 row = ui.listWidget->currentRow();
|
||||
delete ui.listWidget->item( row );
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ public slots:
|
|||
* @param row number of row
|
||||
*/
|
||||
void ObjectChanged(int row);
|
||||
void DeleteItem();
|
||||
private:
|
||||
/**
|
||||
* @brief ui keeps information about user interface
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>327</height>
|
||||
<width>565</width>
|
||||
<height>324</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -211,6 +211,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButtonDelete">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -232,6 +232,29 @@ VDetail VDetail::RemoveEdge(const ptrdiff_t &index) const
|
|||
return det;
|
||||
}
|
||||
|
||||
QList<qint64> VDetail::Missing(const VDetail &det) const
|
||||
{
|
||||
QList<qint64> list;
|
||||
if(nodes.size() == det.CountNode())
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
qint32 j = 0;
|
||||
for(qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
if(nodes[i].getId() == det.at(j).getId())
|
||||
{
|
||||
++j;
|
||||
}
|
||||
else
|
||||
{
|
||||
list.append(nodes[i].getId());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
QVector<VNodeDetail> VDetail::listNodePoint() const
|
||||
{
|
||||
QVector<VNodeDetail> list;
|
||||
|
|
|
@ -183,6 +183,7 @@ public:
|
|||
ptrdiff_t Edge(const qint64 &p1, const qint64 &p2)const;
|
||||
void NodeOnEdge(const ptrdiff_t &index, VNodeDetail &p1, VNodeDetail &p2)const;
|
||||
VDetail RemoveEdge(const ptrdiff_t &index) const;
|
||||
QList<qint64> Missing(const VDetail &det) const;
|
||||
private:
|
||||
qint64 _id;
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
dialogCutSpline(QSharedPointer<DialogCutSpline>()), dialogCutSplinePath (QSharedPointer<DialogCutSplinePath>()),
|
||||
dialogUnionDetails(QSharedPointer<DialogUnionDetails>()), dialogCutArc(QSharedPointer<DialogCutArc>()),
|
||||
dialogHistory(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
||||
mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0)
|
||||
mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
static const char * GENERIC_ICON_TO_CHECK = "document-open";
|
||||
|
@ -701,6 +701,7 @@ void MainWindow::ToolBarDraws()
|
|||
|
||||
ui->toolBarDraws->addAction(ui->actionLayout);
|
||||
connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout);
|
||||
ui->actionLayout->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::currentDrawChanged( int index )
|
||||
|
@ -709,6 +710,9 @@ void MainWindow::currentDrawChanged( int index )
|
|||
{
|
||||
doc->setCurrentData();
|
||||
doc->ChangeActivDraw(comboBoxDraws->itemText(index));
|
||||
if(drawMode)
|
||||
{
|
||||
ArrowTool();
|
||||
qint64 id = doc->SPointActiveDraw();
|
||||
if (id != 0)
|
||||
{
|
||||
|
@ -716,6 +720,7 @@ void MainWindow::currentDrawChanged( int index )
|
|||
view->centerOn(p->toQPointF());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mouseMove(const QPointF &scenePos)
|
||||
|
@ -915,15 +920,22 @@ void MainWindow::ActionDraw(bool checked)
|
|||
|
||||
currentScene = sceneDraw;
|
||||
view->setScene(currentScene);
|
||||
connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
|
||||
RestoreCurrentScene();
|
||||
|
||||
mode = Draw::Calculation;
|
||||
comboBoxDraws->setEnabled(true);
|
||||
comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace
|
||||
drawMode = true;
|
||||
|
||||
SetEnableTool(true);
|
||||
doc->setCurrentData();
|
||||
ui->toolBox->setCurrentIndex(currentToolBoxIndex);
|
||||
|
||||
ui->actionHistory->setEnabled(true);
|
||||
ui->actionLayout->setEnabled(false);
|
||||
ui->actionOptionDraw->setEnabled(true);
|
||||
ui->actionNewDraw->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -940,16 +952,24 @@ void MainWindow::ActionDetails(bool checked)
|
|||
|
||||
currentScene = sceneDetails;
|
||||
view->setScene(sceneDetails);
|
||||
disconnect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
|
||||
RestoreCurrentScene();
|
||||
|
||||
drawMode = false;
|
||||
currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern peace
|
||||
comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1);
|
||||
comboBoxDraws->setEnabled(false);
|
||||
|
||||
|
||||
mode = Draw::Modeling;
|
||||
SetEnableTool(true);
|
||||
currentToolBoxIndex = ui->toolBox->currentIndex();
|
||||
ui->toolBox->setCurrentIndex(4);
|
||||
|
||||
ui->actionHistory->setEnabled(false);
|
||||
ui->actionLayout->setEnabled(true);
|
||||
ui->actionOptionDraw->setEnabled(false);
|
||||
ui->actionNewDraw->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1014,10 +1034,26 @@ void MainWindow::ActionOpen()
|
|||
if (fileName.isEmpty() && changeInFile == false)
|
||||
{
|
||||
OpenPattern(fName);
|
||||
sceneDraw->setSceneRect(QRectF(0, 0, view->contentsRect().width()-view->contentsRect().x(),
|
||||
view->contentsRect().height()-view->contentsRect().y()));
|
||||
sceneDetails->setSceneRect(QRectF(0, 0, view->contentsRect().width()-view->contentsRect().x(),
|
||||
view->contentsRect().height()-view->contentsRect().y()));
|
||||
|
||||
QRectF rect = sceneDraw->itemsBoundingRect();
|
||||
//Correct BoundingRect
|
||||
rect = QRectF(0, 0, rect.width() + rect.x(), rect.height() + rect.y());
|
||||
|
||||
QRect rec = view->contentsRect();
|
||||
//Correct contentsRect
|
||||
rec = QRect(0, 0, rec.width() - rec.x(), rec.height() - rec.y());
|
||||
|
||||
if(rec.contains(rect.toRect()))
|
||||
{
|
||||
sceneDraw->setSceneRect(rec);
|
||||
sceneDetails->setSceneRect(rec);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = rect.united(rec);
|
||||
sceneDraw->setSceneRect(rect);
|
||||
sceneDetails->setSceneRect(rect);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -511,6 +511,7 @@ private:
|
|||
Draw::Draws mode;
|
||||
qint32 currentDrawIndex;
|
||||
qint32 currentToolBoxIndex;
|
||||
bool drawMode;
|
||||
/**
|
||||
* @brief ToolBarOption
|
||||
*/
|
||||
|
|
|
@ -115,23 +115,31 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
|
|||
|
||||
QGraphicsScene *sc = this->scene();
|
||||
QRectF rect = sc->itemsBoundingRect();
|
||||
//Correct BoundingRect
|
||||
rect = QRectF(0, 0, rect.width() + rect.x(), rect.height() + rect.y());
|
||||
|
||||
QList<QGraphicsView*> list = sc->views();
|
||||
QRect rec = list[0]->contentsRect();
|
||||
//Correct contentsRect
|
||||
rec = QRect(0, 0, rec.width() - rec.x(), rec.height() - rec.y());
|
||||
QRect rec0 = list[0]->rect();
|
||||
rec0 = QRect(0, 0, rec0.width()-2, rec0.height()-2);
|
||||
|
||||
if(rec.contains(rect.toRect()))
|
||||
QTransform t = list[0]->transform();
|
||||
|
||||
QRectF rec1;
|
||||
if(t.m11() < 1)
|
||||
{
|
||||
sc->setSceneRect(rec);
|
||||
rec1 = QRect(0, 0, rec0.width()/t.m11(), rec0.height()/t.m22());
|
||||
|
||||
rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y());
|
||||
QPolygonF polygone = list[0]->mapToScene(rec1.toRect());
|
||||
rec1 = polygone.boundingRect();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = rect.united(rec);
|
||||
sc->setSceneRect(rect);
|
||||
rec1 = rec0;
|
||||
}
|
||||
|
||||
rec1 = rec1.united(rect.toRect());
|
||||
sc->setSceneRect(rec1);
|
||||
|
||||
//I don't now why but signal does not work.
|
||||
doc->FullUpdateTree();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,40 @@ VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, const qint64 &
|
|||
_referens = 0;
|
||||
}
|
||||
|
||||
void VAbstractNode::DeleteNode()
|
||||
{
|
||||
if (_referens <= 1)
|
||||
{
|
||||
//remove from xml file
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QDomNode element = domElement.parentNode();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
if (element.isElement())
|
||||
{
|
||||
RemoveReferens();//deincrement referens
|
||||
element.removeChild(domElement);//remove form file
|
||||
emit toolhaveChange();//set enabled save button
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"parent isn't element"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"parent isNull"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't get element by id form file = "<<id<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VAbstractNode::AddToModeling(const QDomElement &domElement)
|
||||
{
|
||||
QDomElement modelingElement;
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
*/
|
||||
static const QString AttrIdObject;
|
||||
static const QString AttrIdTool;
|
||||
virtual void DeleteNode();
|
||||
protected:
|
||||
/**
|
||||
* @brief idNode
|
||||
|
|
|
@ -78,6 +78,12 @@ void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idA
|
|||
}
|
||||
}
|
||||
|
||||
void VNodeArc::DeleteNode()
|
||||
{
|
||||
VAbstractNode::DeleteNode();
|
||||
this->setVisible(false);
|
||||
}
|
||||
|
||||
void VNodeArc::FullUpdateFromFile()
|
||||
{
|
||||
RefreshGeometry();
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
* @brief ToolType
|
||||
*/
|
||||
static const QString ToolType;
|
||||
virtual void DeleteNode();
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile
|
||||
|
|
|
@ -89,6 +89,12 @@ void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 i
|
|||
}
|
||||
}
|
||||
|
||||
void VNodePoint::DeleteNode()
|
||||
{
|
||||
VAbstractNode::DeleteNode();
|
||||
this->setVisible(false);
|
||||
}
|
||||
|
||||
void VNodePoint::FullUpdateFromFile()
|
||||
{
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
* @brief ToolType
|
||||
*/
|
||||
static const QString ToolType;
|
||||
virtual void DeleteNode();
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile
|
||||
|
|
|
@ -81,6 +81,12 @@ VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id,
|
|||
return spl;
|
||||
}
|
||||
|
||||
void VNodeSpline::DeleteNode()
|
||||
{
|
||||
VAbstractNode::DeleteNode();
|
||||
this->setVisible(false);
|
||||
}
|
||||
|
||||
void VNodeSpline::FullUpdateFromFile()
|
||||
{
|
||||
RefreshGeometry();
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
* @brief ToolType
|
||||
*/
|
||||
static const QString ToolType;
|
||||
virtual void DeleteNode();
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile
|
||||
|
|
|
@ -85,6 +85,12 @@ void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qin
|
|||
}
|
||||
}
|
||||
|
||||
void VNodeSplinePath::DeleteNode()
|
||||
{
|
||||
VAbstractNode::DeleteNode();
|
||||
this->setVisible(false);
|
||||
}
|
||||
|
||||
void VNodeSplinePath::FullUpdateFromFile()
|
||||
{
|
||||
RefreshGeometry();
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
* @brief ToolType
|
||||
*/
|
||||
static const QString ToolType;
|
||||
virtual void DeleteNode();
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile
|
||||
|
|
|
@ -178,6 +178,7 @@ void VAbstractTool::RemoveAllChild(QDomElement &domElement)
|
|||
}
|
||||
}
|
||||
|
||||
//TODO see method deleteNode. I think no need have QGraphicsItem. QObject can delete yourself.
|
||||
void VAbstractTool::DeleteTool(QGraphicsItem *tool)
|
||||
{
|
||||
if (_referens <= 1)
|
||||
|
@ -198,7 +199,8 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool)
|
|||
{
|
||||
scene->removeItem(tool);//remove form scene
|
||||
}
|
||||
emit toolhaveChange();//set enabled save button
|
||||
doc->FullUpdateTree();
|
||||
//emit toolhaveChange();//set enabled save button
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -185,6 +185,17 @@ void VToolDetail::FullUpdateFromGui(int result)
|
|||
{
|
||||
AddNode(domElement, det[i]);
|
||||
}
|
||||
VDetail detail = VAbstractTool::data.GetDetail(id);
|
||||
QList<qint64> list = detail.Missing(det);
|
||||
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
||||
if(list.size()>0)
|
||||
{
|
||||
for(qint32 i = 0; i < list.size(); ++i)
|
||||
{
|
||||
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(list[i]));
|
||||
node->DeleteNode();
|
||||
}
|
||||
}
|
||||
emit FullUpdateTree();
|
||||
}
|
||||
}
|
||||
|
@ -247,6 +258,34 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
|
|||
{
|
||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x())));
|
||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y())));
|
||||
|
||||
QGraphicsScene *sc = this->scene();
|
||||
QRectF rect = sc->itemsBoundingRect();
|
||||
|
||||
QList<QGraphicsView*> list = sc->views();
|
||||
QRect rec0 = list[0]->rect();
|
||||
rec0 = QRect(0, 0, rec0.width()-2, rec0.height()-2);
|
||||
|
||||
QTransform t = list[0]->transform();
|
||||
|
||||
QRectF rec1;
|
||||
if(t.m11() < 1)
|
||||
{
|
||||
rec1 = QRect(0, 0, rec0.width()/t.m11(), rec0.height()/t.m22());
|
||||
|
||||
rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y());
|
||||
QPolygonF polygone = list[0]->mapToScene(rec1.toRect());
|
||||
rec1 = polygone.boundingRect();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rec1 = rec0;
|
||||
}
|
||||
|
||||
rec1 = rec1.united(rect.toRect());
|
||||
sc->setSceneRect(rec1);
|
||||
|
||||
doc->haveLiteChange();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,10 +139,10 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
|
|||
BiasRotatePoint(p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP1 = data->AddGObject(p1);
|
||||
|
||||
VPointF p2 = VPointF(spline->GetP2().x(), spline->GetP2().y(), "A", 0, 0);
|
||||
VPointF p2 = VPointF(spline->GetP2());
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF p3 = VPointF(spline->GetP3().x(), spline->GetP3().y(), "A", 0, 0);
|
||||
VPointF p3 = VPointF(spline->GetP3());
|
||||
BiasRotatePoint(&p3, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF *p4 = new VPointF(spline->GetP4());
|
||||
|
@ -150,9 +150,9 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
|
|||
BiasRotatePoint(p4, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP4 = data->AddGObject(p4);
|
||||
|
||||
VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve());
|
||||
VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0,
|
||||
Draw::Modeling);
|
||||
Q_ASSERT(spl != 0);
|
||||
spl->setMode(Draw::Modeling);
|
||||
idObject = data->AddGObject(spl);
|
||||
|
||||
VSpline *spl1 = new VSpline(*spl);
|
||||
|
@ -208,10 +208,10 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
|
|||
if (i==1)
|
||||
{
|
||||
path->append(VSplinePoint(*p1, splinePath->at(i-1).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i-1).KAsm1()));
|
||||
splinePath->at(i-1).KAsm2()));
|
||||
}
|
||||
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i).KAsm1()));
|
||||
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle2()+180,
|
||||
splinePath->at(i).KAsm2()));
|
||||
}
|
||||
while(k>=0)
|
||||
{
|
||||
|
@ -310,9 +310,10 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
|||
++idCount;
|
||||
data->UpdateGObject(idDetail+idCount, p4);
|
||||
|
||||
VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve());
|
||||
VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0,
|
||||
Draw::Modeling);
|
||||
|
||||
Q_ASSERT(spl != 0);
|
||||
spl->setMode(Draw::Modeling);
|
||||
++idCount;
|
||||
data->UpdateGObject(idDetail+idCount, spl);
|
||||
|
||||
|
@ -364,10 +365,10 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
|||
if (i==1)
|
||||
{
|
||||
path->append(VSplinePoint(*p1, splinePath->at(i-1).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i-1).KAsm1()));
|
||||
splinePath->at(i-1).KAsm2()));
|
||||
}
|
||||
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i).KAsm1()));
|
||||
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle2()+180,
|
||||
splinePath->at(i).KAsm2()));
|
||||
}
|
||||
|
||||
while(k>=0)
|
||||
|
|
|
@ -31,10 +31,14 @@
|
|||
#include <QtWidgets>
|
||||
|
||||
VMainGraphicsScene::VMainGraphicsScene()
|
||||
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()){}
|
||||
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform())
|
||||
{
|
||||
}
|
||||
|
||||
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent)
|
||||
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()){}
|
||||
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform())
|
||||
{
|
||||
}
|
||||
|
||||
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
|
|
|
@ -43,19 +43,26 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
|||
|
||||
void VMainGraphicsView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int numDegrees = event->delta() / 8;
|
||||
int numSteps = numDegrees / 15; // see QWheelEvent documentation
|
||||
int numSteps = event->delta() / 8 / 15; // see QWheelEvent documentation
|
||||
|
||||
_numScheduledScalings += numSteps;
|
||||
if (_numScheduledScalings * numSteps < 0)
|
||||
{ // if user moved the wheel in another direction, we reset
|
||||
_numScheduledScalings = numSteps; // previously scheduled scalings
|
||||
}
|
||||
|
||||
QTimeLine *anim = new QTimeLine(350, this);
|
||||
QTimeLine *anim = new QTimeLine(300, this);
|
||||
Q_ASSERT(anim != 0);
|
||||
anim->setUpdateInterval(20);
|
||||
|
||||
if (QApplication::keyboardModifiers() == Qt::ControlModifier)
|
||||
{// If you press CTRL this code will be executed
|
||||
connect(anim, &QTimeLine::valueChanged, this, &VMainGraphicsView::scalingTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(anim, &QTimeLine::valueChanged, this, &VMainGraphicsView::scrollingTime);
|
||||
}
|
||||
connect(anim, &QTimeLine::finished, this, &VMainGraphicsView::animFinished);
|
||||
anim->start();
|
||||
}
|
||||
|
@ -63,15 +70,49 @@ void VMainGraphicsView::wheelEvent(QWheelEvent *event)
|
|||
void VMainGraphicsView::scalingTime(qreal x)
|
||||
{
|
||||
Q_UNUSED(x);
|
||||
qreal factor = 1.0;
|
||||
if (QApplication::keyboardModifiers() == Qt::ControlModifier)
|
||||
{// If you press CTRL this code will be executed
|
||||
factor = 1.0 + static_cast<qreal>(_numScheduledScalings) / 300.0;
|
||||
const QPointF p0scene = mapToScene(mapFromGlobal(QCursor::pos()));
|
||||
|
||||
qreal factor = 1.0 + static_cast<qreal>(_numScheduledScalings) / 50.0;
|
||||
scale(factor, factor);
|
||||
emit NewFactor(factor);
|
||||
|
||||
const QPointF p1mouse = mapFromScene(p0scene);
|
||||
const QPointF move = p1mouse - this->mapFromGlobal(QCursor::pos()); // The move
|
||||
horizontalScrollBar()->setValue(move.x() + horizontalScrollBar()->value());
|
||||
verticalScrollBar()->setValue(move.y() + verticalScrollBar()->value());
|
||||
|
||||
QGraphicsScene *sc = this->scene();
|
||||
QRectF rect = sc->itemsBoundingRect();
|
||||
|
||||
QRect rec0 = this->rect();
|
||||
rec0 = QRect(0, 0, rec0.width()-2, rec0.height()-2);
|
||||
|
||||
QTransform t = this->transform();
|
||||
|
||||
QRectF rec1;
|
||||
if(t.m11() < 1)
|
||||
{
|
||||
rec1 = QRect(0, 0, rec0.width()/t.m11(), rec0.height()/t.m22());
|
||||
|
||||
rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y());
|
||||
QPolygonF polygone = this->mapToScene(rec1.toRect());
|
||||
rec1 = polygone.boundingRect();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rec1 = rec0;
|
||||
}
|
||||
|
||||
rec1 = rec1.united(rect.toRect());
|
||||
sc->setSceneRect(rec1);
|
||||
|
||||
emit NewFactor(factor);
|
||||
}
|
||||
|
||||
void VMainGraphicsView::scrollingTime(qreal x)
|
||||
{
|
||||
Q_UNUSED(x);
|
||||
qreal factor = 1.0;
|
||||
if (_numScheduledScalings < 0)
|
||||
{
|
||||
verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() + factor*3.5));
|
||||
|
@ -79,12 +120,11 @@ void VMainGraphicsView::scalingTime(qreal x)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (verticalScrollBar()->value() > 0)
|
||||
{
|
||||
// if (verticalScrollBar()->value() > 0)
|
||||
// {
|
||||
verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() - factor*3.5));
|
||||
emit NewFactor(factor);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ public slots:
|
|||
* @param x
|
||||
*/
|
||||
void scalingTime(qreal x);
|
||||
void scrollingTime(qreal x);
|
||||
/**
|
||||
* @brief animFinished
|
||||
*/
|
||||
|
|
|
@ -350,6 +350,7 @@ void VDomDocument::Parse(const Document::Documents &parse, VMainGraphicsScene *s
|
|||
data->ClearLengthArcs();
|
||||
data->ClearLengthSplines();
|
||||
data->ClearLineAngles();
|
||||
data->ClearDetails();
|
||||
history.clear();
|
||||
QDomElement rootElement = this->documentElement();
|
||||
QDomNode domNode = rootElement.firstChild();
|
||||
|
|
Loading…
Reference in New Issue
Block a user