+ fix crashes in ortho view panel

This commit is contained in:
wmayer 2016-01-13 17:40:20 +01:00
parent ffcbb0b66c
commit 6ed52e479b
2 changed files with 61 additions and 96 deletions

View File

@ -31,9 +31,12 @@
#include <Gui/Application.h> #include <Gui/Application.h>
#include <Gui/BitmapFactory.h> #include <Gui/BitmapFactory.h>
#include <Gui/Command.h> #include <Gui/Command.h>
#include <Gui/Control.h>
#include <Mod/Part/App/PartFeature.h> #include <Mod/Part/App/PartFeature.h>
#include <Mod/Drawing/App/FeaturePage.h> #include <Mod/Drawing/App/FeaturePage.h>
#include <boost/bind.hpp>
using namespace Gui; using namespace Gui;
using namespace DrawingGui; using namespace DrawingGui;
@ -134,9 +137,6 @@ void pagesize(string & page_template, int dims[4], int block[4])
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
orthoview::orthoview(App::Document * parent, App::DocumentObject * part, App::DocumentObject * page, Base::BoundBox3d * partbox) orthoview::orthoview(App::Document * parent, App::DocumentObject * part, App::DocumentObject * page, Base::BoundBox3d * partbox)
{ {
parent_doc = parent; parent_doc = parent;
@ -160,12 +160,10 @@ orthoview::orthoview(App::Document * parent, App::DocumentObject * part, App::Do
auto_scale = true; auto_scale = true;
} }
orthoview::~orthoview() orthoview::~orthoview()
{ {
} }
void orthoview::set_data(int r_x, int r_y) void orthoview::set_data(int r_x, int r_y)
{ {
rel_x = r_x; rel_x = r_x;
@ -178,13 +176,11 @@ void orthoview::set_data(int r_x, int r_y)
ortho = ((rel_x * rel_y) == 0); ortho = ((rel_x * rel_y) == 0);
} }
void orthoview::deleteme() void orthoview::deleteme()
{ {
parent_doc->remObject(myname.c_str()); parent_doc->remObject(myname.c_str());
} }
void orthoview::setPos(float px, float py) void orthoview::setPos(float px, float py)
{ {
if (px != 0 && py !=0) if (px != 0 && py !=0)
@ -200,39 +196,33 @@ void orthoview::setPos(float px, float py)
this_view->Y.setValue(oy); this_view->Y.setValue(oy);
} }
void orthoview::setScale(float newScale) void orthoview::setScale(float newScale)
{ {
scale = newScale; scale = newScale;
this_view->Scale.setValue(scale); this_view->Scale.setValue(scale);
} }
float orthoview::getScale() float orthoview::getScale()
{ {
return scale; return scale;
} }
void orthoview::calcCentre() void orthoview::calcCentre()
{ {
x = X_dir.X() * cx + X_dir.Y() * cy + X_dir.Z() * cz; x = X_dir.X() * cx + X_dir.Y() * cy + X_dir.Z() * cz;
y = Y_dir.X() * cx + Y_dir.Y() * cy + Y_dir.Z() * cz; y = Y_dir.X() * cx + Y_dir.Y() * cy + Y_dir.Z() * cz;
} }
void orthoview::hidden(bool state) void orthoview::hidden(bool state)
{ {
this_view->ShowHiddenLines.setValue(state); this_view->ShowHiddenLines.setValue(state);
} }
void orthoview::smooth(bool state) void orthoview::smooth(bool state)
{ {
this_view->ShowSmoothLines.setValue(state); this_view->ShowSmoothLines.setValue(state);
} }
void orthoview::set_projection(gp_Ax2 cs) void orthoview::set_projection(gp_Ax2 cs)
{ {
gp_Ax2 actual_cs; gp_Ax2 actual_cs;
@ -271,23 +261,13 @@ void orthoview::set_projection(gp_Ax2 cs)
this_view->Rotation.setValue(180 * rotation / PI); this_view->Rotation.setValue(180 * rotation / PI);
} }
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
OrthoViews::OrthoViews(App::Document* doc, const char * pagename, const char * partname)
OrthoViews::OrthoViews(const char * pagename, const char * partname)
{ {
page_name = pagename; parent_doc = doc;
part_name = partname;
parent_doc = App::GetApplication().getActiveDocument();
parent_doc->openTransaction("Create view"); parent_doc->openTransaction("Create view");
part = parent_doc->getObject(partname); part = parent_doc->getObject(partname);
@ -306,8 +286,12 @@ OrthoViews::OrthoViews(const char * pagename, const char * partname)
smooth = false; smooth = false;
hidden = false; hidden = false;
autodims = true; autodims = true;
}
this->connectDocumentDeletedObject = doc->signalDeletedObject.connect(boost::bind
(&OrthoViews::slotDeletedObject, this, _1));
this->connectApplicationDeletedDocument = App::GetApplication().signalDeleteDocument.connect(boost::bind
(&OrthoViews::slotDeletedDocument, this, _1));
}
OrthoViews::~OrthoViews() OrthoViews::~OrthoViews()
{ {
@ -317,6 +301,27 @@ OrthoViews::~OrthoViews()
page->recompute(); page->recompute();
} }
void OrthoViews::slotDeletedDocument(const App::Document& Obj)
{
if (parent_doc == &Obj) {
Gui::Control().closeDialog();
}
}
void OrthoViews::slotDeletedObject(const App::DocumentObject& Obj)
{
if (page == &Obj || part == &Obj) {
Gui::Control().closeDialog();
}
else {
for (std::vector<orthoview *>::iterator it = views.begin(); it != views.end(); ++it) {
if ((*it)->getViewPart() == &Obj) {
views.erase(it);
break;
}
}
}
}
void OrthoViews::load_page() void OrthoViews::load_page()
{ {
@ -363,7 +368,6 @@ void OrthoViews::load_page()
title = false; title = false;
} }
void OrthoViews::calc_layout_size() // calculate the real world size of given view layout, assuming no space void OrthoViews::calc_layout_size() // calculate the real world size of given view layout, assuming no space
{ {
// note that views in relative positions x = -4, -2, 0 , 2 etc etc // note that views in relative positions x = -4, -2, 0 , 2 etc etc
@ -379,7 +383,6 @@ void OrthoViews::calc_layout_size() // calculate the rea
layout_height += (ceil(max_r_y / 2.0) + ceil(-min_r_y / 2.0)) * depth; layout_height += (ceil(max_r_y / 2.0) + ceil(-min_r_y / 2.0)) * depth;
} }
void OrthoViews::choose_page() // chooses which bit of page space to use depending upon layout & titleblock void OrthoViews::choose_page() // chooses which bit of page space to use depending upon layout & titleblock
{ {
int h = abs(*horiz); // how many views in direction of title block (horiz points to min_r_x or max_r_x) int h = abs(*horiz); // how many views in direction of title block (horiz points to min_r_x or max_r_x)
@ -417,7 +420,6 @@ void OrthoViews::choose_page() // chooses which bit
} }
} }
void OrthoViews::calc_scale() // compute scale required to meet minimum space requirements void OrthoViews::calc_scale() // compute scale required to meet minimum space requirements
{ {
float scale_x, scale_y, working_scale; float scale_x, scale_y, working_scale;
@ -443,7 +445,6 @@ void OrthoViews::calc_scale() // compute scale req
scale = valid_scales[(exponent>=0)][i] * pow(10, exponent); //now have the appropriate scale, reapply the *10^b scale = valid_scales[(exponent>=0)][i] * pow(10, exponent); //now have the appropriate scale, reapply the *10^b
} }
void OrthoViews::calc_offsets() // calcs SVG coords for centre of upper left view void OrthoViews::calc_offsets() // calcs SVG coords for centre of upper left view
{ {
// space_x is the emptry clear white space between views // space_x is the emptry clear white space between views
@ -466,7 +467,6 @@ void OrthoViews::calc_offsets() // calcs SVG coords
offset_y = page_dims[1] + space_y + 0.5 * scale * depth; offset_y = page_dims[1] + space_y + 0.5 * scale * depth;
} }
void OrthoViews::set_views() // process all views - scale & positions void OrthoViews::set_views() // process all views - scale & positions
{ {
float x; float x;
@ -484,7 +484,6 @@ void OrthoViews::set_views() // process all views
} }
} }
void OrthoViews::process_views() // update scale and positions of views void OrthoViews::process_views() // update scale and positions of views
{ {
if (autodims) if (autodims)
@ -502,7 +501,6 @@ void OrthoViews::process_views() // update scale and
parent_doc->recompute(); parent_doc->recompute();
} }
void OrthoViews::set_hidden(bool state) void OrthoViews::set_hidden(bool state)
{ {
hidden = state; hidden = state;
@ -513,7 +511,6 @@ void OrthoViews::set_hidden(bool state)
parent_doc->recompute(); parent_doc->recompute();
} }
void OrthoViews::set_smooth(bool state) void OrthoViews::set_smooth(bool state)
{ {
smooth = state; smooth = state;
@ -524,7 +521,6 @@ void OrthoViews::set_smooth(bool state)
parent_doc->recompute(); parent_doc->recompute();
} }
void OrthoViews::set_primary(gp_Dir facing, gp_Dir right) // set the orientation of the primary view void OrthoViews::set_primary(gp_Dir facing, gp_Dir right) // set the orientation of the primary view
{ {
primary.SetDirection(facing); primary.SetDirection(facing);
@ -546,7 +542,6 @@ void OrthoViews::set_primary(gp_Dir facing, gp_Dir right) // set the orientati
} }
} }
void OrthoViews::set_orientation(int index) // set orientation of single view void OrthoViews::set_orientation(int index) // set orientation of single view
{ {
double rotation; double rotation;
@ -573,7 +568,6 @@ void OrthoViews::set_orientation(int index) // set orientation o
} }
} }
void OrthoViews::set_all_orientations() // set orientations of all views (ie projection or primary changed) void OrthoViews::set_all_orientations() // set orientations of all views (ie projection or primary changed)
{ {
for (unsigned int i = 1; i < views.size(); i++) // start from 1 - the 0 is the primary view for (unsigned int i = 1; i < views.size(); i++) // start from 1 - the 0 is the primary view
@ -585,7 +579,6 @@ void OrthoViews::set_all_orientations() // set orientations
} }
} }
void OrthoViews::set_projection(int proj) // 1 = 1st angle, 3 = 3rd angle void OrthoViews::set_projection(int proj) // 1 = 1st angle, 3 = 3rd angle
{ {
if (proj == 3) if (proj == 3)
@ -597,7 +590,6 @@ void OrthoViews::set_projection(int proj) // 1 = 1st angle, 3
process_views(); process_views();
} }
void OrthoViews::add_view(int rel_x, int rel_y) // add a new view to the layout void OrthoViews::add_view(int rel_x, int rel_y) // add a new view to the layout
{ {
if (index(rel_x, rel_y) == -1) if (index(rel_x, rel_y) == -1)
@ -627,26 +619,27 @@ void OrthoViews::add_view(int rel_x, int rel_y) // add a new view to
} }
} }
void OrthoViews::del_view(int rel_x, int rel_y) // remove a view from the layout void OrthoViews::del_view(int rel_x, int rel_y) // remove a view from the layout
{ {
int num = index(rel_x, rel_y); int num = index(rel_x, rel_y);
if (num > 0) if (num > 0)
{ {
connectDocumentDeletedObject.block();
views[num]->deleteme(); views[num]->deleteme();
delete views[num]; delete views[num];
views.erase(views.begin() + num); views.erase(views.begin() + num);
connectDocumentDeletedObject.unblock();
min_r_x = max_r_x = 0; min_r_x = max_r_x = 0;
min_r_y = max_r_y = 0; min_r_y = max_r_y = 0;
for (unsigned int i = 1; i < views.size(); i++) // start from 1 - the 0 is the primary view for (unsigned int i = 1; i < views.size(); i++) // start from 1 - the 0 is the primary view
{ {
min_r_x = min(min_r_x, views[i]->rel_x); // calculate extremes from remaining views min_r_x = min(min_r_x, views[i]->rel_x); // calculate extremes from remaining views
max_r_x = max(max_r_x, views[i]->rel_x); max_r_x = max(max_r_x, views[i]->rel_x);
min_r_y = min(min_r_y, views[i]->rel_y); min_r_y = min(min_r_y, views[i]->rel_y);
max_r_y = max(max_r_y, views[i]->rel_y); max_r_y = max(max_r_y, views[i]->rel_y);
} }
num_gaps_x = max_r_x - min_r_x + 2; num_gaps_x = max_r_x - min_r_x + 2;
@ -656,18 +649,18 @@ void OrthoViews::del_view(int rel_x, int rel_y) // remove a view fro
} }
} }
void OrthoViews::del_all() void OrthoViews::del_all()
{ {
connectDocumentDeletedObject.block();
for (int i = views.size() - 1; i >= 0; i--) // count downwards to delete from back for (int i = views.size() - 1; i >= 0; i--) // count downwards to delete from back
{ {
views[i]->deleteme(); views[i]->deleteme();
delete views[i]; delete views[i];
views.pop_back(); views.pop_back();
} }
connectDocumentDeletedObject.unblock();
} }
int OrthoViews::is_Ortho(int rel_x, int rel_y) // is the view at r_x, r_y an ortho or axo one? int OrthoViews::is_Ortho(int rel_x, int rel_y) // is the view at r_x, r_y an ortho or axo one?
{ {
int result = index(rel_x, rel_y); int result = index(rel_x, rel_y);
@ -678,7 +671,6 @@ int OrthoViews::is_Ortho(int rel_x, int rel_y) // is the view at r_
return result; return result;
} }
int OrthoViews::index(int rel_x, int rel_y) // index in vector of view, -1 if doesn't exist int OrthoViews::index(int rel_x, int rel_y) // index in vector of view, -1 if doesn't exist
{ {
int index = -1; int index = -1;
@ -693,7 +685,6 @@ int OrthoViews::index(int rel_x, int rel_y) // index in vector o
return index; return index;
} }
void OrthoViews::set_Axo_scale(int rel_x, int rel_y, float axo_scale) // set an axo scale independent of ortho ones void OrthoViews::set_Axo_scale(int rel_x, int rel_y, float axo_scale) // set an axo scale independent of ortho ones
{ {
int num = index(rel_x, rel_y); int num = index(rel_x, rel_y);
@ -707,7 +698,6 @@ void OrthoViews::set_Axo_scale(int rel_x, int rel_y, float axo_scale) // s
} }
} }
void OrthoViews::set_Axo(int rel_x, int rel_y, gp_Dir up, gp_Dir right, bool away, int axo, bool tri) // set custom axonometric view void OrthoViews::set_Axo(int rel_x, int rel_y, gp_Dir up, gp_Dir right, bool away, int axo, bool tri) // set custom axonometric view
{ {
int num = index(rel_x, rel_y); int num = index(rel_x, rel_y);
@ -757,7 +747,6 @@ void OrthoViews::set_Axo(int rel_x, int rel_y, gp_Dir up, gp_Dir right, bool awa
parent_doc->recompute(); parent_doc->recompute();
} }
void OrthoViews::set_Axo(int rel_x, int rel_y) // set view to default axo projection void OrthoViews::set_Axo(int rel_x, int rel_y) // set view to default axo projection
{ {
int num = index(rel_x, rel_y); int num = index(rel_x, rel_y);
@ -793,7 +782,6 @@ void OrthoViews::set_Axo(int rel_x, int rel_y) // set view to defau
} }
} }
void OrthoViews::set_Ortho(int rel_x, int rel_y) // return view to orthographic void OrthoViews::set_Ortho(int rel_x, int rel_y) // return view to orthographic
{ {
int num = index(rel_x, rel_y); int num = index(rel_x, rel_y);
@ -810,7 +798,6 @@ void OrthoViews::set_Ortho(int rel_x, int rel_y) // return view to or
} }
} }
bool OrthoViews::get_Axo(int rel_x, int rel_y, int & axo, gp_Dir & up, gp_Dir & right, bool & away, bool & tri, float & axo_scale) bool OrthoViews::get_Axo(int rel_x, int rel_y, int & axo, gp_Dir & up, gp_Dir & right, bool & away, bool & tri, float & axo_scale)
{ {
int num = index(rel_x, rel_y); int num = index(rel_x, rel_y);
@ -829,7 +816,6 @@ bool OrthoViews::get_Axo(int rel_x, int rel_y, int & axo, gp_Dir & up, gp_Dir &
return false; return false;
} }
void OrthoViews::auto_dims(bool setting) void OrthoViews::auto_dims(bool setting)
{ {
autodims = setting; autodims = setting;
@ -837,7 +823,6 @@ void OrthoViews::auto_dims(bool setting)
process_views(); process_views();
} }
void OrthoViews::set_configs(float configs[5]) // for autodims off, set scale & positionings void OrthoViews::set_configs(float configs[5]) // for autodims off, set scale & positionings
{ {
if (!autodims) if (!autodims)
@ -851,7 +836,6 @@ void OrthoViews::set_configs(float configs[5]) // for autodims off,
} }
} }
void OrthoViews::get_configs(float configs[5]) // get scale & positionings void OrthoViews::get_configs(float configs[5]) // get scale & positionings
{ {
configs[0] = scale; configs[0] = scale;
@ -861,29 +845,24 @@ void OrthoViews::get_configs(float configs[5]) // get scale & posit
configs[4] = gap_y; configs[4] = gap_y;
} }
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
TaskOrthoViews::TaskOrthoViews(QWidget *parent) TaskOrthoViews::TaskOrthoViews(QWidget *parent)
: ui(new Ui_TaskOrthoViews) : ui(new Ui_TaskOrthoViews)
{ {
ui->setupUi(this); ui->setupUi(this);
vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId()); std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId());
const char * part = obj.front()->getNameInDocument(); const char * part = obj.front()->getNameInDocument();
App::Document * doc = App::GetApplication().getActiveDocument(); App::Document * doc = App::GetApplication().getActiveDocument();
vector<App::DocumentObject*> pages = Gui::Selection().getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); std::vector<App::DocumentObject*> pages = Gui::Selection().getObjectsOfType(Drawing::FeaturePage::getClassTypeId());
if (pages.empty()) { if (pages.empty()) {
pages = doc->getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); pages = doc->getObjectsOfType(Drawing::FeaturePage::getClassTypeId());
} }
string PageName = pages.front()->getNameInDocument();
std::string PageName = pages.front()->getNameInDocument();
const char * page = PageName.c_str(); const char * page = PageName.c_str();
@ -909,12 +888,16 @@ TaskOrthoViews::TaskOrthoViews(QWidget *parent)
c_boxes[4][2] = ui->cb42; //right most, x = 2, y = 0 c_boxes[4][2] = ui->cb42; //right most, x = 2, y = 0
for (int i=0; i < 5; i++) for (int i=0; i < 5; i++)
{
for (int j=0; j < 5; j++) for (int j=0; j < 5; j++)
{
if ((abs(i-2) + abs(j-2)) < 3) //if i,j combination corresponds to valid check box, then proceed with: if ((abs(i-2) + abs(j-2)) < 3) //if i,j combination corresponds to valid check box, then proceed with:
{ {
connect(c_boxes[i][j], SIGNAL(toggled(bool)), this, SLOT(cb_toggled(bool))); connect(c_boxes[i][j], SIGNAL(toggled(bool)), this, SLOT(cb_toggled(bool)));
connect(c_boxes[i][j], SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(ShowContextMenu(const QPoint&))); connect(c_boxes[i][j], SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(ShowContextMenu(const QPoint&)));
} }
}
}
// access scale / position QLineEdits via array // access scale / position QLineEdits via array
inputs[0] = ui->scale_0; inputs[0] = ui->scale_0;
@ -949,20 +932,18 @@ TaskOrthoViews::TaskOrthoViews(QWidget *parent)
gp_Dir facing = gp_Dir(1, 0, 0); gp_Dir facing = gp_Dir(1, 0, 0);
gp_Dir right = gp_Dir(0, 1, 0); gp_Dir right = gp_Dir(0, 1, 0);
orthos = new OrthoViews(page, part); orthos = new OrthoViews(doc, page, part);
orthos->set_primary(facing, right); orthos->set_primary(facing, right);
txt_return = false; txt_return = false;
} //end of constructor } //end of constructor
TaskOrthoViews::~TaskOrthoViews() TaskOrthoViews::~TaskOrthoViews()
{ {
delete orthos; delete orthos;
delete ui; delete ui;
} }
void TaskOrthoViews::ShowContextMenu(const QPoint& pos) void TaskOrthoViews::ShowContextMenu(const QPoint& pos)
{ {
QString name = sender()->objectName().right(2); QString name = sender()->objectName().right(2);
@ -1025,7 +1006,6 @@ void TaskOrthoViews::ShowContextMenu(const QPoint& pos)
} }
} }
void TaskOrthoViews::changeEvent(QEvent *e) void TaskOrthoViews::changeEvent(QEvent *e)
{ {
if (e->type() == QEvent::LanguageChange) { if (e->type() == QEvent::LanguageChange) {
@ -1033,7 +1013,6 @@ void TaskOrthoViews::changeEvent(QEvent *e)
} }
} }
void TaskOrthoViews::cb_toggled(bool toggle) void TaskOrthoViews::cb_toggled(bool toggle)
{ {
QString name = sender()->objectName().right(2); QString name = sender()->objectName().right(2);
@ -1072,7 +1051,6 @@ void TaskOrthoViews::cb_toggled(bool toggle)
set_configs(); set_configs();
} }
void TaskOrthoViews::projectionChanged(int index) void TaskOrthoViews::projectionChanged(int index)
{ {
int proj = 3 - 2 * index; // index = 0 = third angle int proj = 3 - 2 * index; // index = 0 = third angle
@ -1081,7 +1059,6 @@ void TaskOrthoViews::projectionChanged(int index)
set_configs(); set_configs();
} }
void TaskOrthoViews::setPrimary(int dir) void TaskOrthoViews::setPrimary(int dir)
{ {
int p_sel = ui->view_from->currentIndex(); // index for entry selected for 'view from' int p_sel = ui->view_from->currentIndex(); // index for entry selected for 'view from'
@ -1128,7 +1105,6 @@ void TaskOrthoViews::setPrimary(int dir)
set_configs(); set_configs();
} }
void TaskOrthoViews::hidden(int i) void TaskOrthoViews::hidden(int i)
{ {
orthos->set_hidden(i == 2); orthos->set_hidden(i == 2);
@ -1140,7 +1116,6 @@ void TaskOrthoViews::smooth(int i)
orthos->set_smooth(i == 2); orthos->set_smooth(i == 2);
} }
void TaskOrthoViews::toggle_auto(int i) void TaskOrthoViews::toggle_auto(int i)
{ {
if (i == 2) //auto scale switched on if (i == 2) //auto scale switched on
@ -1166,7 +1141,6 @@ void TaskOrthoViews::toggle_auto(int i)
} }
} }
void TaskOrthoViews::data_entered(const QString & text) void TaskOrthoViews::data_entered(const QString & text)
{ {
bool ok; bool ok;
@ -1188,13 +1162,11 @@ void TaskOrthoViews::data_entered(const QString & text)
} }
} }
void TaskOrthoViews::clean_up() void TaskOrthoViews::clean_up()
{ {
orthos->del_all(); orthos->del_all();
} }
void TaskOrthoViews::setup_axo_tab() void TaskOrthoViews::setup_axo_tab()
{ {
int axo; int axo;
@ -1242,7 +1214,6 @@ void TaskOrthoViews::setup_axo_tab()
ui->axoScale->setText(QString::number(axo_scale)); ui->axoScale->setText(QString::number(axo_scale));
} }
void TaskOrthoViews::change_axo(int p) void TaskOrthoViews::change_axo(int p)
{ {
int u_sel = ui->axoUp->currentIndex(); // index for entry selected for 'view from' int u_sel = ui->axoUp->currentIndex(); // index for entry selected for 'view from'
@ -1285,13 +1256,11 @@ void TaskOrthoViews::change_axo(int p)
ui->axoRight->setCurrentIndex(r_sel - pos + 1); ui->axoRight->setCurrentIndex(r_sel - pos + 1);
} }
void TaskOrthoViews::axo_button() void TaskOrthoViews::axo_button()
{ {
change_axo(); change_axo();
} }
void TaskOrthoViews::axo_scale(const QString & text) void TaskOrthoViews::axo_scale(const QString & text)
{ {
bool ok; bool ok;
@ -1301,7 +1270,6 @@ void TaskOrthoViews::axo_scale(const QString & text)
orthos->set_Axo_scale(axo_r_x, -axo_r_y, value); orthos->set_Axo_scale(axo_r_x, -axo_r_y, value);
} }
void TaskOrthoViews::set_configs() void TaskOrthoViews::set_configs()
{ {
orthos->get_configs(data); orthos->get_configs(data);
@ -1310,7 +1278,6 @@ void TaskOrthoViews::set_configs()
inputs[i]->setText(QString::number(data[i])); inputs[i]->setText(QString::number(data[i]));
} }
bool TaskOrthoViews::user_input() bool TaskOrthoViews::user_input()
{ {
if (txt_return) if (txt_return)
@ -1323,15 +1290,11 @@ bool TaskOrthoViews::user_input()
return false; // return that we weren't editing ---> treat as clicking OK... we can close the GUI return false; // return that we weren't editing ---> treat as clicking OK... we can close the GUI
} }
void TaskOrthoViews::text_return() void TaskOrthoViews::text_return()
{ {
txt_return = true; txt_return = true;
} }
//************************************************************************** //**************************************************************************
//************************************************************************** //**************************************************************************
// TaskDialog // TaskDialog
@ -1381,6 +1344,4 @@ bool TaskDlgOrthoViews::reject()
} }
#include "moc_TaskOrthoViews.cpp" #include "moc_TaskOrthoViews.cpp"

