Fix #2692 TaskProjectGroup cancel button
This commit is contained in:
parent
81472a5fd8
commit
254b28ea77
|
@ -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) {
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
*/
|
||||
int removeProjection(const char *viewProjType);
|
||||
|
||||
int purgeProjections();
|
||||
/// Automatically position child views
|
||||
bool distributeProjections(void);
|
||||
void resetPositions(void);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)) {
|
||||
Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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)) {
|
||||
Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user