Merge pull request #279 from WandererFan/PreProd

TechDraw bug fixes
This commit is contained in:
wwmayer 2016-09-14 14:57:00 +02:00 committed by GitHub
commit cccf1ee613
63 changed files with 878 additions and 467 deletions

View File

@ -134,6 +134,11 @@ private:
throw Py::Exception(Part::PartExceptionOCCError, e->GetMessageString());
}
if (edgeList.empty()) {
Base::Console().Log("LOG - edgeWalker: input is empty\n");
return Py::None();
}
bool biggie;
if (inclBig == Py_True) {
biggie = true;
@ -142,15 +147,23 @@ private:
}
PyObject* result = PyList_New(0);
EdgeWalker ew;
ew.loadEdges(edgeList);
ew.perform();
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,biggie); //false==>do not include biggest wires
for (auto& w:sortedWires) {
PyList_Append(result,new TopoShapeWirePy(new TopoShape(w)));
try {
EdgeWalker ew;
ew.loadEdges(edgeList);
bool success = ew.perform();
if (success) {
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,biggie); //false==>do not include biggest wires
for (auto& w:sortedWires) {
PyList_Append(result,new TopoShapeWirePy(new TopoShape(w)));
}
} else {
Base::Console().Warning("edgeWalker: input is not planar graph. Wire detection not done\n");
}
}
catch (Base::Exception &e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());
}
return Py::asObject(result);
}
@ -179,12 +192,31 @@ private:
throw Py::Exception(Part::PartExceptionOCCError, e->GetMessageString());
}
EdgeWalker ew;
ew.loadEdges(edgeList);
ew.perform();
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,true);
PyObject* outerWire = new TopoShapeWirePy(new TopoShape(*sortedWires.begin()));
if (edgeList.empty()) {
Base::Console().Log("LOG - findOuterWire: input is empty\n");
return Py::None();
}
PyObject* outerWire = nullptr;
bool success = false;
try {
EdgeWalker ew;
ew.loadEdges(edgeList);
success = ew.perform();
if (success) {
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,true);
outerWire = new TopoShapeWirePy(new TopoShape(*sortedWires.begin()));
} else {
Base::Console().Warning("findOuterWire: input is not planar graph. Wire detection not done\n");
}
}
catch (Base::Exception &e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());
}
if (!success) {
return Py::None();
}
return Py::asObject(outerWire);
}
};

View File

@ -107,7 +107,6 @@ void DrawPage::onChanged(const App::Property* prop)
} else if (prop == &Views) {
if (!isRestoring()) {
//TODO: reload if Views prop changes (ie adds/deletes)
//touch();
}
} else if(prop == &Scale) {
// touch all views in the Page as they may be dependent on this scale
@ -136,6 +135,8 @@ void DrawPage::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawPage::execute(void)
{
//Page is just a property storage area? no real logic involved?
//all this does is trigger onChanged in this and ViewProviderPage
Template.touch();
Views.touch();
return App::DocumentObject::StdReturn;
@ -236,9 +237,9 @@ int DrawPage::addView(App::DocumentObject *docObj)
{
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
return -1;
DrawView* view = static_cast<DrawView*>(docObj);
//position all new views in center of Page (exceptDVDimension)
DrawView* view = dynamic_cast<DrawView*>(docObj);
if (!docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
view->X.setValue(getPageWidth()/2.0);
view->Y.setValue(getPageHeight()/2.0);

View File

@ -18,6 +18,11 @@
<UserDocu>addView(DrawView) - Add a View to this Page</UserDocu>
</Documentation>
</Methode>
<Methode Name="removeView">
<Documentation>
<UserDocu>removeView(DrawView) - Remove a View to this Page</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPageWidth">
<Documentation>
<UserDocu>Return the width of this page</UserDocu>

View File

@ -27,11 +27,8 @@ PyObject* DrawPagePy::addView(PyObject* args)
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
Base::Console().Error("Error: DrawPagePy::addView - Bad Arg - not DocumentObject\n");
return NULL;
//TODO: sb PyErr??
//PyErr_SetString(PyExc_TypeError,"addView expects a DrawView");
//return -1;
PyErr_SetString(PyExc_TypeError, "DrawPagePy::AddView - Bad Arg - not DocumentObject");
return nullptr;
}
DrawPage* page = getDrawPagePtr(); //get DrawPage for pyPage
@ -45,6 +42,28 @@ PyObject* DrawPagePy::addView(PyObject* args)
return PyInt_FromLong((long) rc);
}
PyObject* DrawPagePy::removeView(PyObject* args)
{
//this implements iRC = pyPage.removeView(pyView) -or-
//doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
PyErr_SetString(PyExc_TypeError, "DrawPagePy::removeView - Bad Arg - not DocumentObject");
return nullptr;
}
DrawPage* page = getDrawPagePtr(); //get DrawPage for pyPage
//how to validate that obj is DrawView before use??
DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj);
DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView
int rc = page->removeView(view);
return PyInt_FromLong((long) rc);
}
// double getPageWidth() const;
PyObject* DrawPagePy::getPageWidth(PyObject *args)
{

View File

@ -242,17 +242,6 @@ App::DocumentObject * DrawProjGroup::getProjObj(const char *viewProjType) const
return 0;
}
bool DrawProjGroup::hasProjection(const char *viewProjType) const
{
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if( view && strcmp(viewProjType, view->Type.getValueAsString()) == 0 ) {
return true;
}
}
return false;
}
bool DrawProjGroup::checkViewProjType(const char *in)
{
if ( strcmp(in, "Front") == 0 ||
@ -270,13 +259,27 @@ bool DrawProjGroup::checkViewProjType(const char *in)
return false;
}
//********************************
// ProjectionItem A/D/I
//********************************
bool DrawProjGroup::hasProjection(const char *viewProjType) const
{
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if( view && strcmp(viewProjType, view->Type.getValueAsString()) == 0 ) {
return true;
}
}
return false;
}
App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
{
DrawProjGroupItem *view( nullptr );
if ( checkViewProjType(viewProjType) && !hasProjection(viewProjType) ) {
std::string FeatName = getDocument()->getUniqueObjectName("ProjItem");
auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem",
auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem", //add to Document
FeatName.c_str() ) );
view = static_cast<TechDraw::DrawProjGroupItem *>( docObj );
@ -287,13 +290,50 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
view->Label.setValue( viewProjType );
setViewOrientation( view, viewProjType );
addView(view); //from DrawViewCollection
addView(view); //from DrawViewCollection - add to ProjGroup Views
moveToCentre();
}
return view;
}
int DrawProjGroup::removeProjection(const char *viewProjType)
{
if ( checkViewProjType(viewProjType) ) {
if( !hasProjection(viewProjType) ) {
throw Base::Exception("The projection doesn't exist in the group");
}
// Iterate through the child views and find the projection type
for( auto it : Views.getValues() ) {
auto projPtr( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if( projPtr ) {
if ( strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) {
removeView(projPtr); // Remove from collection
getDocument()->remObject( it->getNameInDocument() ); // Remove from the document
moveToCentre();
return Views.getValues().size();
}
}
}
}
return -1;
}
int DrawProjGroup::purgeProjections()
{
while (!Views.getValues().empty()) {
std::vector<DocumentObject*> views = Views.getValues();
DrawProjGroupItem* dpgi;
DocumentObject* dObj = views.back();
dpgi = dynamic_cast<DrawProjGroupItem*>(dObj);
std::string itemName = dpgi->Type.getValueAsString();
removeProjection(itemName.c_str());
}
return Views.getValues().size();
}
void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projType) const
{
Base::Vector3d dir, xDir;
@ -351,30 +391,6 @@ void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projTyp
v->XAxisDirection.setValue(xDir);
}
int DrawProjGroup::removeProjection(const char *viewProjType)
{
if ( checkViewProjType(viewProjType) ) {
if( !hasProjection(viewProjType) ) {
throw Base::Exception("The projection doesn't exist in the group");
}
// Iterate through the child views and find the projection type
for( auto it : Views.getValues() ) {
auto projPtr( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if( projPtr ) {
if ( strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) {
// Remove from the document
getDocument()->remObject( it->getNameInDocument() );
moveToCentre();
return Views.getValues().size();
}
}
}
}
return -1;
}
void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
{
for (int i=0; i<10; ++i) {

View File

@ -83,6 +83,7 @@ public:
*/
int removeProjection(const char *viewProjType);
int purgeProjections();
/// Automatically position child views
bool distributeProjections(void);
void resetPositions(void);

View File

@ -57,8 +57,8 @@ DrawProjGroupItem::DrawProjGroupItem(void)
ADD_PROPERTY(Type, ((long)0));
//projection group controls these
Direction.setStatus(App::Property::Hidden,true);
XAxisDirection.setStatus(App::Property::Hidden,true);
Direction.setStatus(App::Property::ReadOnly,true);
XAxisDirection.setStatus(App::Property::ReadOnly,true);
Scale.setStatus(App::Property::ReadOnly,true);
ScaleType.setStatus(App::Property::ReadOnly,true);
}

View File

@ -31,8 +31,6 @@
namespace TechDraw
{
/** Base class of all View Features in the drawing module
*/
class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart
{
PROPERTY_HEADER(TechDraw::DrawProjGroupItem);

View File

@ -23,6 +23,11 @@
<UserDocu>removeProjection(string projectionType) - Remove specified Projection Item from this Group. Returns int number of views in Group.</UserDocu>
</Documentation>
</Methode>
<Methode Name="purgeProjections">
<Documentation>
<UserDocu>purgeProjections() - Remove all Projection Items from this Group. Returns int number of views in Group (0).</UserDocu>
</Documentation>
</Methode>
<Methode Name="getItemByLabel">
<Documentation>
<UserDocu>getItemByLabel(string projectionType) - return specified Projection Item</UserDocu>

View File

@ -50,6 +50,14 @@ PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
return PyInt_FromLong((long) i);;
}
PyObject* DrawProjGroupPy::purgeProjections(PyObject* args)
{
DrawProjGroup* projGroup = getDrawProjGroupPtr();
int i = projGroup->purgeProjections();
return PyInt_FromLong((long) i);;
}
PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
{
const char* projType;

View File

@ -129,7 +129,6 @@ short DrawView::mustExecute() const
if (!isRestoring()) {
result = (X.isTouched() ||
Y.isTouched() ||
Rotation.isTouched() ||
Scale.isTouched() ||
ScaleType.isTouched() );
}

View File

@ -76,8 +76,7 @@ void DrawViewClip::onChanged(const App::Property* prop)
{
if (prop == &Height ||
prop == &Width ||
prop == &ShowFrame ||
prop == &ShowLabels) {
prop == &Views) {
if (!isRestoring()) {
DrawViewClip::execute();
}

View File

@ -68,6 +68,54 @@ int DrawViewCollection::addView(DrawView *view)
return Views.getSize();
}
int DrawViewCollection::removeView(DrawView *view)
{
// Remove the view from the the collection
const std::vector<App::DocumentObject*> currViews = Views.getValues();
std::vector<App::DocumentObject*> newViews;
std::vector<App::DocumentObject*>::const_iterator it = currViews.begin();
for (; it != currViews.end(); it++) {
std::string viewName = view->getNameInDocument();
if (viewName.compare((*it)->getNameInDocument()) != 0) {
newViews.push_back((*it));
}
}
Views.setValues(newViews);
//TODO: also have to touch the parent page's views to get repaint??
DrawPage* page = findParentPage();
if (page) {
page->Views.touch();
}
return Views.getSize();
}
//make sure everything in View list represents a real DrawView docObj and occurs only once
void DrawViewCollection::rebuildViewList()
{
const std::vector<App::DocumentObject*> currViews = Views.getValues();
std::vector<App::DocumentObject*> newViews;
std::vector<App::DocumentObject*> children = getOutList();
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) {
//TechDraw::DrawView* view = static_cast<TechDraw::DrawView *>(*it);
bool found = false;
for (auto& v:currViews) {
if (v == (*it)) {
found = true;
break;
}
}
if (found) {
newViews.push_back((*it));
}
}
} // newViews contains only valid items, but may have duplicates
sort( newViews.begin(), newViews.end() );
newViews.erase( unique( newViews.begin(), newViews.end() ), newViews.end() );
Views.setValues(newViews);
}
short DrawViewCollection::mustExecute() const
{
// If Tolerance Property is touched
@ -87,9 +135,8 @@ int DrawViewCollection::countChildren()
const std::vector<App::DocumentObject *> &views = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::DocumentObject *docObj = dynamic_cast<App::DocumentObject *>(*it);
if(docObj->getTypeId().isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId())) {
TechDraw::DrawViewCollection *viewCollection = dynamic_cast<TechDraw::DrawViewCollection *>(*it);
if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId())) {
TechDraw::DrawViewCollection *viewCollection = static_cast<TechDraw::DrawViewCollection *>(*it);
numChildren += viewCollection->countChildren() + 1;
} else {
numChildren += 1;
@ -127,7 +174,7 @@ App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::DocumentObject *docObj = *it;
if(docObj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(*it);
TechDraw::DrawView *view = static_cast<TechDraw::DrawView *>(*it);
// Set scale factor of each view
view->ScaleType.setValue("Document");
@ -140,7 +187,7 @@ App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::DocumentObject *docObj = *it;
if(docObj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(*it);
TechDraw::DrawView *view = static_cast<TechDraw::DrawView *>(*it);
view->ScaleType.setValue("Custom");
// Set scale factor of each view
@ -159,6 +206,10 @@ QRectF DrawViewCollection::getRect() const
QRectF result;
for (auto& v:Views.getValues()) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(v);
if (!view) {
throw Base::Exception("DrawViewCollection::getRect bad View\n");
}
result = result.united(view->getRect().translated(view->X.getValue(),view->Y.getValue()));
}
return QRectF(0,0,Scale.getValue() * result.width(),Scale.getValue() * result.height());

View File

@ -48,6 +48,8 @@ public:
short mustExecute() const;
int addView(DrawView *view);
int removeView(DrawView *view);
void rebuildViewList(void);
int countChildren();
/** @name methods overide Feature */

View File

@ -13,6 +13,16 @@
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>Feature for creating and manipulating Technical Drawing View Collections</UserDocu>
</Documentation>
<Methode Name="addView">
<Documentation>
<UserDocu>addView(DrawView object) - Add a new View to this Group. Returns count of views.</UserDocu>
</Documentation>
</Methode>
<Methode Name="removeView">
<Documentation>
<UserDocu>removeView(DrawView object) - Remove specified Viewfrom this Group. Returns count of views in Group.</UserDocu>
</Documentation>
</Methode>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@ -14,6 +14,41 @@ std::string DrawViewCollectionPy::representation(void) const
{
return std::string("<DrawViewCollection object>");
}
PyObject* DrawViewCollectionPy::addView(PyObject* args)
{
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
PyErr_SetString(PyExc_TypeError, "DrawViewCollectionPy::addView - Bad Arg - not DocumentObject");
return nullptr;
}
DrawViewCollection* collect = getDrawViewCollectionPtr();
DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj);
DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView
int i = collect->addView(view);
return PyInt_FromLong((long) i);
}
PyObject* DrawViewCollectionPy::removeView(PyObject* args)
{
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
PyErr_SetString(PyExc_TypeError, "DrawViewCollectionPy::removeView - Bad Arg - not DocumentObject");
return nullptr;
}
DrawViewCollection* collect = getDrawViewCollectionPtr();
DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj);
DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView
int i = collect->removeView(view);
return PyInt_FromLong((long) i);
}
PyObject *DrawViewCollectionPy::getCustomAttributes(const char* /*attr*/) const

