Fix #41 Projoection Group Spacing

Fix glitch when change First <-> Third Angle
This commit is contained in:
WandererFan 2016-03-26 14:17:01 -04:00 committed by wmayer
parent 1b52a517bf
commit 96d817e280
5 changed files with 44 additions and 35 deletions

View File

@ -117,18 +117,7 @@ Base::BoundBox3d DrawProjGroup::getBoundingBox() const
TechDraw::DrawPage * DrawProjGroup::getPage(void) const
{
//TODO: DrawView already has DrawPage* findParentPage()
return findParentPage();
//TechDraw::DrawPage *ret = NULL;
//std::vector<App::DocumentObject*> parent = getInList();
//for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
// if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) {
// ret = static_cast<DrawPage *>(*it);
// }
//}
//return ret;
}
// Function provided by Joe Dowsett, 2014
@ -203,11 +192,13 @@ void DrawProjGroup::minimumBbViews(DrawProjGroupItem *viewPtrs[10],
void DrawProjGroup::onChanged(const App::Property* prop)
{
//TODO: For some reason, when the projection type is changed, the isometric views show change appropriately, but the orthographic ones dont... Or vice-versa.
if ( prop == &ProjectionType ||
prop == &ScaleType ||
if (!isRestoring()) {
if ( prop == &ProjectionType ) {
resetPositions();
execute();
} else if (prop == &ScaleType ||
prop == &viewOrientationMatrix ||
prop == &Scale ) {
if (!isRestoring()) {
execute();
}
}
@ -494,45 +485,45 @@ bool DrawProjGroup::distributeProjections()
double xSpacing = spacingX.getValue(); //in mm
double ySpacing = spacingY.getValue(); //in mm
if (viewPtrs[0]) {
if (viewPtrs[0] && viewPtrs[0]->allowAutoPos()) {
double displace = std::max(bboxes[0].LengthX() + bboxes[4].LengthX(),
bboxes[0].LengthY() + bboxes[4].LengthY());
viewPtrs[0]->X.setValue(displace / -2.0 - xSpacing);
viewPtrs[0]->Y.setValue(displace / 2.0 + ySpacing);
}
if (viewPtrs[1]) {
if (viewPtrs[1] && viewPtrs[1]->allowAutoPos()) {
viewPtrs[1]->Y.setValue((bboxes[1].LengthY() + bboxes[4].LengthY()) / 2.0 + ySpacing);
}
if (viewPtrs[2]) {
if (viewPtrs[2] && viewPtrs[2]->allowAutoPos()) {
double displace = std::max(bboxes[2].LengthX() + bboxes[4].LengthX(),
bboxes[2].LengthY() + bboxes[4].LengthY());
viewPtrs[2]->X.setValue(displace / 2.0 + xSpacing);
viewPtrs[2]->Y.setValue(displace / 2.0 + ySpacing);
}
if (viewPtrs[3]) {
if (viewPtrs[3] && viewPtrs[3]->allowAutoPos()) {
viewPtrs[3]->X.setValue((bboxes[3].LengthX() + bboxes[4].LengthX()) / -2.0 - xSpacing);
}
if (viewPtrs[4]) { // TODO: Move this check above, and figure out a sane bounding box based on other existing views
}
if (viewPtrs[5]) {
if (viewPtrs[5] && viewPtrs[5]->allowAutoPos()) {
viewPtrs[5]->X.setValue((bboxes[5].LengthX() + bboxes[4].LengthX()) / 2.0 + xSpacing);
}
if (viewPtrs[6]) {
if (viewPtrs[6] && viewPtrs[6]->allowAutoPos()) { //"Rear"
if (viewPtrs[5])
viewPtrs[6]->X.setValue((bboxes[6].LengthX() + bboxes[4].LengthX()) / 2.0 + bboxes[5].LengthX() + 2 * xSpacing);
viewPtrs[6]->X.setValue(viewPtrs[5]->X.getValue() + bboxes[5].LengthX()/2.0 + xSpacing + bboxes[6].LengthX() / 2.0 );
else
viewPtrs[6]->X.setValue((bboxes[6].LengthX() + bboxes[4].LengthX()) / 2.0 + xSpacing);
}
if (viewPtrs[7]) {
if (viewPtrs[7] && viewPtrs[7]->allowAutoPos()) {
double displace = std::max(bboxes[7].LengthX() + bboxes[4].LengthX(),
bboxes[7].LengthY() + bboxes[4].LengthY());
viewPtrs[7]->X.setValue(displace / -2.0 - xSpacing);
viewPtrs[7]->Y.setValue(displace / -2.0 - ySpacing);
}
if (viewPtrs[8]) {
if (viewPtrs[8] && viewPtrs[8]->allowAutoPos()) {
viewPtrs[8]->Y.setValue((bboxes[8].LengthY() + bboxes[4].LengthY()) / -2.0 - ySpacing);
}
if (viewPtrs[9]) {
if (viewPtrs[9] && viewPtrs[9]->allowAutoPos()) {
double displace = std::max(bboxes[9].LengthX() + bboxes[4].LengthX(),
bboxes[9].LengthY() + bboxes[4].LengthY());
viewPtrs[9]->X.setValue(displace / 2.0 + xSpacing);
@ -542,6 +533,17 @@ bool DrawProjGroup::distributeProjections()
return true;
}
void DrawProjGroup::resetPositions(void)
{
const std::vector<App::DocumentObject *> &views = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
DrawView *view = dynamic_cast<DrawView *>(*it);
if(view->getTypeId() == DrawProjGroupItem::getClassTypeId()) {
view->setAutoPos(true);
}
}
}
//TODO: Turn this into a command so it can be issued from python
void DrawProjGroup::setFrontViewOrientation(const Base::Matrix4D &newMat)
{

View File

@ -82,7 +82,7 @@ public:
/// Automatically position child views
bool distributeProjections(void);
void resetPositions(void);
/// Changes child views' coordinate space
/*!
* Used to set the Direction and XAxisDirection in child views

View File

@ -77,6 +77,8 @@ DrawView::DrawView(void)
ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view");
Scale.setStatus(App::Property::ReadOnly,true);
autoPos = true;
}
DrawView::~DrawView()
@ -136,9 +138,11 @@ void DrawView::onChanged(const App::Property* prop)
//TODO else if (ScaleType.isValue("Automatic"))...
DrawView::execute();
} else if (prop == &X ||
prop == &Y ||
prop == &Rotation) {
DrawView::execute(); //trigger stuff to happen on Gui side
prop == &Y) {
setAutoPos(false);
DrawView::execute();
} else if (prop == &Rotation) {
DrawView::execute();
}
}

View File

@ -69,10 +69,13 @@ public:
virtual PyObject *getPyObject(void);
DrawPage* findParentPage() const;
bool allowAutoPos() {return autoPos;};
void setAutoPos(bool state) {autoPos = state;};
protected:
void onChanged(const App::Property* prop);
std::string pageFeatName;
bool autoPos;
private:
static const char* ScaleTypeEnums[];

View File

@ -62,8 +62,9 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView) : ui(new Ui_Task
blockUpdate = true;
setFractionalScale(multiView->Scale.getValue());
ui->projection->setCurrentIndex(multiView->ProjectionType.getValue());
setFractionalScale(multiView->Scale.getValue());
ui->cmbScaleType->setCurrentIndex(multiView->ScaleType.getValue());
// Initially toggle view checkboxes if needed
@ -410,4 +411,3 @@ bool TaskDlgProjGroup::reject()
#include "moc_TaskProjGroup.cpp"