FreeCAD

Форк
0
/
SketchOrientationDialog.cpp 
126 строк · 4.5 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
#include <QDialog>
26
#endif
27

28
#include <Gui/BitmapFactory.h>
29
#include <Gui/MainWindow.h>
30

31
#include "SketchOrientationDialog.h"
32
#include "ui_SketchOrientationDialog.h"
33

34

35
using namespace SketcherGui;
36

37
SketchOrientationDialog::SketchOrientationDialog()
38
    : QDialog(Gui::getMainWindow())
39
    , ui(new Ui_SketchOrientationDialog)
40
{
41
    DirType = 0;
42
    ui->setupUi(this);
43
    onPreview();
44

45
    connect(ui->Reverse_checkBox, &QCheckBox::clicked, this, &SketchOrientationDialog::onPreview);
46
    connect(ui->XY_radioButton, &QRadioButton::clicked, this, &SketchOrientationDialog::onPreview);
47
    connect(ui->XZ_radioButton, &QRadioButton::clicked, this, &SketchOrientationDialog::onPreview);
48
    connect(ui->YZ_radioButton, &QRadioButton::clicked, this, &SketchOrientationDialog::onPreview);
49
}
50

51
SketchOrientationDialog::~SketchOrientationDialog()
52
{}
53

54
void SketchOrientationDialog::accept()
55
{
56
    double offset = ui->Offset_doubleSpinBox->value().getValue();
57
    bool reverse = ui->Reverse_checkBox->isChecked();
58
    if (ui->XY_radioButton->isChecked()) {
59
        if (reverse) {
60
            Pos = Base::Placement(Base::Vector3d(0, 0, offset), Base::Rotation(1.0, 0.0, 0.0, 0.0));
61
            DirType = 1;
62
        }
63
        else {
64
            Pos = Base::Placement(Base::Vector3d(0, 0, offset), Base::Rotation());
65
            DirType = 0;
66
        }
67
    }
68
    else if (ui->XZ_radioButton->isChecked()) {
69
        if (reverse) {
70
            Pos = Base::Placement(Base::Vector3d(0, offset, 0), Base::Rotation(0.0, 1.0, 1.0, 0.0));
71
            DirType = 3;
72
        }
73
        else {
74
            Pos = Base::Placement(Base::Vector3d(0, offset, 0), Base::Rotation(1.0, 0.0, 0.0, 1.0));
75
            DirType = 2;
76
        }
77
    }
78
    else if (ui->YZ_radioButton->isChecked()) {
79
        if (reverse) {
80
            Pos =
81
                Base::Placement(Base::Vector3d(offset, 0, 0), Base::Rotation(-1.0, 1.0, 1.0, -1.0));
82
            DirType = 5;
83
        }
84
        else {
85
            Pos = Base::Placement(Base::Vector3d(offset, 0, 0), Base::Rotation(1.0, 1.0, 1.0, 1.0));
86
            DirType = 4;
87
        }
88
    }
89

90
    QDialog::accept();
91
}
92

93
void SketchOrientationDialog::onPreview()
94
{
95
    std::string icon;
96
    bool reverse = ui->Reverse_checkBox->isChecked();
97
    if (ui->XY_radioButton->isChecked()) {
98
        if (reverse) {
99
            icon = "view-bottom";
100
        }
101
        else {
102
            icon = "view-top";
103
        }
104
    }
105
    else if (ui->XZ_radioButton->isChecked()) {
106
        if (reverse) {
107
            icon = "view-rear";
108
        }
109
        else {
110
            icon = "view-front";
111
        }
112
    }
113
    else if (ui->YZ_radioButton->isChecked()) {
114
        if (reverse) {
115
            icon = "view-left";
116
        }
117
        else {
118
            icon = "view-right";
119
        }
120
    }
121

122
    ui->previewLabel->setPixmap(
123
        Gui::BitmapFactory().pixmapFromSvg(icon.c_str(), ui->previewLabel->size()));
124
}
125

126
#include "moc_SketchOrientationDialog.cpp"
127

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.