diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 13937a749..300ec9cb8 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -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(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(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( 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(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 views = Views.getValues(); + DrawProjGroupItem* dpgi; + DocumentObject* dObj = views.back(); + dpgi = dynamic_cast(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(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) { diff --git a/src/Mod/TechDraw/App/DrawProjGroup.h b/src/Mod/TechDraw/App/DrawProjGroup.h index a6b53e2d2..589c7b63b 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.h +++ b/src/Mod/TechDraw/App/DrawProjGroup.h @@ -83,6 +83,7 @@ public: */ int removeProjection(const char *viewProjType); + int purgeProjections(); /// Automatically position child views bool distributeProjections(void); void resetPositions(void); diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index 9a35bfae8..ede874d2f 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -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); } diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.h b/src/Mod/TechDraw/App/DrawProjGroupItem.h index c0de0735e..b08f52f6f 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.h +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.h @@ -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); diff --git a/src/Mod/TechDraw/App/DrawProjGroupPy.xml b/src/Mod/TechDraw/App/DrawProjGroupPy.xml index f42fe53f7..603a2543b 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupPy.xml +++ b/src/Mod/TechDraw/App/DrawProjGroupPy.xml @@ -23,6 +23,11 @@ removeProjection(string projectionType) - Remove specified Projection Item from this Group. Returns int number of views in Group. + + + purgeProjections() - Remove all Projection Items from this Group. Returns int number of views in Group (0). + + getItemByLabel(string projectionType) - return specified Projection Item diff --git a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp index 1b6872434..9ff9d092c 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp @@ -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; diff --git a/src/Mod/TechDraw/App/DrawViewCollection.cpp b/src/Mod/TechDraw/App/DrawViewCollection.cpp index 8a788a22f..acb29de81 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollection.cpp @@ -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 currViews = Views.getValues(); + std::vector newViews; + std::vector::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 currViews = Views.getValues(); + std::vector newViews; + std::vector children = getOutList(); + for (std::vector::iterator it = children.begin(); it != children.end(); ++it) { + if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) { + //TechDraw::DrawView* view = static_cast(*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 diff --git a/src/Mod/TechDraw/App/DrawViewCollection.h b/src/Mod/TechDraw/App/DrawViewCollection.h index d54a139ce..4b1c85d54 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.h +++ b/src/Mod/TechDraw/App/DrawViewCollection.h @@ -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 */ diff --git a/src/Mod/TechDraw/App/DrawViewCollectionPy.xml b/src/Mod/TechDraw/App/DrawViewCollectionPy.xml index 543b0527f..ded644e4b 100644 --- a/src/Mod/TechDraw/App/DrawViewCollectionPy.xml +++ b/src/Mod/TechDraw/App/DrawViewCollectionPy.xml @@ -13,6 +13,16 @@ Feature for creating and manipulating Technical Drawing View Collections + + + addView(DrawView object) - Add a new View to this Group. Returns count of views. + + + + + removeView(DrawView object) - Remove specified Viewfrom this Group. Returns count of views in Group. + + diff --git a/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp b/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp index b507c233c..1fe97d292 100644 --- a/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp @@ -14,6 +14,41 @@ std::string DrawViewCollectionPy::representation(void) const { return std::string(""); } +PyObject* DrawViewCollectionPy::addView(PyObject* args) +{ + PyObject *pcDocObj; + + if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { + Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n"); + return NULL; + } + + DrawViewCollection* collect = getDrawViewCollectionPtr(); + DrawViewPy* pyView = static_cast(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)) { + Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n"); + return NULL; + } + + DrawViewCollection* collect = getDrawViewCollectionPtr(); + DrawViewPy* pyView = static_cast(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 diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index a4b0d1cf0..0a04c6f35 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -469,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(); } diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index a1ea17df3..71df028a4 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include @@ -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 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(featView); - widget = new TaskProjGroup(featView); + //viewProvider = dynamic_cast(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; } diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index fca0c220e..1dffa3063 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -31,6 +31,7 @@ #include #include +#include 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(); diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.ui b/src/Mod/TechDraw/Gui/TaskProjGroup.ui index a9b023b4a..3675144d9 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.ui +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.ui @@ -110,7 +110,7 @@ - + @@ -132,12 +132,9 @@ - - - - 0 - 0 - + + + 1 @@ -149,7 +146,11 @@ - + + + 1 + + diff --git a/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp b/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp index d459ddbd3..4edd5f960 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp @@ -127,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(); }