Correct delayed update when adding views to ProjectionGroup
This commit is contained in:
parent
6abce56595
commit
a912ccd9bb
|
@ -292,6 +292,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
|||
|
||||
addView(view); //from DrawViewCollection - add to ProjGroup Views
|
||||
moveToCentre();
|
||||
view->recompute();
|
||||
}
|
||||
|
||||
return view;
|
||||
|
|
|
@ -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
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
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
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
<UserDocu>getItemByLabel(string projectionType) - return specified Projection Item</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setViewOrientation">
|
||||
<Documentation>
|
||||
<UserDocu>setViewOrientation(DrawProjGroupItem item, string projectionType) - sets item's view Direction according to projectionType</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -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<App::DocumentObjectPy*>(pcObj)->getDocumentObjectPtr();
|
||||
if (obj->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
|
||||
TechDraw::DrawProjGroupItem* view = static_cast<TechDraw::DrawProjGroupItem*>(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;
|
||||
|
|
|
@ -418,7 +418,25 @@ void MDIViewPage::updateDrawing(bool forceUpdate)
|
|||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::redrawAllViews()
|
||||
{
|
||||
const std::vector<QGIView *> &upviews = m_view->getViews();
|
||||
for(std::vector<QGIView *>::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<QGIView *> &upviews = m_view->getViews();
|
||||
for(std::vector<QGIView *>::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<App::DocumentObject*> &list, std::vector<App::DocumentObject*> &missing)
|
||||
{
|
||||
for(std::vector<App::DocumentObject*>::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -38,12 +38,15 @@
|
|||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPart.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
||||
|
||||
#include "ViewProviderProjGroup.h"
|
||||
#include "ViewProviderProjGroupItem.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "TaskProjGroup.h"
|
||||
#include <Mod/TechDraw/Gui/ui_TaskProjGroup.h>
|
||||
|
||||
|
@ -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<ViewProviderPage*>(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<TechDraw::DrawView*>(newObj);
|
||||
m_mdi->redraw1View(newView);
|
||||
} else if ( !toggle && multiView->hasProjection( viewNameCStr ) ) {
|
||||
multiView->removeProjection( viewNameCStr );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "MDIViewPage.h"
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskProjGroup.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user