Вертикальное и горизонтальное выравнивание
This commit is contained in:
16
Canvas.cpp
16
Canvas.cpp
@@ -81,9 +81,23 @@ void Canvas::mousePressEvent(QMouseEvent* event)
|
|||||||
if (p) {
|
if (p) {
|
||||||
draggedPoint = p;
|
draggedPoint = p;
|
||||||
dragOffset = scene - QPointF(*p->x, *p->y);
|
dragOffset = scene - QPointF(*p->x, *p->y);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (mode == Mode::Horizontal || mode == Mode::Vertical) {
|
||||||
|
Line* found = findAt(scene);
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
if (mode == Mode::Horizontal)
|
||||||
|
sys.addConstraintHorizontal(*found, constraints_count++);
|
||||||
|
else
|
||||||
|
sys.addConstraintVertical(*found, constraints_count++);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
mode = Mode::None;
|
||||||
|
after_constraint = true;
|
||||||
|
}
|
||||||
|
|
||||||
else if (mode == Mode::DrawingLine) {
|
else if (mode == Mode::DrawingLine) {
|
||||||
if (!current_line) {
|
if (!current_line) {
|
||||||
current_line = new Line();
|
current_line = new Line();
|
||||||
|
|||||||
4
Canvas.h
4
Canvas.h
@@ -19,7 +19,9 @@ enum class Mode : int
|
|||||||
None = 0,
|
None = 0,
|
||||||
DrawingLine = 1,
|
DrawingLine = 1,
|
||||||
Parallel = 2,
|
Parallel = 2,
|
||||||
Coincedent = 3
|
Coincedent = 3,
|
||||||
|
Horizontal = 4,
|
||||||
|
Vertical = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
// Удобный тип для хранения пары параллельных линий (порядок не важен)
|
// Удобный тип для хранения пары параллельных линий (порядок не важен)
|
||||||
|
|||||||
@@ -30,8 +30,13 @@ void DRAWer_2_0::on_P2P_Button_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DRAWer_2_0::on_FIX_Button_clicked()
|
void DRAWer_2_0::on_Horizontal_Button_clicked()
|
||||||
{
|
{
|
||||||
|
ui.widget->changeMode(Mode::Horizontal);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRAWer_2_0::on_Vertical_Button_clicked()
|
||||||
|
{
|
||||||
|
ui.widget->changeMode(Mode::Vertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ private slots:
|
|||||||
|
|
||||||
void on_P2P_Button_clicked();
|
void on_P2P_Button_clicked();
|
||||||
|
|
||||||
void on_FIX_Button_clicked();
|
void on_Horizontal_Button_clicked();
|
||||||
|
|
||||||
|
void on_Vertical_Button_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DRAWer_2_0Class ui;
|
Ui::DRAWer_2_0Class ui;
|
||||||
|
|||||||
@@ -66,9 +66,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="FIX_Button">
|
<widget class="QPushButton" name="Vertical_Button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Fix Point</string>
|
<string>Vertical</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="Horizontal_Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Horizontal</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -117,7 +124,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>700</width>
|
<width>700</width>
|
||||||
<height>22</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user