View File

@ -30,13 +30,13 @@
#include <gp_Ax2.hxx> #include <gp_Ax2.hxx>
#include <vector> #include <vector>
#include <boost/signals.hpp>
#include <Mod/Drawing/App/FeatureViewPart.h> #include <Mod/Drawing/App/FeatureViewPart.h>
class Ui_TaskOrthoViews; class Ui_TaskOrthoViews;
using namespace std;
namespace DrawingGui { namespace DrawingGui {
@ -56,6 +56,10 @@ public:
void hidden(bool); void hidden(bool);
void smooth(bool); void smooth(bool);
App::DocumentObject* getViewPart() {
return this_view;
}
private: private:
void calcCentre(); void calcCentre();
@ -71,7 +75,7 @@ private:
App::Document * parent_doc; App::Document * parent_doc;
Drawing::FeatureViewPart * this_view; Drawing::FeatureViewPart * this_view;
string myname; std::string myname;
float x, y; // 2D projection coords of bbox centre relative to origin float x, y; // 2D projection coords of bbox centre relative to origin
float cx, cy, cz; // coords of bbox centre in 3D space float cx, cy, cz; // coords of bbox centre in 3D space
float pageX, pageY; // required coords of centre of bbox projection on page float pageX, pageY; // required coords of centre of bbox projection on page
@ -80,12 +84,10 @@ private:
}; };
class OrthoViews class OrthoViews
{ {
public: public:
OrthoViews(const char * pagename, const char * partname); OrthoViews(App::Document*, const char * pagename, const char * partname);
~OrthoViews(); ~OrthoViews();
void set_primary(gp_Dir facing, gp_Dir right); void set_primary(gp_Dir facing, gp_Dir right);
@ -116,16 +118,16 @@ private:
void calc_scale(); void calc_scale();
void process_views(); void process_views();
int index(int rel_x, int rel_y); int index(int rel_x, int rel_y);
void slotDeletedObject(const App::DocumentObject& Obj);
void slotDeletedDocument(const App::Document& Obj);
private: private:
vector<orthoview *> views; std::vector<orthoview *> views;
Base::BoundBox3d bbox; Base::BoundBox3d bbox;
App::Document * parent_doc; App::Document * parent_doc;
App::DocumentObject * part; App::DocumentObject * part;
App::DocumentObject * page; App::DocumentObject * page;
string page_name, part_name;
int large[4]; // arrays containing page size info [margin_x, margin_y, size_x, size_y] = [x1, y1, x2-x1, y2-y1] int large[4]; // arrays containing page size info [margin_x, margin_y, size_x, size_y] = [x1, y1, x2-x1, y2-y1]
int small_h[4], small_v[4]; // page size avoiding title block, using maximum horizontal / vertical space int small_h[4], small_v[4]; // page size avoiding title block, using maximum horizontal / vertical space
int * page_dims; // points to one of above arrays for which set of page dimensions to use int * page_dims; // points to one of above arrays for which set of page dimensions to use
@ -146,6 +148,8 @@ private:
bool hidden, smooth; bool hidden, smooth;
bool autodims; bool autodims;
boost::BOOST_SIGNALS_NAMESPACE::scoped_connection connectDocumentDeletedObject;
boost::BOOST_SIGNALS_NAMESPACE::scoped_connection connectApplicationDeletedDocument;
}; };