View File

@ -198,7 +198,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
}
catch (Standard_Failure) {
Handle_Standard_Failure e4 = Standard_Failure::Caught();
Base::Console().Log("LOG - DVP::execute - buildGeometryObject failed for %s - %s **\n",getNameInDocument(),e4->GetMessageString());
Base::Console().Log("LOG - DVP::execute - extractFaces failed for %s - %s **\n",getNameInDocument(),e4->GetMessageString());
return new App::DocumentObjectExecReturn(e4->GetMessageString());
}
#endif //#if MOD_TECHDRAW_HANDLE_FACES
@ -225,22 +225,10 @@ short DrawViewPart::mustExecute() const
Source.isTouched() ||
Scale.isTouched() ||
ScaleType.isTouched() ||
Tolerance.isTouched());
// don't have to execute DVP, but should update Gui
// ShowHiddenLines.isTouched() ||
// ShowSmoothLines.isTouched() ||
// ShowSeamLines.isTouched() ||
// LineWidth.isTouched() ||
// HiddenWidth.isTouched() ||
// ShowCenters.isTouched() ||
// CenterScale.isTouched() ||
// ShowSectionLine.isTouched() ||
// HorizSectionLine.isTouched() ||
// ArrowUpSection.isTouched() ||
// SymbolSection.isTouched() ||
// HorizCenterLine.isTouched() ||
// VertCenterLine.isTouched());
Tolerance.isTouched() ||
ShowHiddenLines.isTouched() ||
ShowSmoothLines.isTouched() ||
ShowSeamLines.isTouched() );
}
if (result) {
@ -259,28 +247,16 @@ void DrawViewPart::onChanged(const App::Property* prop)
prop == &XAxisDirection ||
prop == &Source ||
prop == &Scale ||
prop == &ScaleType) {
//don't need to execute, but need to update Gui
// prop == &ShowHiddenLines ||
// prop == &ShowSmoothLines ||
// prop == &ShowSeamLines ||
// prop == &LineWidth ||
// prop == &HiddenWidth ||
// prop == &ShowCenters ||
// prop == &CenterScale ||
// prop == &ShowSectionLine ||
// prop == &HorizSectionLine ||
// prop == &ArrowUpSection ||
// prop == &SymbolSection ||
// prop == &HorizCenterLine ||
// prop == &VertCenterLine) {
prop == &ScaleType ||
prop == &ShowHiddenLines ||
prop == &ShowSmoothLines ||
prop == &ShowSeamLines)
try {
App::DocumentObjectExecReturn *ret = recompute();
delete ret;
}
catch (...) {
}
}
}
DrawView::onChanged(prop);
@ -404,10 +380,21 @@ void DrawViewPart::extractFaces()
faceEdges.insert(std::end(faceEdges), std::begin(edgesToAdd),std::end(edgesToAdd));
}
if (faceEdges.empty()) {
Base::Console().Log("LOG - DVP::extractFaces - no faceEdges\n");
return;
}
//find all the wires in the pile of faceEdges
EdgeWalker ew;
ew.loadEdges(faceEdges);
ew.perform();
bool success = ew.perform();
if (!success) {
Base::Console().Warning("DVP::extractFaces - input is not planar graph. No face detection\n");
return;
}
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw,true);

View File

@ -28,6 +28,8 @@
#ifndef _PreComp_
# include <sstream>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepAlgoAPI_Cut.hxx>
@ -113,10 +115,6 @@ short DrawViewSection::mustExecute() const
BaseView.isTouched() ||
SectionNormal.isTouched() ||
SectionOrigin.isTouched() );
//don't need to execute, but need to update Gui
// ShowCutSurface.isTouched() ||
// CutSurfaceColor.isTouched() );
}
if (result) {
return result;
@ -196,6 +194,12 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
return new App::DocumentObjectExecReturn("Section cut has failed");
TopoDS_Shape rawShape = mkCut.Shape();
Bnd_Box testBox;
BRepBndLib::Add(rawShape, testBox);
testBox.SetGap(0.0);
if (testBox.IsVoid()) { //prism & input don't intersect. rawShape is garbage, don't bother.
return DrawView::execute();
}
geometryObject->setTolerance(Tolerance.getValue());
geometryObject->setScale(Scale.getValue());
@ -237,7 +241,9 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
inputCenter,
Direction.getValue(),
validXDir);
builder.Add(newFaces,pFace);
if (!pFace.IsNull()) {
builder.Add(newFaces,pFace);
}
}
sectionFaces = newFaces;
@ -385,28 +391,37 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face,
// }
// }
TopoDS_Face projectedFace;
if (faceEdges.empty()) {
Base::Console().Log("LOG - DVS::projectFace - no faceEdges\n");
return projectedFace;
}
//recreate the wires for this single face
EdgeWalker ew;
ew.loadEdges(faceEdges);
ew.perform();
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
bool success = ew.perform();
if (success) {
std::vector<TopoDS_Wire> fw = ew.getResultNoDups();
TopoDS_Face projectedFace;
if (!fw.empty()) {
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw, true);
if (sortedWires.empty()) {
return projectedFace;
}
if (!fw.empty()) {
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw, true);
if (sortedWires.empty()) {
return projectedFace;
BRepBuilderAPI_MakeFace mkFace(sortedWires.front(),true); //true => only want planes?
std::vector<TopoDS_Wire>::iterator itWire = ++sortedWires.begin(); //starting with second face
for (; itWire != sortedWires.end(); itWire++) {
mkFace.Add(*itWire);
}
projectedFace = mkFace.Face();
}
BRepBuilderAPI_MakeFace mkFace(sortedWires.front(),true); //true => only want planes?
std::vector<TopoDS_Wire>::iterator itWire = ++sortedWires.begin(); //starting with second face
for (; itWire != sortedWires.end(); itWire++) {
mkFace.Add(*itWire);
}
projectedFace = mkFace.Face();
} else {
Base::Console().Warning("DVS::projectFace - input is not planar graph. No face detection\n");
}
return projectedFace;
}

View File

