23
#include "PreCompiled.h"
29
#include <App/Document.h>
30
#include <Gui/Application.h>
31
#include <Gui/BitmapFactory.h>
32
#include <Gui/Control.h>
33
#include <Mod/Drawing/App/FeaturePage.h>
34
#include <Mod/Part/App/PartFeature.h>
36
#include "TaskOrthoViews.h"
37
#include "ui_TaskOrthoViews.h"
41
using namespace DrawingGui;
43
namespace bp = boost::placeholders;
46
qApp->translate("QObject", "Make axonometric...");
47
qApp->translate("QObject", "Edit axonometric settings...");
48
qApp->translate("QObject", "Make orthographic");
52
void pagesize(string& page_template, int dims[4], int block[4])
59
block[0] = block[1] = 0;
60
block[2] = block[3] = 0;
62
int t0, t1, t2, t3 = 0;
65
Base::FileInfo fi(page_template);
66
if (!fi.isReadable()) {
67
fi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName());
68
if (!fi.isReadable()) {
76
ifstream file(fi.filePath().c_str());
79
while (getline(file, line)) {
80
if (line.find("<!-- Working space") != string::npos) {
81
(void)sscanf(line.c_str(),
82
"%*s %*s %*s %d %d %d %d",
89
if (line.find("<!-- Title block") != string::npos) {
90
(void)sscanf(line.c_str(),
91
"%*s %*s %*s %d %d %d %d",
101
if (line.find("metadata") != string::npos) {
106
catch (Standard_Failure&) {
117
else if (t2 >= dims[2]) {
124
else if (t3 >= dims[3]) {
138
orthoview::orthoview(App::Document* parent,
139
App::DocumentObject* part,
140
App::DocumentObject* page,
141
Base::BoundBox3d* partbox)
144
myname = parent_doc->getUniqueObjectName("Ortho");
148
cx = partbox->GetCenter().x;
149
cy = partbox->GetCenter().y;
150
cz = partbox->GetCenter().z;
152
this_view = static_cast<Drawing::FeatureViewPart*>(
153
parent_doc->addObject("Drawing::FeatureViewPart", myname.c_str()));
154
static_cast<App::DocumentObjectGroup*>(page)->addObject(this_view);
155
this_view->Source.setValue(part);
171
orthoview::~orthoview()
174
void orthoview::set_data(int r_x, int r_y)
180
sprintf(label, "Ortho_%i_%i", rel_x, rel_y);
182
this_view->Label.setValue(label);
183
ortho = ((rel_x * rel_y) == 0);
186
void orthoview::deleteme()
188
parent_doc->removeObject(myname.c_str());
191
void orthoview::setPos(float px, float py)
193
if (px != 0 && py != 0) {
198
float ox = pageX - scale * x;
199
float oy = pageY + scale * y;
201
this_view->X.setValue(ox);
202
this_view->Y.setValue(oy);
205
void orthoview::setScale(float newScale)
208
this_view->Scale.setValue(scale);
211
float orthoview::getScale()
216
void orthoview::calcCentre()
218
x = X_dir.X() * cx + X_dir.Y() * cy + X_dir.Z() * cz;
219
y = Y_dir.X() * cx + Y_dir.Y() * cy + Y_dir.Z() * cz;
222
void orthoview::hidden(bool state)
224
this_view->ShowHiddenLines.setValue(state);
227
void orthoview::smooth(bool state)
229
this_view->ShowSmoothLines.setValue(state);
232
void orthoview::set_projection(const gp_Ax2& cs)
238
X_dir = cs.XDirection();
239
Y_dir = cs.YDirection();
240
Z_dir = cs.Direction();
249
const double x = round(Z_dir.X() * 1e12) / 1e12;
250
const double y = round(Z_dir.Y() * 1e12) / 1e12;
251
const double z = round(Z_dir.Z() * 1e12) / 1e12;
252
actual_cs = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(x, y, z));
254
actual_X = actual_cs.XDirection();
257
float rotation = X_dir.Angle(actual_X);
259
if (rotation != 0 && abs(M_PI - rotation) > 0.05) {
260
if (!Z_dir.IsEqual(actual_X.Crossed(X_dir), 0.05)) {
261
rotation = -rotation;
268
this_view->Direction.setValue(x, y, z);
269
this_view->Rotation.setValue(180 * rotation / M_PI);
276
OrthoViews::OrthoViews(App::Document* doc, const char* pagename, const char* partname)
282
parent_doc->openTransaction("Create view");
284
part = parent_doc->getObject(partname);
285
bbox.Add(static_cast<Part::Feature*>(part)->Shape.getBoundingBox());
287
page = parent_doc->getObject(pagename);
288
Gui::Application::Instance->showViewProvider(page);
293
min_r_x = max_r_x = 0;
294
min_r_y = max_r_y = 0;
301
width = height = depth = 0;
302
layout_width = layout_height = 0;
304
offset_x = offset_y = 0;
306
num_gaps_x = num_gaps_y = 0;
308
this->connectDocumentDeletedObject =
309
doc->signalDeletedObject.connect(boost::bind(&OrthoViews::slotDeletedObject, this, bp::_1));
310
this->connectApplicationDeletedDocument = App::GetApplication().signalDeleteDocument.connect(
311
boost::bind(&OrthoViews::slotDeletedDocument, this, bp::_1));
314
OrthoViews::~OrthoViews()
316
for (int i = views.size() - 1; i >= 0; i--) {
321
page->recomputeFeature();
327
void OrthoViews::slotDeletedDocument(const App::Document& Obj)
329
if (parent_doc == &Obj) {
330
Gui::Control().closeDialog();
334
void OrthoViews::slotDeletedObject(const App::DocumentObject& Obj)
336
if (page == &Obj || part == &Obj) {
337
Gui::Control().closeDialog();
340
for (std::vector<orthoview*>::iterator it = views.begin(); it != views.end(); ++it) {
341
if ((*it)->getViewPart() == &Obj) {
349
void OrthoViews::load_page()
351
string template_name = static_cast<Drawing::FeaturePage*>(page)->Template.getValue();
352
pagesize(template_name, large, block);
360
small_v[1] = large[1];
361
small_v[3] = large[3];
362
small_v[2] = large[2] - block[2];
363
if (block[0] == -1) {
364
small_v[0] = large[0] + block[2];
368
small_v[0] = large[0];
373
small_h[0] = large[0];
374
small_h[2] = large[2];
375
small_h[3] = large[3] - block[3];
377
small_h[1] = large[1] + block[3];
381
small_h[1] = large[1];
390
void OrthoViews::calc_layout_size()
400
layout_width = (1 + floor(max_r_x / 2.0) + floor(-min_r_x / 2.0)) * width;
401
layout_width += (ceil(max_r_x / 2.0) + ceil(-min_r_x / 2.0)) * depth;
402
layout_height = (1 + floor(max_r_y / 2.0) + floor(-min_r_y / 2.0)) * height;
403
layout_height += (ceil(max_r_y / 2.0) + ceil(-min_r_y / 2.0)) * depth;
406
void OrthoViews::choose_page()
412
float layout_corner_width = (1 + floor(h / 2.0)) * width
413
+ ceil(h / 2.0) * depth;
415
float layout_corner_height = (1 + floor(v / 2.0)) * height + ceil(v / 2.0) * depth;
416
float rel_space_x = layout_corner_width / layout_width
417
- 1.0 * block[2] / large[2];
419
float rel_space_y = layout_corner_height / layout_height
420
- 1.0 * block[3] / large[3];
422
float view_x, view_y, v_x_r, v_y_r;
423
bool interferes = false;
426
for (int i = min_r_x; i <= max_r_x; i++) {
427
for (int j = min_r_y; j <= max_r_y; j++) {
428
if (index(i, j) != -1)
432
b = j * block[1] * 0.5;
433
view_x = ceil(a + 0.5) * width
436
view_y = ceil(b + 0.5) * height
439
v_x_r = view_x / layout_width;
440
v_y_r = view_y / layout_height;
441
if (v_x_r > rel_space_x
442
&& v_y_r > rel_space_y) {
454
if (min(small_h[2] / layout_width, small_h[3] / layout_height)
455
> min(small_v[2] / layout_width, small_v[3] / layout_height)) {
464
void OrthoViews::calc_scale()
466
float scale_x, scale_y, working_scale;
468
scale_x = (page_dims[2] - num_gaps_x * min_space) / layout_width;
469
scale_y = (page_dims[3] - num_gaps_y * min_space) / layout_height;
471
working_scale = min(scale_x, scale_y);
477
float exponent = floor(log10(working_scale));
478
working_scale *= pow(10, -exponent);
480
float valid_scales[2][8] = {
481
{1, 1.25, 2, 2.5, 3.75, 5, 7.5, 10},
482
{1, 1.5, 2, 3, 4, 5, 8, 10}};
485
while (valid_scales[(exponent >= 0)][i]
490
scale = valid_scales[(exponent >= 0)][i]
494
void OrthoViews::calc_offsets()
499
float space_x = (page_dims[2] - scale * layout_width) / num_gaps_x;
500
float space_y = (page_dims[3] - scale * layout_height) / num_gaps_y;
502
gap_x = space_x + scale * (width + depth) * 0.5;
503
gap_y = space_y + scale * (height + depth) * 0.5;
505
if (min_r_x % 2 == 0) {
506
offset_x = page_dims[0] + space_x + 0.5 * scale * width;
509
offset_x = page_dims[0] + space_x + 0.5 * scale * depth;
512
if (max_r_y % 2 == 0) {
513
offset_y = page_dims[1] + space_y + 0.5 * scale * height;
516
offset_y = page_dims[1] + space_y + 0.5 * scale * depth;
520
void OrthoViews::set_views()
525
for (unsigned int i = 0; i < views.size(); i++) {
526
x = offset_x + (views[i]->rel_x - min_r_x) * gap_x;
527
y = offset_y + (max_r_y - views[i]->rel_y) * gap_y;
529
if (views[i]->auto_scale) {
530
views[i]->setScale(scale);
533
views[i]->setPos(x, y);
537
void OrthoViews::process_views()
551
parent_doc->recompute();
554
void OrthoViews::set_hidden(bool state)
558
for (unsigned int i = 0; i < views.size(); i++) {
559
views[i]->hidden(hidden);
562
parent_doc->recompute();
565
void OrthoViews::set_smooth(bool state)
569
for (unsigned int i = 0; i < views.size(); i++) {
570
views[i]->smooth(smooth);
573
parent_doc->recompute();
576
void OrthoViews::set_primary(gp_Dir facing,
579
primary.SetDirection(facing);
580
primary.SetXDirection(right);
581
gp_Dir up = primary.YDirection();
585
abs(right.X() * bbox.LengthX() + right.Y() * bbox.LengthY() + right.Z() * bbox.LengthZ());
586
height = abs(up.X() * bbox.LengthX() + up.Y() * bbox.LengthY() + up.Z() * bbox.LengthZ());
587
depth = abs(facing.X() * bbox.LengthX() + facing.Y() * bbox.LengthY()
588
+ facing.Z() * bbox.LengthZ());
590
if (views.size() == 0) {
594
views[0]->set_projection(primary);
595
set_all_orientations();
600
void OrthoViews::set_orientation(int index)
607
if (views[index]->ortho) {
608
if (views[index]->rel_x != 0) {
609
dir = primary.YDirection();
610
n = views[index]->rel_x;
613
dir = primary.XDirection();
614
n = -views[index]->rel_y;
617
rotation = n * rotate_coeff * M_PI / 2;
618
cs = primary.Rotated(gp_Ax1(gp_Pnt(0, 0, 0), dir), rotation);
619
views[index]->set_projection(cs);
623
void OrthoViews::set_all_orientations()
626
for (unsigned int i = 1; i < views.size(); i++)
628
if (views[i]->ortho) {
632
set_Axo(views[i]->rel_x, views[i]->rel_y);
637
void OrthoViews::set_projection(int proj)
642
else if (proj == 1) {
646
set_all_orientations();
650
void OrthoViews::add_view(int rel_x, int rel_y)
652
if (index(rel_x, rel_y) == -1) {
653
orthoview* view = new orthoview(parent_doc, part, page, &bbox);
654
view->set_data(rel_x, rel_y);
655
views.push_back(view);
657
max_r_x = max(max_r_x, rel_x);
658
min_r_x = min(min_r_x, rel_x);
659
max_r_y = max(max_r_y, rel_y);
660
min_r_y = min(min_r_y, rel_y);
662
num_gaps_x = max_r_x - min_r_x + 2;
663
num_gaps_y = max_r_y - min_r_y + 2;
665
int i = views.size() - 1;
666
views[i]->hidden(hidden);
667
views[i]->smooth(smooth);
669
if (views[i]->ortho) {
673
set_Axo(rel_x, rel_y);
680
void OrthoViews::del_view(int rel_x, int rel_y)
682
int num = index(rel_x, rel_y);
686
boost::signals2::shared_connection_block blocker(connectDocumentDeletedObject);
687
views[num]->deleteme();
689
views.erase(views.begin() + num);
692
min_r_x = max_r_x = 0;
693
min_r_y = max_r_y = 0;
695
for (unsigned int i = 1; i < views.size(); i++)
697
min_r_x = min(min_r_x, views[i]->rel_x);
698
max_r_x = max(max_r_x, views[i]->rel_x);
699
min_r_y = min(min_r_y, views[i]->rel_y);
700
max_r_y = max(max_r_y, views[i]->rel_y);
703
num_gaps_x = max_r_x - min_r_x + 2;
704
num_gaps_y = max_r_y - min_r_y + 2;
710
void OrthoViews::del_all()
712
boost::signals2::shared_connection_block blocker(connectDocumentDeletedObject);
713
for (int i = views.size() - 1; i >= 0; i--)
715
views[i]->deleteme();
721
int OrthoViews::is_Ortho(int rel_x, int rel_y)
723
int result = index(rel_x, rel_y);
726
result = views[result]->ortho;
732
int OrthoViews::index(int rel_x, int rel_y)
736
for (unsigned int i = 0; i < views.size(); i++) {
737
if (views[i]->rel_x == rel_x && views[i]->rel_y == rel_y) {
746
void OrthoViews::set_Axo_scale(int rel_x,
750
int num = index(rel_x, rel_y);
752
if (num != -1 && !views[num]->ortho) {
753
views[num]->auto_scale = false;
754
views[num]->setScale(axo_scale);
755
views[num]->setPos();
756
parent_doc->recompute();
760
void OrthoViews::set_Axo(int rel_x,
771
rotations[0] = -0.7853981633974476;
772
rotations[1] = -0.6154797086703873;
775
rotations[0] = -0.7853981633974476;
776
rotations[1] = -0.2712637537260206;
779
rotations[0] = -1.3088876392502007;
780
rotations[1] = -0.6156624905260762;
783
rotations[0] = 1.3088876392502007 - M_PI / 2;
784
rotations[1] = -0.6156624905260762;
788
rotations[1] = -rotations[1];
791
gp_Ax2 cs = gp_Ax2(gp_Pnt(0, 0, 0), right);
792
cs.SetYDirection(up);
793
cs.Rotate(gp_Ax1(gp_Pnt(0, 0, 0), up), rotations[0]);
795
dir = cs.XDirection();
796
cs.Rotate(gp_Ax1(gp_Pnt(0, 0, 0), dir), rotations[1]);
798
int num = index(rel_x, rel_y);
800
views[num]->ortho = false;
801
views[num]->away = away;
802
views[num]->tri = tri;
803
views[num]->axo = axo;
806
views[num]->right = right;
807
views[num]->set_projection(cs);
808
views[num]->setPos();
811
parent_doc->recompute();
814
void OrthoViews::set_Axo(int rel_x, int rel_y)
816
int num = index(rel_x, rel_y);
819
gp_Dir up = primary.YDirection();
820
gp_Dir right = primary.XDirection();
823
if (rel_x * rel_y != 0)
825
if (rotate_coeff == 1)
830
right = primary.Direction();
833
right = primary.XDirection();
841
right = primary.Direction();
844
right = primary.XDirection();
848
set_Axo(rel_x, rel_y, up, right, away);
852
void OrthoViews::set_Ortho(int rel_x, int rel_y)
854
int num = index(rel_x, rel_y);
856
if (num != -1 && rel_x * rel_y == 0) {
857
views[num]->ortho = true;
858
views[num]->setScale(scale);
859
views[num]->auto_scale = true;
860
set_orientation(num);
861
views[num]->setPos();
863
parent_doc->recompute();
867
bool OrthoViews::get_Axo(int rel_x,
876
int num = index(rel_x, rel_y);
878
if (num != -1 && !views[num]->ortho) {
879
axo = views[num]->axo;
881
right = views[num]->right;
882
away = views[num]->away;
883
tri = views[num]->tri;
884
axo_scale = views[num]->getScale();
892
void OrthoViews::auto_dims(bool setting)
900
void OrthoViews::set_configs(float configs[5])
904
offset_x = configs[1];
905
offset_y = configs[2];
912
void OrthoViews::get_configs(float configs[5])
915
configs[1] = offset_x;
916
configs[2] = offset_y;
925
TaskOrthoViews::TaskOrthoViews(QWidget* parent)
926
: ui(new Ui_TaskOrthoViews)
930
std::vector<App::DocumentObject*> obj =
931
Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId());
932
const char* part = obj.front()->getNameInDocument();
934
App::Document* doc = App::GetApplication().getActiveDocument();
935
std::vector<App::DocumentObject*> pages =
936
Gui::Selection().getObjectsOfType(Drawing::FeaturePage::getClassTypeId());
938
pages = doc->getObjectsOfType(Drawing::FeaturePage::getClassTypeId());
941
std::string PageName = pages.front()->getNameInDocument();
942
const char* page = PageName.c_str();
952
c_boxes[0][2] = ui->cb02;
953
c_boxes[1][1] = ui->cb11;
954
c_boxes[1][2] = ui->cb12;
955
c_boxes[1][3] = ui->cb13;
956
c_boxes[2][0] = ui->cb20;
957
c_boxes[2][1] = ui->cb21;
958
c_boxes[2][2] = ui->cb22;
959
c_boxes[2][3] = ui->cb23;
960
c_boxes[2][4] = ui->cb24;
961
c_boxes[3][1] = ui->cb31;
962
c_boxes[3][2] = ui->cb32;
963
c_boxes[3][3] = ui->cb33;
964
c_boxes[4][2] = ui->cb42;
966
for (int i = 0; i < 5; i++) {
967
for (int j = 0; j < 5; j++) {
968
if ((abs(i - 2) + abs(j - 2))
971
connect(c_boxes[i][j], SIGNAL(toggled(bool)), this, SLOT(cb_toggled(bool)));
972
connect(c_boxes[i][j],
973
SIGNAL(customContextMenuRequested(const QPoint&)),
975
SLOT(ShowContextMenu(const QPoint&)));
981
inputs[0] = ui->scale_0;
984
inputs[3] = ui->spacing_h_3;
985
inputs[4] = ui->spacing_v_4;
987
for (int i = 0; i < 5; i++) {
989
SIGNAL(textEdited(const QString&)),
991
SLOT(data_entered(const QString&)));
992
connect(inputs[i], SIGNAL(returnPressed()), this, SLOT(text_return()));
995
connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionChanged(int)));
996
connect(ui->smooth, SIGNAL(stateChanged(int)), this, SLOT(smooth(int)));
997
connect(ui->hidden, SIGNAL(stateChanged(int)), this, SLOT(hidden(int)));
998
connect(ui->auto_tog, SIGNAL(stateChanged(int)), this, SLOT(toggle_auto(int)));
1000
connect(ui->view_from, SIGNAL(currentIndexChanged(int)), this, SLOT(setPrimary(int)));
1001
connect(ui->axis_right, SIGNAL(currentIndexChanged(int)), this, SLOT(setPrimary(int)));
1003
connect(ui->axoProj, SIGNAL(activated(int)), this, SLOT(change_axo(int)));
1004
connect(ui->axoUp, SIGNAL(activated(int)), this, SLOT(change_axo(int)));
1005
connect(ui->axoRight, SIGNAL(activated(int)), this, SLOT(change_axo(int)));
1006
connect(ui->vert_flip, SIGNAL(clicked()), this, SLOT(axo_button()));
1007
connect(ui->tri_flip, SIGNAL(clicked()), this, SLOT(axo_button()));
1008
connect(ui->axoScale,
1009
SIGNAL(textEdited(const QString&)),
1011
SLOT(axo_scale(const QString&)));
1012
connect(ui->axoScale, SIGNAL(returnPressed()), this, SLOT(text_return()));
1014
ui->tabWidget->setTabEnabled(1, false);
1016
gp_Dir facing = gp_Dir(1, 0, 0);
1017
gp_Dir right = gp_Dir(0, 1, 0);
1018
orthos = new OrthoViews(doc, page, part);
1019
orthos->set_primary(facing, right);
1024
TaskOrthoViews::~TaskOrthoViews()
1030
void TaskOrthoViews::ShowContextMenu(const QPoint& pos)
1032
QString name = sender()->objectName().right(2);
1033
char letter = name.toStdString()[0];
1034
int dx = letter - '0' - 2;
1036
letter = name.toStdString()[1];
1037
int dy = letter - '0' - 2;
1039
if (c_boxes[dx + 2][dy + 2]->isChecked()) {
1040
QString str_1 = QObject::tr("Make axonometric...");
1041
QString str_2 = QObject::tr("Edit axonometric settings...");
1042
QString str_3 = QObject::tr("Make orthographic");
1044
QPoint globalPos = c_boxes[dx + 2][dy + 2]->mapToGlobal(pos);
1046
if (orthos->is_Ortho(dx, -dy)) {
1047
myMenu.addAction(str_1);
1050
myMenu.addAction(str_2);
1052
myMenu.addAction(str_3);
1056
QAction* selectedItem = myMenu.exec(globalPos);
1058
QString text = selectedItem->text();
1062
orthos->set_Axo(dx, -dy);
1065
ui->tabWidget->setTabEnabled(1, true);
1066
ui->tabWidget->setCurrentIndex(1);
1069
else if (text == str_2)
1073
ui->tabWidget->setTabEnabled(1, true);
1074
ui->tabWidget->setCurrentIndex(1);
1077
else if (text == str_3)
1079
orthos->set_Ortho(dx, -dy);
1080
if (dx == axo_r_x && dy == axo_r_y) {
1083
ui->tabWidget->setTabEnabled(1, false);
1090
void TaskOrthoViews::changeEvent(QEvent* e)
1092
if (e->type() == QEvent::LanguageChange) {
1093
ui->retranslateUi(this);
1097
void TaskOrthoViews::cb_toggled(bool toggle)
1099
QString name = sender()->objectName().right(2);
1100
char letter = name.toStdString()[0];
1101
int dx = letter - '0' - 2;
1103
letter = name.toStdString()[1];
1104
int dy = letter - '0' - 2;
1107
orthos->add_view(dx, -dy);
1112
ui->tabWidget->setTabEnabled(1, true);
1113
ui->tabWidget->setCurrentIndex(1);
1119
if (!orthos->is_Ortho(dx, -dy))
1121
if (dx == axo_r_x && dy == axo_r_y)
1125
ui->tabWidget->setTabEnabled(1, false);
1128
orthos->del_view(dx, -dy);
1134
void TaskOrthoViews::projectionChanged(int index)
1136
int proj = 3 - 2 * index;
1137
orthos->set_projection(proj);
1142
void TaskOrthoViews::setPrimary(int )
1144
int p_sel = ui->view_from->currentIndex();
1145
int r_sel = ui->axis_right->currentIndex();
1147
int p_vec[3] = {0, 0, 0};
1148
int r_vec[3] = {0, 0, 0};
1151
int pos = 1 - 2 * int(p_sel / 3);
1155
for (int i = p_sel; i < 2;
1160
pos = 1 - 2 * int(r_sel / 2);
1162
r_vec[r[r_sel]] = pos;
1164
gp_Dir facing = gp_Dir(p_vec[0], p_vec[1], p_vec[2]);
1165
gp_Dir right = gp_Dir(r_vec[0], r_vec[1], r_vec[2]);
1167
orthos->set_primary(facing, right);
1170
if (sender() == ui->view_from) {
1171
disconnect(ui->axis_right, SIGNAL(currentIndexChanged(int)), this, SLOT(setPrimary(int)));
1174
items << QString::fromUtf8("X +ve") << QString::fromUtf8("Y +ve")
1175
<< QString::fromUtf8("Z +ve");
1176
items << QString::fromUtf8("X -ve") << QString::fromUtf8("Y -ve")
1177
<< QString::fromUtf8("Z -ve");
1178
items.removeAt(p_sel + 3);
1179
items.removeAt(p_sel);
1181
ui->axis_right->clear();
1182
ui->axis_right->addItems(items);
1183
ui->axis_right->setCurrentIndex(r_sel - pos + 1);
1185
connect(ui->axis_right, SIGNAL(currentIndexChanged(int)), this, SLOT(setPrimary(int)));
1191
void TaskOrthoViews::hidden(int i)
1193
orthos->set_hidden(i == 2);
1197
void TaskOrthoViews::smooth(int i)
1199
orthos->set_smooth(i == 2);
1202
void TaskOrthoViews::toggle_auto(int i)
1206
orthos->auto_dims(true);
1207
ui->label_4->setEnabled(false);
1208
ui->label_5->setEnabled(false);
1209
ui->label_6->setEnabled(false);
1211
for (int j = 0; j < 5; j++) {
1212
inputs[j]->setEnabled(false);
1216
orthos->auto_dims(false);
1217
ui->label_4->setEnabled(true);
1218
ui->label_5->setEnabled(true);
1219
ui->label_6->setEnabled(true);
1221
for (int j = 0; j < 5; j++) {
1222
inputs[j]->setEnabled(true);
1228
void TaskOrthoViews::data_entered(const QString& text)
1231
QString name = sender()->objectName().right(1);
1232
char letter = name.toStdString()[0];
1233
int index = letter - '0';
1235
float value = text.toFloat(&ok);
1238
data[index] = value;
1239
orthos->set_configs(data);
1242
inputs[index]->setText(QString::number(data[index]));
1247
void TaskOrthoViews::clean_up()
1252
void TaskOrthoViews::setup_axo_tab()
1260
orthos->get_Axo(axo_r_x, -axo_r_y, axo, up, right, away, tri, axo_scale);
1264
up_n = (up.X() == -1) ? 3 : 0;
1266
else if (up.Y() != 0) {
1267
up_n = (up.Y() == -1) ? 4 : 1;
1270
up_n = (up.Z() == -1) ? 5 : 2;
1273
if (right.X() != 0) {
1274
right_n = (right.X() == -1) ? 3 : 0;
1276
else if (right.Y() != 0) {
1277
right_n = (right.Y() == -1) ? 4 : 1;
1280
right_n = (right.Z() == -1) ? 5 : 2;
1283
if (right_n > (up_n % 3 + 3)) {
1286
else if (right_n > up_n) {
1291
items << QString::fromUtf8("X +ve") << QString::fromUtf8("Y +ve") << QString::fromUtf8("Z +ve");
1292
items << QString::fromUtf8("X -ve") << QString::fromUtf8("Y -ve") << QString::fromUtf8("Z -ve");
1293
items.removeAt(up_n % 3 + 3);
1294
items.removeAt(up_n % 3);
1296
ui->axoUp->setCurrentIndex(up_n);
1297
ui->axoRight->clear();
1298
ui->axoRight->addItems(items);
1299
ui->axoRight->setCurrentIndex(right_n);
1301
ui->vert_flip->setChecked(away);
1302
ui->tri_flip->setChecked(tri);
1303
ui->axoProj->setCurrentIndex(axo);
1304
ui->axoScale->setText(QString::number(axo_scale));
1307
void TaskOrthoViews::change_axo(int )
1309
int u_sel = ui->axoUp->currentIndex();
1310
int r_sel = ui->axoRight->currentIndex();
1312
int u_vec[3] = {0, 0, 0};
1313
int r_vec[3] = {0, 0, 0};
1316
int pos = 1 - 2 * int(u_sel / 3);
1320
for (int i = u_sel; i < 2; i++) {
1324
pos = 1 - 2 * int(r_sel / 2);
1326
r_vec[r[r_sel]] = pos;
1328
gp_Dir up = gp_Dir(u_vec[0], u_vec[1], u_vec[2]);
1329
gp_Dir right = gp_Dir(r_vec[0], r_vec[1], r_vec[2]);
1331
orthos->set_Axo(axo_r_x,
1335
ui->vert_flip->isChecked(),
1336
ui->axoProj->currentIndex(),
1337
ui->tri_flip->isChecked());
1339
if (ui->axoProj->currentIndex() == 2) {
1340
ui->tri_flip->setEnabled(true);
1343
ui->tri_flip->setEnabled(false);
1348
items << QString::fromUtf8("X +ve") << QString::fromUtf8("Y +ve") << QString::fromUtf8("Z +ve");
1349
items << QString::fromUtf8("X -ve") << QString::fromUtf8("Y -ve") << QString::fromUtf8("Z -ve");
1350
items.removeAt(u_sel % 3 + 3);
1351
items.removeAt(u_sel % 3);
1353
ui->axoRight->clear();
1354
ui->axoRight->addItems(items);
1355
ui->axoRight->setCurrentIndex(r_sel - pos + 1);
1358
void TaskOrthoViews::axo_button()
1363
void TaskOrthoViews::axo_scale(const QString& text)
1366
float value = text.toFloat(&ok);
1369
orthos->set_Axo_scale(axo_r_x, -axo_r_y, value);
1373
void TaskOrthoViews::set_configs()
1375
orthos->get_configs(data);
1377
for (int i = 0; i < 5; i++) {
1378
inputs[i]->setText(QString::number(data[i]));
1382
bool TaskOrthoViews::user_input()
1386
ui->label_7->setFocus();
1395
void TaskOrthoViews::text_return()
1405
TaskDlgOrthoViews::TaskDlgOrthoViews()
1408
widget = new TaskOrthoViews();
1409
addTaskBox(Gui::BitmapFactory().pixmap("actions/drawing-orthoviews"), widget, true, nullptr);
1412
TaskDlgOrthoViews::~TaskDlgOrthoViews()
1418
void TaskDlgOrthoViews::open()
1421
void TaskDlgOrthoViews::clicked(int)
1424
bool TaskDlgOrthoViews::accept()
1426
bool check = widget->user_input();
1427
App::Document* doc = App::GetApplication().getDocument(this->getDocumentName().c_str());
1429
doc->commitTransaction();
1434
bool TaskDlgOrthoViews::reject()
1437
App::Document* doc = App::GetApplication().getDocument(this->getDocumentName().c_str());
1439
doc->abortTransaction();
1445
#include "moc_TaskOrthoViews.cpp"