diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp
index 9b92e6449e..0ae94e398e 100644
--- a/src/Mod/TechDraw/App/DrawProjGroup.cpp
+++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp
@@ -292,6 +292,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
addView(view); //from DrawViewCollection - add to ProjGroup Views
moveToCentre();
+ view->recompute();
}
return view;
diff --git a/src/Mod/TechDraw/App/DrawProjGroup.h b/src/Mod/TechDraw/App/DrawProjGroup.h
index 589c7b63b5..6ccc051146 100644
--- a/src/Mod/TechDraw/App/DrawProjGroup.h
+++ b/src/Mod/TechDraw/App/DrawProjGroup.h
@@ -114,25 +114,11 @@ public:
/// Allowed projection types - either Document, First Angle or Third Angle
static const char* ProjectionTypeEnums[];
-protected:
- void onChanged(const App::Property* prop);
-
- //! Moves anchor view to keep our bounding box centre on the origin
- void moveToCentre();
-
- /// Annoying helper - keep in sync with DrawProjGroupItem::TypeEnums
- /*!
- * \TODO See note regarding App::PropertyEnumeration on my wiki page http://freecadweb.org/wiki/index.php?title=User:Ian.rees
- * \return true iff 'in' is a valid name for an orthographic/isometric view
- */
- bool checkViewProjType(const char *in);
-
- /// Sets Direction and XAxisDirection in v
+ /// Sets Direction in v
/*!
* Applies viewOrientationMatrix to appropriate unit vectors depending on projType
*/
void setViewOrientation(DrawProjGroupItem *v, const char *projType) const;
-
/// Populates an array of DrawProjGroupItem*s arranged for drawing
/*!
* Setup array of pointers to the views that we're displaying,
@@ -151,6 +137,20 @@ protected:
* FTRight T FTL
*
*/
+
+protected:
+ void onChanged(const App::Property* prop);
+
+ //! Moves anchor view to keep our bounding box centre on the origin
+ void moveToCentre();
+
+ /// Annoying helper - keep in sync with DrawProjGroupItem::TypeEnums
+ /*!
+ * \TODO See note regarding App::PropertyEnumeration on my wiki page http://freecadweb.org/wiki/index.php?title=User:Ian.rees
+ * \return true iff 'in' is a valid name for an orthographic/isometric view
+ */
+ bool checkViewProjType(const char *in);
+
void arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const;
/// Populates array of 10 BoundBox3d's given DrawProjGroupItem *s
diff --git a/src/Mod/TechDraw/App/DrawProjGroupPy.xml b/src/Mod/TechDraw/App/DrawProjGroupPy.xml
index 603a2543b4..516ab280a5 100644
--- a/src/Mod/TechDraw/App/DrawProjGroupPy.xml
+++ b/src/Mod/TechDraw/App/DrawProjGroupPy.xml
@@ -33,6 +33,11 @@
getItemByLabel(string projectionType) - return specified Projection Item
+
+
+ setViewOrientation(DrawProjGroupItem item, string projectionType) - sets item's view Direction according to projectionType
+
+
diff --git a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
index cd177a5a2b..cb016fdde6 100644
--- a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
+++ b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
@@ -24,8 +24,7 @@ PyObject* DrawProjGroupPy::addProjection(PyObject* args)
const char* projType;
if (!PyArg_ParseTuple(args, "s", &projType)) {
- Base::Console().Error("Error: DrawProjGroupPy::addProjection - Bad Arg - not string\n");
- return NULL;
+ throw Py::Exception();
}
DrawProjGroup* projGroup = getDrawProjGroupPtr();
@@ -40,8 +39,7 @@ PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
const char* projType;
if (!PyArg_ParseTuple(args, "s", &projType)) {
- Base::Console().Error("Error: DrawProjGroupPy::removeProjection - Bad Arg - not string\n");
- return NULL;
+ throw Py::Exception();
}
DrawProjGroup* projGroup = getDrawProjGroupPtr();
@@ -63,8 +61,7 @@ PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
const char* projType;
if (!PyArg_ParseTuple(args, "s", &projType)) {
- Base::Console().Error("Error: DrawProjGroupPy::getItemByLabel - Bad Arg - not string\n");
- return NULL;
+ throw Py::Exception();
}
DrawProjGroup* projGroup = getDrawProjGroupPtr();
@@ -74,6 +71,27 @@ PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
return new DrawProjGroupItemPy(newProj);
}
+PyObject* DrawProjGroupPy::setViewOrientation(PyObject* args)
+{
+ const char* projType;
+ PyObject* pcObj;
+ if (!PyArg_ParseTuple(args, "Os", &pcObj,&projType))
+ throw Py::Exception();
+
+ App::DocumentObject* obj = static_cast(pcObj)->getDocumentObjectPtr();
+ if (obj->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
+ TechDraw::DrawProjGroupItem* view = static_cast(obj);
+ TechDraw::DrawProjGroup* projGroup = getDrawProjGroupPtr();
+ projGroup->setViewOrientation( view, projType );
+
+ } else {
+ Base::Console().Message("'%s' is not a DrawProjGroup Item, it will be ignored.\n", obj->Label.getValue());
+ }
+
+ return Py_None;
+}
+
+
PyObject *DrawProjGroupPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp
index 730ab53398..1e5845a52a 100644
--- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp
+++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp
@@ -418,7 +418,25 @@ void MDIViewPage::updateDrawing(bool forceUpdate)
}
}
+void MDIViewPage::redrawAllViews()
+{
+ const std::vector &upviews = m_view->getViews();
+ for(std::vector::const_iterator it = upviews.begin(); it != upviews.end(); ++it) {
+ (*it)->updateView(true);
+ }
+}
+void MDIViewPage::redraw1View(TechDraw::DrawView* dv)
+{
+ std::string dvName = dv->getNameInDocument();
+ const std::vector &upviews = m_view->getViews();
+ for(std::vector::const_iterator it = upviews.begin(); it != upviews.end(); ++it) {
+ std::string qgivName = (*it)->getViewObject()->getNameInDocument();
+ if(dvName == qgivName) {
+ (*it)->updateView(true);
+ }
+ }
+}
void MDIViewPage::findMissingViews(const std::vector &list, std::vector &missing)
{
for(std::vector::const_iterator it = list.begin(); it != list.end(); ++it) {
diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.h b/src/Mod/TechDraw/Gui/MDIViewPage.h
index 6acf19de85..29ff8ac2d3 100644
--- a/src/Mod/TechDraw/Gui/MDIViewPage.h
+++ b/src/Mod/TechDraw/Gui/MDIViewPage.h
@@ -37,6 +37,7 @@ QT_END_NAMESPACE
namespace TechDraw {
class DrawTemplate;
+class DrawView;
}
namespace TechDrawGui
@@ -86,6 +87,9 @@ public:
QPointF getTemplateCenter(TechDraw::DrawTemplate *obj);
void centerOnPage(void);
+ void redrawAllViews(void);
+ void redraw1View(TechDraw::DrawView* dv);
+
public Q_SLOTS:
void setRenderer(QAction *action);
diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp
index 15bee443ed..56973ecdb4 100644
--- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp
+++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp
@@ -38,12 +38,15 @@
#include
#include
+#include
#include
#include
#include
#include "ViewProviderProjGroup.h"
+#include "ViewProviderProjGroupItem.h"
+#include "ViewProviderPage.h"
#include "TaskProjGroup.h"
#include
@@ -93,6 +96,12 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
// Slot for Projection Type (layout)
connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int)));
+
+ m_page = multiView->findParentPage();
+ Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_page->getDocument());
+ Gui::ViewProvider* vp = activeGui->getViewProvider(m_page);
+ ViewProviderPage* dvp = dynamic_cast(vp);
+ m_mdi = dvp->getMDIViewPage();
}
TaskProjGroup::~TaskProjGroup()
@@ -106,8 +115,12 @@ void TaskProjGroup::viewToggled(bool toggle)
QString viewName = sender()->objectName();
int index = viewName.mid(7).toInt();
const char *viewNameCStr = viewChkIndexToCStr(index);
+ App::DocumentObject* newObj;
+ TechDraw::DrawView* newView;
if ( toggle && !multiView->hasProjection( viewNameCStr ) ) {
- multiView->addProjection( viewNameCStr );
+ newObj = multiView->addProjection( viewNameCStr );
+ newView = static_cast(newObj);
+ m_mdi->redraw1View(newView);
} else if ( !toggle && multiView->hasProjection( viewNameCStr ) ) {
multiView->removeProjection( viewNameCStr );
}
diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h
index 28cfd6f8eb..b1a5cbd597 100644
--- a/src/Mod/TechDraw/Gui/TaskProjGroup.h
+++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h
@@ -28,6 +28,8 @@
#include
#include
+#include "MDIViewPage.h"
+
#include
#include
@@ -37,11 +39,13 @@
class Ui_TaskProjGroup;
namespace TechDraw {
- class DrawProjGroup;
+class DrawProjGroup;
+class DrawPage;
}
namespace TechDrawGui
{
+class MDIViewPage;
class ViewProviderProjGroup;
class TaskProjGroup : public QWidget
@@ -93,6 +97,9 @@ protected:
//ViewProviderProjGroup *viewProvider;
TechDraw::DrawProjGroup* multiView;
bool m_createMode;
+ TechDraw::DrawPage* m_page;
+ MDIViewPage* m_mdi;
+
};
/// Simulation dialog for the TaskView