@ -41,8 +41,10 @@
#include <BRepGProp.hxx>
#endif
#include <sstream>
#include <Base/Console.h>
#include <Base/Exception.h>
#include "DrawUtil.h"
#include "EdgeWalker.h"
@ -86,7 +88,7 @@ void edgeVisitor::setGraph(TechDraw::graph& g)
}
//*******************************************************
//* EdgeWalker
//* EdgeWalker methods
//*******************************************************
EdgeWalker::EdgeWalker()
@ -97,6 +99,7 @@ EdgeWalker::~EdgeWalker()
{
}
//loads a list of unique edges into the traversal mechanism
bool EdgeWalker::loadEdges(std::vector<TechDraw::WalkerEdge> edges)
{
for (auto e: edges) {
@ -107,10 +110,14 @@ bool EdgeWalker::loadEdges(std::vector<TechDraw::WalkerEdge> edges)
bool EdgeWalker::loadEdges(std::vector<TopoDS_Edge> edges)
{
if (edges.empty()) {
throw Base::Exception("EdgeWalker has no edges to load\n");
}
std::vector<TopoDS_Vertex> verts = makeUniqueVList(edges);
setSize(verts.size());
std::vector<WalkerEdge> we = makeWalkerEdges(edges, verts);
saveInEdges = edges;
return loadEdges(we);
}
@ -133,15 +140,43 @@ bool EdgeWalker::perform()
for(boost::tie(ei, ei_end) = edges(m_g); ei != ei_end; ++ei)
put(e_index, *ei, edge_count++);
// Test for planarity - we know it is planar, we just want to
// compute the planar embedding as a side-effect
// Test for planarity
typedef std::vector< graph_traits<TechDraw::graph>::edge_descriptor > vec_t;
std::vector<vec_t> embedding(num_vertices(m_g));
boyer_myrvold_planarity_test(boyer_myrvold_params::graph = m_g,
boyer_myrvold_params::embedding = &embedding[0]);
typedef std::vector< graph_traits<TechDraw::graph>::edge_descriptor > kura_edges_t;
kura_edges_t kEdges;
kura_edges_t::iterator ki, ki_end;
graph_traits<TechDraw::graph>::edge_descriptor e1;
// Get the index associated with edge
graph_traits<TechDraw::graph>::edges_size_type
get(boost::edge_index_t,
const TechDraw::graph& m_g,
graph_traits<TechDraw::graph>::edge_descriptor edge);
bool isPlanar = boyer_myrvold_planarity_test(boyer_myrvold_params::graph = m_g,
boyer_myrvold_params::embedding = &embedding[0],
boyer_myrvold_params::kuratowski_subgraph =
std::back_inserter(kEdges));
if (!isPlanar) {
//TODO: remove kura subgraph to make planar??
Base::Console().Log("LOG - EW::perform - input is NOT planar\n");
ki_end = kEdges.end();
std::stringstream ss;
ss << "EW::perform - obstructing edges: ";
for(ki = kEdges.begin(); ki != ki_end; ++ki) {
e1 = *ki;
ss << boost::get(edge_index,m_g,e1) << ",";
}
ss << std::endl;
Base::Console().Log("LOG - %s\n",ss.str().c_str());
return false;
}
m_eV.setGraph(m_g);
//Base::Console().Message("TRACE - EW::perform - setGraph complete\n");
planar_face_traversal(m_g, &embedding[0], m_eV);
//Base::Console().Message("TRACE - EW::perform - traversal complete\n");
return true;
}
@ -155,10 +190,13 @@ ewWireList EdgeWalker::getResult()
std::vector<TopoDS_Wire> EdgeWalker::getResultWires()
{
std::vector<TopoDS_Wire> fw;
ewWireList result = m_eV.getResult();
if (result.wires.empty()) {
return fw;
}
std::vector<ewWire>::iterator iWire = result.wires.begin(); // a WE within [WE]
std::vector<TopoDS_Wire> fw;
for (;iWire != result.wires.end(); iWire++) {
std::vector<WalkerEdge>::iterator iEdge = (*iWire).wedges.begin();
std::vector<TopoDS_Edge> topoEdges;
@ -174,11 +212,15 @@ std::vector<TopoDS_Wire> EdgeWalker::getResultWires()
std::vector<TopoDS_Wire> EdgeWalker::getResultNoDups()
{
std::vector<TopoDS_Wire> fw;
ewWireList result = m_eV.getResult();
result = result.removeDuplicates();
if (result.wires.empty()) {
return fw;
}
result = result.removeDuplicateWires();
std::vector<ewWire>::iterator iWire = result.wires.begin();
std::vector<TopoDS_Wire> fw;
for (;iWire != result.wires.end(); iWire++) {
std::vector<WalkerEdge>::iterator iEdge = (*iWire).wedges.begin();
std::vector<TopoDS_Edge> topoEdges;
@ -250,6 +292,7 @@ std::vector<TopoDS_Vertex> EdgeWalker:: makeUniqueVList(std::vector<TopoDS_Edge>
std::vector<WalkerEdge> EdgeWalker::makeWalkerEdges(std::vector<TopoDS_Edge> edges,
std::vector<TopoDS_Vertex> verts)
{
saveInEdges = edges;
std::vector<WalkerEdge> walkerEdges;
for (auto e:edges) {
TopoDS_Vertex ev1 = TopExp::FirstVertex(e);
@ -261,6 +304,7 @@ std::vector<WalkerEdge> EdgeWalker::makeWalkerEdges(std::vector<TopoDS_Edge> edg
we.v2 = v2dx;
walkerEdges.push_back(we);
}
return walkerEdges;
}
@ -278,61 +322,6 @@ int EdgeWalker::findUniqueVert(TopoDS_Vertex vx, std::vector<TopoDS_Vertex> &uni
return result;
}
/*static*/ bool WalkerEdge::weCompare(WalkerEdge i, WalkerEdge j)
{
return (i.idx < j.idx);
}
bool ewWire::isEqual(ewWire w2)
{
bool result = true;
if (wedges.size() != w2.wedges.size()) {
result = false;
} else {
std::sort(wedges.begin(),wedges.end(),WalkerEdge::weCompare);
std::sort(w2.wedges.begin(),w2.wedges.end(),WalkerEdge::weCompare);
for (unsigned int i = 0; i < w2.wedges.size(); i ++) {
if (wedges.at(i).idx != w2.wedges.at(i).idx) {
result = false;
break;
}
}
}
return result;
}
void ewWire::push_back(WalkerEdge w)
{
wedges.push_back(w);
}
//check wirelist for wires that use the same set of edges, but maybe in a different order.
ewWireList ewWireList::removeDuplicates()
{
ewWireList result;
result.push_back(*(wires.begin())); //save the first ewWire
std::vector<ewWire>::iterator iWire = (wires.begin()) + 1; //starting with second
for (; iWire != wires.end(); iWire++) {
bool addToResult = true;
for (auto& w:result.wires) {
if ((*iWire).isEqual(w)) { //already in result?
addToResult = false;
break;
}
}
if (addToResult) {
result.push_back((*iWire));
}
}
return result;
}
void ewWireList::push_back(ewWire w)
{
wires.push_back(w);
}
std::vector<TopoDS_Wire> EdgeWalker::sortStrip(std::vector<TopoDS_Wire> fw, bool includeBiggest)
{
std::vector<TopoDS_Wire> sortedWires = sortWiresBySize(fw,false); //biggest 1st
@ -431,3 +420,83 @@ std::vector<TopoDS_Wire> EdgeWalker::sortWiresBySize(std::vector<TopoDS_Wire>& w
return box1.SquareExtent() > box2.SquareExtent();
}
//*******************************************
// WalkerEdge Methods
//*******************************************
bool WalkerEdge::isEqual(WalkerEdge w)
{
bool result = false;
if ((( v1 == w.v1) && (v2 == w.v2)) ||
(( v1 == w.v2) && (v2 == w.v1)) ) {
result = true;
}
return result;
}
/*static*/ bool WalkerEdge::weCompare(WalkerEdge i, WalkerEdge j) //used for sorting
{
return (i.idx < j.idx);
}
//*****************************************
// ewWire Methods
//*****************************************
bool ewWire::isEqual(ewWire w2)
{
bool result = true;
if (wedges.size() != w2.wedges.size()) {
result = false;
} else {
std::sort(wedges.begin(),wedges.end(),WalkerEdge::weCompare);
std::sort(w2.wedges.begin(),w2.wedges.end(),WalkerEdge::weCompare);
for (unsigned int i = 0; i < w2.wedges.size(); i ++) {
if (wedges.at(i).idx != w2.wedges.at(i).idx) {
result = false;
break;
}
}
}
return result;
}
void ewWire::push_back(WalkerEdge w)
{
wedges.push_back(w);
}
//***************************************
// ewWireList methods
//***************************************
//check wirelist for wires that use the same set of edges, but maybe in a different order.
ewWireList ewWireList::removeDuplicateWires()
{
ewWireList result;
if (wires.empty()) {
return result;
}
result.push_back(*(wires.begin())); //save the first ewWire
std::vector<ewWire>::iterator iWire = (wires.begin()) + 1; //starting with second
for (; iWire != wires.end(); iWire++) {
bool addToResult = true;
for (auto& w:result.wires) {
if ((*iWire).isEqual(w)) { //already in result?
addToResult = false;
break;
}
}
if (addToResult) {
result.push_back((*iWire));
}
}
return result;
}
void ewWireList::push_back(ewWire w)
{
wires.push_back(w);
}

View File

@ -36,6 +36,7 @@
#include <boost/graph/graph_traits.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/boyer_myrvold_planar_test.hpp>
#include <boost/graph/is_kuratowski_subgraph.hpp>
#include <boost/graph/planar_face_traversal.hpp>
#include <boost/ref.hpp>
@ -59,6 +60,7 @@ class WalkerEdge
{
public:
static bool weCompare(WalkerEdge i, WalkerEdge j);
bool isEqual(WalkerEdge w);
std::size_t v1;
std::size_t v2;
@ -78,7 +80,7 @@ public:
class ewWireList
{
public:
ewWireList removeDuplicates();
ewWireList removeDuplicateWires();
std::vector<ewWire> wires;
void push_back(ewWire e);
@ -119,6 +121,7 @@ public:
std::vector<TopoDS_Vertex> makeUniqueVList(std::vector<TopoDS_Edge> edges);
std::vector<WalkerEdge> makeWalkerEdges(std::vector<TopoDS_Edge> edges,
std::vector<TopoDS_Vertex> verts);
int findUniqueVert(TopoDS_Vertex vx, std::vector<TopoDS_Vertex> &uniqueVert);
std::vector<TopoDS_Wire> sortStrip(std::vector<TopoDS_Wire> fw, bool includeBiggest);
std::vector<TopoDS_Wire> sortWiresBySize(std::vector<TopoDS_Wire>& w, bool reverse = false);

View File

@ -401,8 +401,7 @@ Generic::Generic(const TopoDS_Edge &e)
points.push_back(Base::Vector2D(nodes(i).X(), nodes(i).Y()));
}
} else {
//no polygon representation? approximate with line?
Base::Console().Log("INFO - Generic::Generic(edge) - polygon is NULL\n");
//no polygon representation? approximate with line
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
points.push_back(Base::Vector2D(p.X(), p.Y()));
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));

View File

@ -274,7 +274,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
}
if (circle) {
if ((*itVertex)->isEqual(c1,Precision::Confusion())) {
c1Add = true;
c1Add = false;
}
}

View File

@ -36,6 +36,7 @@
#include <App/FeaturePython.h>
#include <App/PropertyGeo.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <Gui/Action.h>
#include <Gui/Application.h>
@ -103,14 +104,14 @@ TechDraw::DrawPage* _findPage(Gui::Command* cmd)
QObject::tr("Can not determine correct page."));
return page;
} else { //use only page in document
page = dynamic_cast<TechDraw::DrawPage*>(selPages.front());
page = static_cast<TechDraw::DrawPage*>(selPages.front());
}
} else if (selPages.size() > 1) { //multiple pages in selection
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Too many pages"),
QObject::tr("Select exactly 1 page."));
return page;
} else { //use only page in selection
page = dynamic_cast<TechDraw::DrawPage *>(selPages.front());
page = static_cast<TechDraw::DrawPage *>(selPages.front());
}
return page;
@ -172,6 +173,10 @@ void CmdTechDrawNewPageDef::activated(int iMsg)
commitCommand();
TechDraw::DrawPage* fp = dynamic_cast<TechDraw::DrawPage*>(getDocument()->getObject(PageName.c_str()));
if (!fp) {
throw Base::Exception("CmdTechDrawNewPageDef fp not found\n");
}
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(getDocument())->getViewProvider(fp);
TechDrawGui::ViewProviderPage* dvp = dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
if (dvp) {
@ -247,6 +252,9 @@ void CmdTechDrawNewPage::activated(int iMsg)
commitCommand();
TechDraw::DrawPage* fp = dynamic_cast<TechDraw::DrawPage*>(getDocument()->getObject(PageName.c_str()));
if (!fp) {
throw Base::Exception("CmdTechDrawNewPagePick fp not found\n");
}
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(getDocument())->getViewProvider(fp);
TechDrawGui::ViewProviderPage* dvp = dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
if (dvp) {
@ -377,7 +385,7 @@ void CmdTechDrawNewViewSection::activated(int iMsg)
return;
}
App::DocumentObject* dObj = *(shapes.begin());
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(dObj);
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(dObj);
if (dvp->getSectionRef()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("This View already has a related Section. Choose another."));
@ -397,6 +405,9 @@ void CmdTechDrawNewViewSection::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
TechDraw::DrawViewSection* dsv = dynamic_cast<TechDraw::DrawViewSection *>(docObj);
if (!dsv) {
throw Base::Exception("CmdTechDrawNewViewSection DSV not found\n");
}
Gui::Control().showDialog(new TaskDlgSectionView(dvp,dsv));
updateActive();
@ -458,13 +469,15 @@ void CmdTechDrawProjGroup::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str());
doCommand(Doc,"App.activeDocument().%s.Anchor = App.activeDocument().%s.getItemByLabel('%s')",
multiViewName.c_str(),multiViewName.c_str(),anchor.c_str());
// create the rest of the desired views
Gui::Control().showDialog(new TaskDlgProjGroup(multiView));
// add the multiView to the page
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
// create the rest of the desired views
Gui::Control().showDialog(new TaskDlgProjGroup(multiView,true));
// // add the multiView to the page
// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
updateActive();
commitCommand();
}
@ -592,9 +605,9 @@ void CmdTechDrawClipPlus::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewClip::getClassTypeId())) {
clip = dynamic_cast<TechDraw::DrawViewClip*>((*itSel).getObject());
clip = static_cast<TechDraw::DrawViewClip*>((*itSel).getObject());
} else if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
view = dynamic_cast<TechDraw::DrawView*>((*itSel).getObject());
view = static_cast<TechDraw::DrawView*>((*itSel).getObject());
}
}
if (!view) {

View File

@ -33,6 +33,7 @@
#include <QGraphicsView>
# include <App/DocumentObject.h>
# include <Base/Exception.h>
# include <Gui/Action.h>
# include <Gui/Application.h>
# include <Gui/BitmapFactory.h>
@ -94,14 +95,14 @@ TechDraw::DrawPage* _findPageCCD(Gui::Command* cmd)
QObject::tr("Can not determine correct page."));
return page;
} else { //use only page in document
page = dynamic_cast<TechDraw::DrawPage*>(selPages.front());
page = static_cast<TechDraw::DrawPage*>(selPages.front());
}
} else if (selPages.size() > 1) { //multiple pages in selection
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Too many pages"),
QObject::tr("Select exactly 1 page."));
return page;
} else { //use only page in selection
page = dynamic_cast<TechDraw::DrawPage*>(selPages.front());
page = static_cast<TechDraw::DrawPage*>(selPages.front());
}
}
return page;
@ -161,7 +162,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -242,6 +243,9 @@ void CmdTechDrawNewDimension::activated(int iMsg)
,contentStr.c_str());
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
@ -293,7 +297,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -325,6 +329,9 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
doCommand(Doc, "App.activeDocument().%s.FormatSpec = 'R%%value%%'", FeatName.c_str());
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewRadiusDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
@ -377,7 +384,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -411,6 +418,9 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '\xe2\x8c\x80%%value%%'", FeatName.c_str()); // utf-8 encoded diameter symbol
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewDiameterDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
@ -463,7 +473,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -513,6 +523,9 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.Type = '%s'", FeatName.c_str()
, "Distance");
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewLengthDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
@ -567,7 +580,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -615,6 +628,9 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
,"DistanceX");
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewDistanceXDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
@ -669,7 +685,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -716,6 +732,9 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"DistanceY");
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewDistanceYDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
@ -770,7 +789,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = dynamic_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
@ -801,6 +820,9 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
,"Angle");
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewAngleDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
@ -858,7 +880,7 @@ void CmdTechDrawLinkDimension::activated(int iMsg)
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(Part::Feature::getClassTypeId())) {
obj3D = dynamic_cast<Part::Feature*> ((*itSel).getObject());
obj3D = static_cast<Part::Feature*> ((*itSel).getObject());
subs = (*itSel).getSubNames();
}
}
@ -1072,8 +1094,8 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
bool _isValidVertexToEdge(Gui::Command* cmd) {
bool result = false;
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
TechDraw::DrawViewPart* objFeat0 = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
//TechDraw::DrawViewPart* objFeat1 = dynamic_cast<TechDraw::DrawViewPart *>(selection[1].getObject());
TechDraw::DrawViewPart* objFeat0 = static_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
//TechDraw::DrawViewPart* objFeat1 = static_castt<TechDraw::DrawViewPart *>(selection[1].getObject());
const std::vector<std::string> SubNames = selection[0].getSubNames();
if(SubNames.size() == 2) { //there are 2
int eId,vId;

View File

@ -96,7 +96,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
: Gui::MDIView(doc, parent),
m_orientation(QPrinter::Landscape),
m_paperSize(QPrinter::A4),
pageGui(pageVp),
m_vpPage(pageVp),
m_frameState(true)
{
@ -149,7 +149,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
// A fresh page is added and we iterate through its collected children and add these to Canvas View -MLP
// if docobj is a featureviewcollection (ex orthogroup), add its child views. if there are ever children that have children,
// we'll have to make this recursive. -WF
const std::vector<App::DocumentObject*> &grp = pageGui->getPageObject()->Views.getValues();
const std::vector<App::DocumentObject*> &grp = m_vpPage->getDrawPage()->Views.getValues();
std::vector<App::DocumentObject*> childViews;
for (std::vector<App::DocumentObject*>::const_iterator it = grp.begin();it != grp.end(); ++it) {
attachView(*it);
@ -165,7 +165,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
//therefore we need to make sure parentage of the graphics representation is set properly. bit of a kludge.
setDimensionGroups();
App::DocumentObject *obj = pageGui->getPageObject()->Template.getValue();
App::DocumentObject *obj = m_vpPage->getDrawPage()->Template.getValue();
auto pageTemplate( dynamic_cast<TechDraw::DrawTemplate *>(obj) );
if( pageTemplate ) {
attachTemplate(pageTemplate);
@ -312,14 +312,14 @@ bool MDIViewPage::attachView(App::DocumentObject *obj)
void MDIViewPage::updateTemplate(bool forceUpdate)
{
App::DocumentObject *templObj = pageGui->getPageObject()->Template.getValue();
App::DocumentObject *templObj = m_vpPage->getDrawPage()->Template.getValue();
// TODO: what if template has been deleted? templObj will be NULL. segfault?
if (!templObj) {
Base::Console().Log("INFO - MDIViewPage::updateTemplate - Page: %s has NO template!!\n",pageGui->getPageObject()->getNameInDocument());
Base::Console().Log("INFO - MDIViewPage::updateTemplate - Page: %s has NO template!!\n",m_vpPage->getDrawPage()->getNameInDocument());
return;
}
if(pageGui->getPageObject()->Template.isTouched() || templObj->isTouched()) {
if(m_vpPage->getDrawPage()->Template.isTouched() || templObj->isTouched()) {
// Template is touched so update
if(forceUpdate ||
@ -338,10 +338,9 @@ void MDIViewPage::updateTemplate(bool forceUpdate)
void MDIViewPage::updateDrawing(bool forceUpdate)
{
// We cannot guarantee if the number of graphical representations (QGIVxxxx) have changed so check the number
// Why?
// We cannot guarantee if the number of graphical representations (QGIVxxxx) have changed so check the number (MLP)
const std::vector<QGIView *> &graphicsList = m_view->getViews();
const std::vector<App::DocumentObject*> &pageChildren = pageGui->getPageObject()->Views.getValues();
const std::vector<App::DocumentObject*> &pageChildren = m_vpPage->getDrawPage()->Views.getValues();
// Count total # DocumentObjects in Page
unsigned int docObjCount = 0;

View File

@ -116,7 +116,7 @@ private:
QString m_currentPath;
QPrinter::Orientation m_orientation;
QPrinter::PaperSize m_paperSize;
ViewProviderPage *pageGui;
ViewProviderPage *m_vpPage;
bool m_frameState;

View File

@ -39,7 +39,8 @@ using namespace TechDrawGui;
QGIArrow::QGIArrow() :
m_fill(Qt::SolidPattern),
m_size(5.0)
m_size(5.0),
m_style(0)
{
isFlipped = false;
m_brush.setStyle(m_fill);

View File

@ -41,6 +41,7 @@ using namespace TechDrawGui;
QGISectionLine::QGISectionLine()
{
m_extLen = 8.0;
m_arrowSize = 0.0;
m_line = new QGraphicsPathItem();
addToGroup(m_line);

View File

@ -46,7 +46,7 @@ public:
enum {Type = QGraphicsItem::UserType + 120};
int type() const override { return Type;}
void updateView(bool update = false) override;
virtual void updateView(bool update = false) override;
void setViewAnnoFeature(TechDraw::DrawViewAnnotation *obj);
virtual void draw() override;

View File

@ -138,7 +138,8 @@ void QGIDatumLabel::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
}
QGIViewDimension::QGIViewDimension() :
hasHover(false)
hasHover(false),
m_lineWidth(0.0)
{
setHandlesChildEvents(false);
setFlag(QGraphicsItem::ItemIsMovable, false);

View File

@ -95,7 +95,7 @@ public:
int type() const { return Type;}
virtual void drawBorder();
virtual void updateView(bool update = false);
virtual void updateView(bool update = false) override;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
public Q_SLOTS:

View File

@ -243,7 +243,6 @@ void QGIViewPart::updateView(bool update)
if( viewPart == nullptr ) {
return;
}
//Base::Console().Message("TRACE - QGIVP::updateView(%d) - %s\n",update,getViewObject()->getNameInDocument());
QGIView::updateView(update);
@ -455,7 +454,7 @@ void QGIViewPart::drawSectionLine(bool b)
{
//Base::Console().Message("TRACE - QGIVP::drawSectionLine);
TechDraw::DrawViewPart *viewPart = dynamic_cast<TechDraw::DrawViewPart *>(getViewObject());
TechDraw::DrawViewPart *viewPart = static_cast<TechDraw::DrawViewPart *>(getViewObject());
TechDraw::DrawViewSection *viewSection = viewPart->getSectionRef();
if (!viewPart ||
!viewSection) {

View File

@ -36,7 +36,7 @@ public:
~QGIViewSection() = default;
virtual void draw() override;
void updateView(bool update = false) override;
virtual void updateView(bool update = false) override;
enum {Type = QGraphicsItem::UserType + 108};
int type() const override { return Type;}
void drawSectionLine(bool b) override;

View File

@ -50,7 +50,7 @@ public:
enum {Type = QGraphicsItem::UserType + 121};
int type() const override { return Type;}
void updateView(bool update = false) override;
virtual void updateView(bool update = false) override;
void setViewSymbolFeature(TechDraw::DrawViewSymbol *obj);
virtual void draw() override;

View File

@ -85,11 +85,11 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene* s, QWidget *parent)
, pageTemplate(0)
, m_renderer(Native)
, drawBkg(true)
, pageGui(0)
, m_vpPage(0)
{
assert(vp);
pageGui = vp;
const char* name = vp->getPageObject()->getNameInDocument();
m_vpPage = vp;
const char* name = vp->getDrawPage()->getNameInDocument();
setObjectName(QString::fromLocal8Bit(name));
setScene(s);
@ -117,7 +117,7 @@ void QGVPage::drawBackground(QPainter *p, const QRectF &)
if(!drawBkg)
return;
if (!pageGui->getPageObject()) {
if (!m_vpPage->getDrawPage()) {
//Base::Console().Log("TROUBLE - QGVP::drawBackground - no Page Object!\n");
return;
}
@ -129,7 +129,7 @@ void QGVPage::drawBackground(QPainter *p, const QRectF &)
p->setBrush(*bkgBrush);
p->drawRect(viewport()->rect());
if(!pageGui) {
if(!m_vpPage) {
return;
}
@ -138,9 +138,9 @@ void QGVPage::drawBackground(QPainter *p, const QRectF &)
float pageWidth = 420,
pageHeight = 297;
if ( pageGui->getPageObject()->hasValidTemplate() ) {
pageWidth = pageGui->getPageObject()->getPageWidth();
pageHeight = pageGui->getPageObject()->getPageHeight();
if ( m_vpPage->getDrawPage()->hasValidTemplate() ) {
pageWidth = m_vpPage->getDrawPage()->getPageWidth();
pageHeight = m_vpPage->getDrawPage()->getPageHeight();
}
// Draw the white page
@ -473,8 +473,8 @@ void QGVPage::toggleHatch(bool enable)
void QGVPage::saveSvg(QString filename)
{
// TODO: We only have pageGui because constructor gets passed a view provider...
TechDraw::DrawPage *page( pageGui->getPageObject() );
// TODO: We only have m_vpPage because constructor gets passed a view provider...
TechDraw::DrawPage *page( m_vpPage->getDrawPage() );
const QString docName( QString::fromUtf8(page->getDocument()->getName()) );
const QString pageName( QString::fromUtf8(page->getNameInDocument()) );
@ -569,7 +569,7 @@ void QGVPage::mouseReleaseEvent(QMouseEvent *event)
TechDraw::DrawPage* QGVPage::getDrawPage()
{
return pageGui->getPageObject();
return m_vpPage->getDrawPage();
}

View File

@ -112,7 +112,7 @@ private:
bool drawBkg;
QBrush* bkgBrush;
QImage m_image;
ViewProviderPage *pageGui;
ViewProviderPage *m_vpPage;
};
} // namespace MDIViewPageGui

View File

@ -32,6 +32,8 @@
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Mod/Part/App/PartFeature.h>
@ -56,8 +58,10 @@ using namespace TechDrawGui;
#endif
TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView) : ui(new Ui_TaskProjGroup),
multiView(featView)
TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
ui(new Ui_TaskProjGroup),
multiView(featView),
m_createMode(mode)
{
ui->setupUi(this);
@ -84,8 +88,8 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView) : ui(new Ui_Task
// Slot for Scale Type
connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int)));
connect(ui->scaleNum, SIGNAL(textEdited(const QString &)), this, SLOT(scaleManuallyChanged(const QString &)));
connect(ui->scaleDenom, SIGNAL(textEdited(const QString &)), this, SLOT(scaleManuallyChanged(const QString &)));
connect(ui->sbScaleNum, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int)));
connect(ui->sbScaleDen, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int)));
// Slot for Projection Type (layout)
connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int)));
@ -148,7 +152,7 @@ void TaskProjGroup::projectionTypeChanged(int index)
if(blockUpdate)
return;
Gui::Command::openCommand("Update projection type");
//Gui::Command::openCommand("Update projection type");
if(index == 0) {
//layout per Page (Document)
Gui::Command::doCommand(Gui::Command::Doc,
@ -165,7 +169,7 @@ void TaskProjGroup::projectionTypeChanged(int index)
"App.activeDocument().%s.ProjectionType = '%s'",
multiView->getNameInDocument(), "Third Angle");
} else {
Gui::Command::abortCommand();
//Gui::Command::abortCommand();
Base::Console().Log("Error - TaskProjGroup::projectionTypeChanged - unknown projection layout: %d\n",
index);
return;
@ -174,8 +178,8 @@ void TaskProjGroup::projectionTypeChanged(int index)
// Update checkboxes so checked state matches the drawing
setupViewCheckboxes();
Gui::Command::commitCommand();
Gui::Command::updateActive();
//Gui::Command::commitCommand();
//Gui::Command::updateActive();
}
void TaskProjGroup::scaleTypeChanged(int index)
@ -183,7 +187,7 @@ void TaskProjGroup::scaleTypeChanged(int index)
if(blockUpdate)
return;
Gui::Command::openCommand("Update projection scale type");
//Gui::Command::openCommand("Update projection scale type");
if(index == 0) {
//Automatic Scale Type
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.ScaleType = '%s'", multiView->getNameInDocument()
@ -197,12 +201,12 @@ void TaskProjGroup::scaleTypeChanged(int index)
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.ScaleType = '%s'", multiView->getNameInDocument()
, "Custom");
} else {
Gui::Command::abortCommand();
//Gui::Command::abortCommand();
Base::Console().Log("Error - TaskProjGroup::scaleTypeChanged - unknown scale type: %d\n",index);
return;
}
Gui::Command::commitCommand();
Gui::Command::updateActive();
//Gui::Command::commitCommand();
//Gui::Command::updateActive();
}
// ** David Eppstein / UC Irvine / 8 Aug 1993
@ -256,43 +260,40 @@ void TaskProjGroup::setFractionalScale(double newScale)
nearestFraction(newScale, num, den);
ui->scaleNum->setText(QString::number(num));
ui->scaleDenom->setText(QString::number(den));
ui->sbScaleNum->setValue(num);
ui->sbScaleDen->setValue(den);
blockUpdate = false;
}
void TaskProjGroup::scaleManuallyChanged(const QString & text)
void TaskProjGroup::scaleManuallyChanged(int i)
{
//TODO: See what this is about - shouldn't be simplifying the scale ratio while it's being edited... IR
if(blockUpdate)
return;
bool ok1, ok2;
int a = ui->scaleNum->text().toInt(&ok1);
int b = ui->scaleDenom->text().toInt(&ok2);
int a = ui->sbScaleNum->value();
int b = ui->sbScaleDen->value();
double scale = (double) a / (double) b;
if (ok1 && ok2) {
// If we were not in Custom, switch to Custom in two steps
bool switchToCustom = (strcmp(multiView->ScaleType.getValueAsString(), "Custom") != 0);
if(switchToCustom) {
// First, send out command to put us into custom scale
scaleTypeChanged(ui->cmbScaleType->findText(QString::fromLatin1("Custom")));
switchToCustom = true;
}
Gui::Command::openCommand("Update custom scale");
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.Scale = %f", multiView->getNameInDocument()
, scale);
Gui::Command::commitCommand();
Gui::Command::updateActive();
if(switchToCustom) {
// Second, update the GUI
ui->cmbScaleType->setCurrentIndex(ui->cmbScaleType->findText(QString::fromLatin1("Custom")));
}
// If we were not in Custom, switch to Custom in two steps
bool switchToCustom = (strcmp(multiView->ScaleType.getValueAsString(), "Custom") != 0);
if(switchToCustom) {
// First, send out command to put us into custom scale
scaleTypeChanged(ui->cmbScaleType->findText(QString::fromLatin1("Custom")));
switchToCustom = true;
}
//Gui::Command::openCommand("Update custom scale");
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.Scale = %f", multiView->getNameInDocument()
, scale);
//Gui::Command::commitCommand();
//Gui::Command::updateActive();
if(switchToCustom) {
// Second, update the GUI
ui->cmbScaleType->setCurrentIndex(ui->cmbScaleType->findText(QString::fromLatin1("Custom")));
}
}
void TaskProjGroup::changeEvent(QEvent *e)
@ -362,13 +363,49 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections)
}
}
bool TaskProjGroup::accept()
{
Gui::Command::commitCommand();
Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
return true;
}
bool TaskProjGroup::reject()
{
if (getCreateMode()) {
std::string multiViewName = multiView->getNameInDocument();
std::string PageName = multiView->findParentPage()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.purgeProjections()",
multiViewName.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)",
PageName.c_str(),multiViewName.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",multiViewName.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
} else {
if (Gui::Command::hasPendingCommand()) {
std::vector<std::string> undos = Gui::Application::Instance->activeDocument()->getUndoVector();
Gui::Application::Instance->activeDocument()->undo(1);
multiView->rebuildViewList();
} else {
Base::Console().Log("TaskProjGroup: Edit mode - NO command is active\n");
}
Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
}
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TODO: Do we really need to hang on to the TaskDlgProjGroup in this class? IR
TaskDlgProjGroup::TaskDlgProjGroup(TechDraw::DrawProjGroup* featView) : TaskDialog(),
TaskDlgProjGroup::TaskDlgProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : TaskDialog(),
multiView(featView)
{
viewProvider = dynamic_cast<const ViewProviderProjGroup *>(featView);
widget = new TaskProjGroup(featView);
//viewProvider = dynamic_cast<const ViewProviderProjGroup *>(featView);
widget = new TaskProjGroup(featView,mode);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-projgroup"),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
@ -384,9 +421,17 @@ void TaskDlgProjGroup::update()
widget->updateTask();
}
void TaskDlgProjGroup::setCreateMode(bool b)
{
widget->setCreateMode(b);
}
//==== calls from the TaskView ===============================================================
void TaskDlgProjGroup::open()
{
if (!widget->getCreateMode()) { //this is an edit session, start a transaction
Gui::Command::openCommand("Edit Projection Group");
}
}
void TaskDlgProjGroup::clicked(int)
@ -395,11 +440,13 @@ void TaskDlgProjGroup::clicked(int)
bool TaskDlgProjGroup::accept()
{
return true;//!widget->user_input();
widget->accept();
return true;
}
bool TaskDlgProjGroup::reject()
{
widget->reject();
return true;
}

View File

@ -31,6 +31,7 @@
#include <Mod/TechDraw/Gui/ui_TaskProjGroup.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
class Ui_TaskProjGroup;
@ -48,14 +49,18 @@ class TaskProjGroup : public QWidget
Q_OBJECT
public:
TaskProjGroup(TechDraw::DrawProjGroup* featView);
TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode);
~TaskProjGroup();
public:
virtual bool accept();
virtual bool reject();
void updateTask();
void nearestFraction(double val, int &a, int &b) const;
/// Sets the numerator and denominator widgets to match newScale
void setFractionalScale(double newScale);
void setCreateMode(bool b) { m_createMode = b;}
bool getCreateMode() { return m_createMode; }
protected Q_SLOTS:
void viewToggled(bool toggle);
@ -65,7 +70,7 @@ protected Q_SLOTS:
void projectionTypeChanged(int index);
void scaleTypeChanged(int index);
void scaleManuallyChanged(const QString & text);
void scaleManuallyChanged(int i);
protected:
void changeEvent(QEvent *e);
@ -87,6 +92,7 @@ private:
protected:
ViewProviderProjGroup *viewProvider;
TechDraw::DrawProjGroup* multiView;
bool m_createMode;
};
/// Simulation dialog for the TaskView
@ -95,7 +101,7 @@ class TaskDlgProjGroup : public Gui::TaskView::TaskDialog
Q_OBJECT
public:
TaskDlgProjGroup(TechDraw::DrawProjGroup* featView);
TaskDlgProjGroup(TechDraw::DrawProjGroup* featView,bool mode);
~TaskDlgProjGroup();
const ViewProviderProjGroup * getViewProvider() const { return viewProvider; }
@ -113,6 +119,7 @@ public:
virtual void helpRequested() { return;}
virtual bool isAllowedAlterDocument(void) const
{ return false; }
void setCreateMode(bool b);
void update();

View File

@ -110,7 +110,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0,0,1,0,1">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
@ -132,12 +132,9 @@
</spacer>
</item>
<item>
<widget class="QLineEdit" name="scaleNum">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QSpinBox" name="sbScaleNum">
<property name="value">
<number>1</number>
</property>
</widget>
</item>
@ -149,7 +146,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="scaleDenom"/>
<widget class="QSpinBox" name="sbScaleDen">
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>

View File

@ -272,12 +272,20 @@ bool TaskSectionView::accept()
{
//calcValues();
updateValues();
std::string BaseName = m_base->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.ShowSectionLine=True",BaseName.c_str());
return true;
}
bool TaskSectionView::reject()
{
//TODO: remove viewSection
std::string BaseName = m_base->getNameInDocument();
std::string PageName = m_base->findParentPage()->getNameInDocument();
std::string SectionName = m_section->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.ShowSectionLine=False",BaseName.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)",
PageName.c_str(),SectionName.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",SectionName.c_str());
return false;
}

View File

@ -46,8 +46,8 @@ public:
~TaskSectionView();
public:
bool accept();
bool reject();
virtual bool accept();
virtual bool reject();
protected Q_SLOTS:
void onHorizontalClicked(bool b);

View File

@ -38,12 +38,11 @@
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
#include "ViewProviderAnnotation.h"
using namespace TechDrawGui;
PROPERTY_SOURCE(TechDrawGui::ViewProviderAnnotation, Gui::ViewProviderDocumentObject)
PROPERTY_SOURCE(TechDrawGui::ViewProviderAnnotation, TechDrawGui::ViewProviderDrawingView)
//**************************************************************************
// Construction/Destruction
@ -60,25 +59,40 @@ ViewProviderAnnotation::~ViewProviderAnnotation()
void ViewProviderAnnotation::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
ViewProviderDocumentObject::attach(pcFeat);
ViewProviderDrawingView::attach(pcFeat);
}
void ViewProviderAnnotation::setDisplayMode(const char* ModeName)
{
ViewProviderDocumentObject::setDisplayMode(ModeName);
ViewProviderDrawingView::setDisplayMode(ModeName);
}
std::vector<std::string> ViewProviderAnnotation::getDisplayModes(void) const
{
// get the modes of the father
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
std::vector<std::string> StrList = ViewProviderDrawingView::getDisplayModes();
return StrList;
}
void ViewProviderAnnotation::updateData(const App::Property* prop)
{
Gui::ViewProviderDocumentObject::updateData(prop);
Base::Console().Log("ViewProviderViewSection::updateData - Update View: %s\n",prop->getName());
if (prop == &(getViewObject()->Text) ||
prop == &(getViewObject()->Font) ||
prop == &(getViewObject()->TextColor) ||
prop == &(getViewObject()->TextSize) ||
prop == &(getViewObject()->LineSpace) ||
prop == &(getViewObject()->TextStyle) ||
prop == &(getViewObject()->MaxWidth) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
}
ViewProviderDrawingView::updateData(prop);
}
TechDraw::DrawViewAnnotation* ViewProviderAnnotation::getViewObject() const

View File

@ -28,10 +28,8 @@
#include <Gui/ViewProviderFeature.h>
#include "ViewProviderDrawingView.h"
namespace TechDraw{
class DrawViewAnnotation;
}
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
namespace TechDrawGui {
@ -54,7 +52,7 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
TechDraw::DrawViewAnnotation* getViewObject() const;
virtual TechDraw::DrawViewAnnotation* getViewObject() const;
};
} // namespace TechDrawGui

View File

@ -38,7 +38,6 @@
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawViewDimension.h>
#include "ViewProviderDimension.h"
using namespace TechDrawGui;
@ -91,7 +90,7 @@ void ViewProviderDimension::updateData(const App::Property* p)
sPixmap = "TechDraw_Dimension_Angle";
}
}
Gui::ViewProviderDocumentObject::updateData(p);
ViewProviderDrawingView::updateData(p);
}
TechDraw::DrawViewDimension* ViewProviderDimension::getViewObject() const

View File

@ -25,12 +25,9 @@
#ifndef DRAWINGGUI_VIEWPROVIDERDIMENSION_H
#define DRAWINGGUI_VIEWPROVIDERDIMENSION_H
#include <Gui/ViewProviderFeature.h>
#include "ViewProviderDrawingView.h"
#include <Mod/TechDraw/App/DrawViewDimension.h>
namespace TechDraw{
class DrawViewDimension;
}
namespace TechDrawGui {
@ -53,7 +50,7 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
TechDraw::DrawViewDimension* getViewObject() const;
virtual TechDraw::DrawViewDimension* getViewObject() const;
};
} // namespace TechDrawGui

View File

@ -43,7 +43,6 @@
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewClip.h>
#include <Mod/TechDraw/App/DrawPage.h>
@ -178,9 +177,18 @@ void ViewProviderDrawingView::finishRestoring()
Gui::ViewProviderDocumentObject::finishRestoring();
}
//void ViewProviderDrawingView::updateData(const App::Property*)
//{
//}
void ViewProviderDrawingView::updateData(const App::Property* prop)
{
if (prop == &(getViewObject()->Rotation) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
}
Gui::ViewProviderDocumentObject::updateData(prop);
}
TechDraw::DrawView* ViewProviderDrawingView::getViewObject() const
{

View File

@ -28,9 +28,8 @@
#include <Gui/ViewProviderFeature.h>
#include <Gui/ViewProviderDocumentObjectGroup.h>
namespace TechDraw{
class DrawView;
}
#include <Mod/TechDraw/App/DrawView.h>
#include "QGIView.h"
namespace TechDrawGui {
class QGIView;
@ -51,7 +50,6 @@ public:
virtual bool useNewSelectionModel(void) const {return false;}
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
//virtual void updateData(const App::Property*);
/// Hide the object in the view
virtual void hide(void);
/// Show the object in the view
@ -59,6 +57,8 @@ public:
virtual bool isShow(void) const;
virtual void onChanged(const App::Property *prop);
virtual void updateData(const App::Property*);
QGIView* getQView(void);
/** @name Restoring view provider from document load */
@ -66,7 +66,7 @@ public:
virtual void startRestoring();
virtual void finishRestoring();
//@}
TechDraw::DrawView* getViewObject() const;
virtual TechDraw::DrawView* getViewObject() const;
private:
bool m_docReady; //sb MDI + QGraphicsScene ready

View File

@ -71,7 +71,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderPage, Gui::ViewProviderDocumentObject)
// Construction/Destruction
ViewProviderPage::ViewProviderPage()
: view(0),
: m_mdiView(0),
m_docReady(true)
{
sPixmap = "TechDraw_Tree_Page";
@ -116,23 +116,23 @@ void ViewProviderPage::show(void)
void ViewProviderPage::hide(void)
{
// hiding the drawing page should not affect its children but closes the MDI view
// hiding the drawing page should not affect its children but closes the MDI m_mdiView
// therefore do not call the method of its direct base class
ViewProviderDocumentObject::hide();
if (view) {
view->parentWidget()->deleteLater();
if (m_mdiView) {
m_mdiView->parentWidget()->deleteLater();
}
}
void ViewProviderPage::updateData(const App::Property* prop)
{
if (prop == &(getPageObject()->Views)) {
if(view) {
view->updateDrawing();
if (prop == &(getDrawPage()->Views)) {
if(m_mdiView) {
m_mdiView->updateDrawing();
}
} else if (prop == &(getPageObject()->Template)) {
if(view) {
view->updateTemplate();
} else if (prop == &(getDrawPage()->Template)) {
if(m_mdiView) {
m_mdiView->updateTemplate();
}
}
@ -141,10 +141,10 @@ void ViewProviderPage::updateData(const App::Property* prop)
bool ViewProviderPage::onDelete(const std::vector<std::string> &items)
{
if (!view.isNull()) {
Gui::getMainWindow()->removeWindow(view);
if (!m_mdiView.isNull()) {
Gui::getMainWindow()->removeWindow(m_mdiView);
Gui::getMainWindow()->activatePreviousWindow();
view->deleteLater(); // Delete the drawing view;
m_mdiView->deleteLater(); // Delete the drawing m_mdiView;
} else {
// MDIViewPage is not displayed yet so don't try to delete it!
Base::Console().Log("INFO - ViewProviderPage::onDelete - Page object deleted when viewer not displayed\n");
@ -165,7 +165,7 @@ bool ViewProviderPage::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
showMDIViewPage(); // show the drawing
Gui::getMainWindow()->setActiveWindow(view);
Gui::getMainWindow()->setActiveWindow(m_mdiView);
return false;
} else {
Gui::ViewProviderDocumentObject::setEdit(ModNum);
@ -176,7 +176,7 @@ bool ViewProviderPage::setEdit(int ModNum)
bool ViewProviderPage::doubleClicked(void)
{
showMDIViewPage();
Gui::getMainWindow()->setActiveWindow(view);
Gui::getMainWindow()->setActiveWindow(m_mdiView);
return true;
}
@ -186,19 +186,19 @@ bool ViewProviderPage::showMDIViewPage()
return true;
}
if (view.isNull()){
if (m_mdiView.isNull()){
Gui::Document* doc = Gui::Application::Instance->getDocument
(pcObject->getDocument());
view = new MDIViewPage(this, doc, Gui::getMainWindow());
view->setWindowTitle(QObject::tr("Drawing viewer") + QString::fromLatin1("[*]"));
view->setWindowIcon(Gui::BitmapFactory().pixmap("TechDraw_Tree_Page"));
view->updateDrawing(true);
// view->updateTemplate(true); //TODO: I don't think this is necessary? Ends up triggering a reload of SVG template, but the MDIViewPage constructor does too.
Gui::getMainWindow()->addWindow(view);
view->viewAll();
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
m_mdiView->setWindowTitle(QObject::tr("Drawing viewer") + QString::fromLatin1("[*]"));
m_mdiView->setWindowIcon(Gui::BitmapFactory().pixmap("TechDraw_Tree_Page"));
m_mdiView->updateDrawing(true);
// m_mdiView->updateTemplate(true); //TODO: I don't think this is necessary? Ends up triggering a reload of SVG template, but the MDIViewPage constructor does too.
Gui::getMainWindow()->addWindow(m_mdiView);
m_mdiView->viewAll();
} else {
view->updateDrawing(true);
view->updateTemplate(true);
m_mdiView->updateDrawing(true);
m_mdiView->updateTemplate(true);
}
return true;
}
@ -209,7 +209,7 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
// Attach the template if it exists
App::DocumentObject *templateFeat = 0;
templateFeat = getPageObject()->Template.getValue();
templateFeat = getDrawPage()->Template.getValue();
if(templateFeat) {
temp.push_back(templateFeat);
@ -221,7 +221,7 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
// any FeatuerView in a DrawViewClip
// DrawHatch
const std::vector<App::DocumentObject *> &views = getPageObject()->Views.getValues();
const std::vector<App::DocumentObject *> &views = getDrawPage()->Views.getValues();
try {
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
@ -252,24 +252,24 @@ void ViewProviderPage::unsetEdit(int ModNum)
MDIViewPage* ViewProviderPage::getMDIViewPage()
{
if (view.isNull()) {
Base::Console().Log("INFO - ViewProviderPage::getMDIViewPage has no view!\n");
if (m_mdiView.isNull()) {
Base::Console().Log("INFO - ViewProviderPage::getMDIViewPage has no m_mdiView!\n");
return 0;
} else {
return view;
return m_mdiView;
}
}
void ViewProviderPage::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if(!view.isNull()) {
if(!m_mdiView.isNull()) {
if(msg.Type == Gui::SelectionChanges::SetSelection) {
view->clearSelection();
m_mdiView->clearSelection();
std::vector<Gui::SelectionSingleton::SelObj> objs = Gui::Selection().getSelection(msg.pDocName);
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = objs.begin(); it != objs.end(); ++it) {
Gui::SelectionSingleton::SelObj selObj = *it;
if(selObj.pObject == getPageObject())
if(selObj.pObject == getDrawPage())
continue;
std::string str = msg.pSubName;
@ -281,7 +281,7 @@ void ViewProviderPage::onSelectionChanged(const Gui::SelectionChanges& msg)
// TODO implement me wf: don't think this is ever executed
}
} else {
view->selectFeature(selObj.pObject, true);
m_mdiView->selectFeature(selObj.pObject, true);
}
}
} else {
@ -297,7 +297,7 @@ void ViewProviderPage::onSelectionChanged(const Gui::SelectionChanges& msg)
TechDraw::DrawUtil::getGeomTypeFromName(str) == "Vertex") {
// TODO implement me
} else {
view->selectFeature(obj, selectState);
m_mdiView->selectFeature(obj, selectState);
}
}
}
@ -307,13 +307,13 @@ void ViewProviderPage::onSelectionChanged(const Gui::SelectionChanges& msg)
void ViewProviderPage::onChanged(const App::Property *prop)
{
if (prop == &(getPageObject()->Views)) {
if(view) {
view->updateDrawing();
if (prop == &(getDrawPage()->Views)) {
if(m_mdiView) {
m_mdiView->updateDrawing();
}
} else if (prop == &(getPageObject()->Template)) {
if(view) {
view->updateTemplate();
} else if (prop == &(getDrawPage()->Template)) {
if(m_mdiView) {
m_mdiView->updateTemplate();
}
}
@ -334,11 +334,11 @@ void ViewProviderPage::finishRestoring()
}
TechDraw::DrawPage* ViewProviderPage::getPageObject() const
TechDraw::DrawPage* ViewProviderPage::getDrawPage() const
{
//during redo, pcObject can become invalid, but non-zero??
if (!pcObject) {
Base::Console().Message("TROUBLE - VPP::getPageObject - no Page Object!\n");
Base::Console().Message("TROUBLE - VPPage::getDrawPage - no Page Object!\n");
return nullptr;
}
return dynamic_cast<TechDraw::DrawPage*>(pcObject);

View File

@ -78,7 +78,7 @@ public:
virtual void finishRestoring();
bool isRestoring(void) {return !m_docReady;}
TechDraw::DrawPage* getPageObject() const;
TechDraw::DrawPage* getDrawPage() const;
void unsetEdit(int ModNum);
MDIViewPage* getMDIViewPage();
@ -87,7 +87,7 @@ protected:
bool showMDIViewPage();
private:
QPointer<MDIViewPage> view;
QPointer<MDIViewPage> m_mdiView;
bool m_docReady;
};

View File

@ -32,8 +32,6 @@
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include <App/Application.h>
#include <App/Document.h>
@ -49,14 +47,13 @@
#include <Gui/SoFCSelection.h>
#include <Gui/ViewProviderDocumentObject.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include "TaskProjGroup.h"
#include "ViewProviderProjGroup.h"
using namespace TechDrawGui;
PROPERTY_SOURCE(TechDrawGui::ViewProviderProjGroup, Gui::ViewProviderDocumentObject)
PROPERTY_SOURCE(TechDrawGui::ViewProviderProjGroup, TechDrawGui::ViewProviderDrawingView)
//**************************************************************************
// Construction/Destruction
@ -130,16 +127,19 @@ bool ViewProviderProjGroup::setEdit(int ModNum)
Gui::Selection().clearSelection();
// start the edit dialog
if (projDlg)
if (projDlg) {
projDlg->setCreateMode(false);
Gui::Control().showDialog(projDlg);
else
Gui::Control().showDialog(new TaskDlgProjGroup(getObject()));
} else {
Gui::Control().showDialog(new TaskDlgProjGroup(getObject(),false));
}
return true;
}
void ViewProviderProjGroup::unsetEdit(int ModNum)
{
Base::Console().Message("TRACE - VPPG::unSetEdit(%d) \n",ModNum);
Gui::Control().closeDialog();
}
@ -165,8 +165,12 @@ std::vector<App::DocumentObject*> ViewProviderProjGroup::claimChildren(void) con
}
}
TechDraw::DrawProjGroup* ViewProviderProjGroup::getObject() const
TechDraw::DrawProjGroup* ViewProviderProjGroup::getViewObject() const
{
return dynamic_cast<TechDraw::DrawProjGroup*>(pcObject);
}
TechDraw::DrawProjGroup* ViewProviderProjGroup::getObject() const
{
return getViewObject();
}

View File

@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
@ -10,7 +10,7 @@
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
@ -26,17 +26,13 @@
#include <Gui/ViewProviderFeature.h>
#include <Gui/ViewProviderDocumentObject.h>
#include <QPointer>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include "ViewProviderDrawingView.h"
namespace TechDraw{
class DrawProjGroup;
}
namespace TechDrawGui {
class TechDrawGuiExport ViewProviderProjGroup : public ViewProviderDrawingView
{
PROPERTY_HEADER(TechDrawGui::ViewProviderProjGroup);
@ -61,6 +57,7 @@ public:
virtual void updateData(const App::Property*);
TechDraw::DrawProjGroup* getObject() const;
virtual TechDraw::DrawProjGroup* getViewObject() const;
void unsetEdit(int ModNum);
protected:

View File

@ -40,12 +40,8 @@
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/SoFCSelection.h>
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
#include "ViewProviderProjGroupItem.h"
using namespace TechDrawGui;
@ -141,8 +137,12 @@ bool ViewProviderProjGroupItem::doubleClicked(void)
return true;
}
TechDraw::DrawProjGroupItem* ViewProviderProjGroupItem::getObject() const
TechDraw::DrawProjGroupItem* ViewProviderProjGroupItem::getViewObject() const
{
return dynamic_cast<TechDraw::DrawProjGroupItem*>(pcObject);
}
TechDraw::DrawProjGroupItem* ViewProviderProjGroupItem::getObject() const
{
return getViewObject();
}

View File

@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (c) 2014 Luke Parry <l.parry@warwick.ac.uk> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
@ -10,7 +10,7 @@
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
@ -24,10 +24,9 @@
#define DRAWINGGUI_VIEWPROVIDERVIEWGROUPITEM_H
#include "ViewProviderViewPart.h"
namespace TechDraw{
class DrawProjGroupItem;
}
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
namespace TechDrawGui {
@ -52,6 +51,7 @@ public:
void setupContextMenu(QMenu*, QObject*, const char*);
virtual void updateData(const App::Property*);
virtual TechDraw::DrawProjGroupItem* getViewObject() const;
TechDraw::DrawProjGroupItem* getObject() const;
void unsetEdit(int ModNum);

View File

@ -28,21 +28,15 @@
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
#include "ViewProviderSpreadsheet.h"
using namespace TechDrawGui;
PROPERTY_SOURCE(TechDrawGui::ViewProviderSpreadsheet, Gui::ViewProviderDocumentObject)
PROPERTY_SOURCE(TechDrawGui::ViewProviderSpreadsheet, TechDrawGui::ViewProviderSymbol)
//**************************************************************************
// Construction/Destruction
@ -59,25 +53,25 @@ ViewProviderSpreadsheet::~ViewProviderSpreadsheet()
void ViewProviderSpreadsheet::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
ViewProviderDocumentObject::attach(pcFeat);
ViewProviderSymbol::attach(pcFeat);
}
void ViewProviderSpreadsheet::setDisplayMode(const char* ModeName)
{
ViewProviderDocumentObject::setDisplayMode(ModeName);
ViewProviderSymbol::setDisplayMode(ModeName);
}
std::vector<std::string> ViewProviderSpreadsheet::getDisplayModes(void) const
{
// get the modes of the father
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
std::vector<std::string> StrList = ViewProviderSymbol::getDisplayModes();
return StrList;
}
void ViewProviderSpreadsheet::updateData(const App::Property* prop)
{
Gui::ViewProviderDocumentObject::updateData(prop);
ViewProviderSymbol::updateData(prop);
}
TechDraw::DrawViewSpreadsheet* ViewProviderSpreadsheet::getViewObject() const

View File

@ -24,14 +24,12 @@
#ifndef DRAWINGGUI_VIEWPROVIDERSPREADSHEET_H
#define DRAWINGGUI_VIEWPROVIDERSPREADSHEET_H
#include <Gui/ViewProviderFeature.h>
#include "ViewProviderSymbol.h"
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
#include <Mod/TechDraw/App/DrawViewSymbol.h>
#include "ViewProviderSymbol.h"
namespace TechDraw{
class DrawViewSpreadsheet;
}
namespace TechDrawGui {
@ -53,7 +51,7 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
TechDraw::DrawViewSpreadsheet* getViewObject() const;
virtual TechDraw::DrawViewSpreadsheet* getViewObject() const;
};
} // namespace TechDrawGui

View File

@ -38,12 +38,11 @@
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawViewSymbol.h>
#include "ViewProviderSymbol.h"
using namespace TechDrawGui;
PROPERTY_SOURCE(TechDrawGui::ViewProviderSymbol, Gui::ViewProviderDocumentObject)
PROPERTY_SOURCE(TechDrawGui::ViewProviderSymbol, TechDrawGui::ViewProviderDrawingView)
//**************************************************************************
// Construction/Destruction
@ -60,25 +59,25 @@ ViewProviderSymbol::~ViewProviderSymbol()
void ViewProviderSymbol::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
ViewProviderDocumentObject::attach(pcFeat);
ViewProviderDrawingView::attach(pcFeat);
}
void ViewProviderSymbol::setDisplayMode(const char* ModeName)
{
ViewProviderDocumentObject::setDisplayMode(ModeName);
ViewProviderDrawingView::setDisplayMode(ModeName);
}
std::vector<std::string> ViewProviderSymbol::getDisplayModes(void) const
{
// get the modes of the father
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
std::vector<std::string> StrList = ViewProviderDrawingView::getDisplayModes();
return StrList;
}
void ViewProviderSymbol::updateData(const App::Property* prop)
{
Gui::ViewProviderDocumentObject::updateData(prop);
ViewProviderDrawingView::updateData(prop);
}
TechDraw::DrawViewSymbol* ViewProviderSymbol::getViewObject() const

View File

@ -25,13 +25,10 @@
#ifndef DRAWINGGUI_VIEWPROVIDERSYMBOL_H
#define DRAWINGGUI_VIEWPROVIDERSYMBOL_H
#include <Gui/ViewProviderFeature.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewSymbol.h>
#include "ViewProviderDrawingView.h"
#include "ViewProviderDrawingView.h"
namespace TechDraw{
class DrawViewSymbol;
}
namespace TechDrawGui {
@ -54,7 +51,7 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
TechDraw::DrawViewSymbol* getViewObject() const;
virtual TechDraw::DrawViewSymbol* getViewObject() const;
};
} // namespace TechDrawGui

View File

@ -33,15 +33,11 @@
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawViewClip.h>
#include "ViewProviderViewClip.h"
using namespace TechDrawGui;
@ -61,6 +57,22 @@ ViewProviderViewClip::~ViewProviderViewClip()
{
}
void ViewProviderViewClip::updateData(const App::Property* prop)
{
Base::Console().Log("ViewProviderViewClip::updateData - Update View: %s\n",prop->getName());
if (prop == &(getViewObject()->Height) ||
prop == &(getViewObject()->Width) ||
prop == &(getViewObject()->ShowFrame) ||
prop == &(getViewObject()->ShowLabels) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
}
ViewProviderDrawingView::updateData(prop);
}
void ViewProviderViewClip::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
@ -121,7 +133,12 @@ bool ViewProviderViewClip::isShow(void) const
return Visibility.getValue();
}
TechDraw::DrawViewClip* ViewProviderViewClip::getObject() const
TechDraw::DrawViewClip* ViewProviderViewClip::getViewObject() const
{
return dynamic_cast<TechDraw::DrawViewClip*>(pcObject);
}
TechDraw::DrawViewClip* ViewProviderViewClip::getObject() const
{
return getViewObject();
}

View File

@ -25,13 +25,10 @@
#ifndef DRAWINGGUI_VIEWPROVIDERCLIP_H
#define DRAWINGGUI_VIEWPROVIDERCLIP_H
#include <Gui/ViewProviderDocumentObjectGroup.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewClip.h>
#include "ViewProviderDrawingView.h"
namespace TechDraw{
class DrawViewClip;
}
namespace TechDrawGui {
class TechDrawGuiExport ViewProviderViewClip : public ViewProviderDrawingView
@ -50,7 +47,10 @@ public:
virtual bool useNewSelectionModel(void) const {return false;}
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
virtual TechDraw::DrawViewClip* getViewObject() const;
TechDraw::DrawViewClip* getObject() const;
virtual void updateData(const App::Property* prop);
/// Hide the object in the view
virtual void hide(void);

View File

@ -31,15 +31,11 @@
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
//#include <Base/Exception.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewDimension.h>
#include <Mod/TechDraw/App/DrawHatch.h>
@ -60,8 +56,38 @@ ViewProviderViewPart::ViewProviderViewPart()
ViewProviderViewPart::~ViewProviderViewPart()
{
}
void ViewProviderViewPart::updateData(const App::Property* prop)
{
if (prop == &(getViewObject()->LineWidth) ||
prop == &(getViewObject()->HiddenWidth) ||
prop == &(getViewObject()->ShowCenters) ||
prop == &(getViewObject()->CenterScale) ||
prop == &(getViewObject()->ShowSectionLine) ||
prop == &(getViewObject()->HorizSectionLine) ||
prop == &(getViewObject()->ArrowUpSection) ||
prop == &(getViewObject()->SymbolSection) ||
prop == &(getViewObject()->HorizCenterLine) ||
prop == &(getViewObject()->VertCenterLine) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
}
ViewProviderDrawingView::updateData(prop);
}
void ViewProviderViewPart::onChanged(const App::Property* prop)
{
ViewProviderDrawingView::onChanged(prop);
}
void ViewProviderViewPart::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
@ -112,7 +138,12 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren(void) cons
}
}
TechDraw::DrawViewPart* ViewProviderViewPart::getViewPart() const
TechDraw::DrawViewPart* ViewProviderViewPart::getViewObject() const
{
return dynamic_cast<TechDraw::DrawViewPart*>(pcObject);
}
TechDraw::DrawViewPart* ViewProviderViewPart::getViewPart() const
{
return getViewObject();
}

View File

@ -25,10 +25,8 @@
#define DRAWINGGUI_VIEWPROVIDERVIEWPART_H
#include "ViewProviderDrawingView.h"
namespace TechDraw{
class DrawViewPart;
}
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
namespace TechDrawGui {
@ -49,8 +47,12 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
public:
virtual void onChanged(const App::Property *prop);
virtual void updateData(const App::Property*);
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
virtual TechDraw::DrawViewPart* getViewObject() const;
TechDraw::DrawViewPart* getViewPart() const;
};

View File

@ -33,15 +33,10 @@
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawView.h>
#include "ViewProviderViewSection.h"
using namespace TechDrawGui;
@ -81,9 +76,17 @@ std::vector<std::string> ViewProviderViewSection::getDisplayModes(void) const
void ViewProviderViewSection::updateData(const App::Property* prop)
{
//Base::Console().Log("ViewProviderViewSection::updateData - Update View: %s\n",prop->getName());
//
Gui::ViewProviderDocumentObject::updateData(prop);
Base::Console().Log("ViewProviderViewSection::updateData - Update View: %s\n",prop->getName());
if (prop == &(getViewObject()->ShowCutSurface) ||
prop == &(getViewObject()->CutSurfaceColor) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
}
ViewProviderViewPart::updateData(prop);
}
std::vector<App::DocumentObject*> ViewProviderViewSection::claimChildren(void) const
@ -91,7 +94,7 @@ std::vector<App::DocumentObject*> ViewProviderViewSection::claimChildren(void) c
return ViewProviderViewPart::claimChildren();
}
TechDraw::DrawView* ViewProviderViewSection::getViewObject() const
TechDraw::DrawViewSection* ViewProviderViewSection::getViewObject() const
{
return dynamic_cast<TechDraw::DrawView*>(pcObject);
return dynamic_cast<TechDraw::DrawViewSection*>(pcObject);
}

View File

@ -2,7 +2,7 @@
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
@ -11,7 +11,7 @@
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
@ -25,11 +25,11 @@
#ifndef DRAWINGGUI_VIEWPROVIDERVIEWSECTION_H
#define DRAWINGGUI_VIEWPROVIDERVIEWSECTION_H
#include "ViewProviderViewPart.h"
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewSection.h>
namespace TechDraw{
class DrawView;
}
#include "ViewProviderViewPart.h"
namespace TechDrawGui {
@ -52,7 +52,7 @@ public:
virtual void updateData(const App::Property*);
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
TechDraw::DrawView* getViewObject() const;
virtual TechDraw::DrawViewSection* getViewObject() const;
};
} // namespace TechDrawGui