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;
|
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)
|
bool DrawProjGroup::checkViewProjType(const char *in)
|
||||||
{
|
{
|
||||||
if ( strcmp(in, "Front") == 0 ||
|
if ( strcmp(in, "Front") == 0 ||
|
||||||
|
@ -270,13 +259,27 @@ bool DrawProjGroup::checkViewProjType(const char *in)
|
||||||
return false;
|
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)
|
App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
||||||
{
|
{
|
||||||
DrawProjGroupItem *view( nullptr );
|
DrawProjGroupItem *view( nullptr );
|
||||||
|
|
||||||
if ( checkViewProjType(viewProjType) && !hasProjection(viewProjType) ) {
|
if ( checkViewProjType(viewProjType) && !hasProjection(viewProjType) ) {
|
||||||
std::string FeatName = getDocument()->getUniqueObjectName("ProjItem");
|
std::string FeatName = getDocument()->getUniqueObjectName("ProjItem");
|
||||||
auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem",
|
auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem", //add to Document
|
||||||
FeatName.c_str() ) );
|
FeatName.c_str() ) );
|
||||||
|
|
||||||
view = static_cast<TechDraw::DrawProjGroupItem *>( docObj );
|
view = static_cast<TechDraw::DrawProjGroupItem *>( docObj );
|
||||||
|
@ -287,13 +290,50 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
||||||
view->Label.setValue( viewProjType );
|
view->Label.setValue( viewProjType );
|
||||||
setViewOrientation( view, viewProjType );
|
setViewOrientation( view, viewProjType );
|
||||||
|
|
||||||
addView(view); //from DrawViewCollection
|
addView(view); //from DrawViewCollection - add to ProjGroup Views
|
||||||
moveToCentre();
|
moveToCentre();
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
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
|
void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projType) const
|
||||||
{
|
{
|
||||||
Base::Vector3d dir, xDir;
|
Base::Vector3d dir, xDir;
|
||||||
|
@ -351,30 +391,6 @@ void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projTyp
|
||||||
v->XAxisDirection.setValue(xDir);
|
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
|
void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
|
||||||
{
|
{
|
||||||
for (int i=0; i<10; ++i) {
|
for (int i=0; i<10; ++i) {
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
*/
|
*/
|
||||||
int removeProjection(const char *viewProjType);
|
int removeProjection(const char *viewProjType);
|
||||||
|
|
||||||
|
int purgeProjections();
|
||||||
/// Automatically position child views
|
/// Automatically position child views
|
||||||
bool distributeProjections(void);
|
bool distributeProjections(void);
|
||||||
void resetPositions(void);
|
void resetPositions(void);
|
||||||
|
|
|
@ -57,8 +57,8 @@ DrawProjGroupItem::DrawProjGroupItem(void)
|
||||||
ADD_PROPERTY(Type, ((long)0));
|
ADD_PROPERTY(Type, ((long)0));
|
||||||
|
|
||||||
//projection group controls these
|
//projection group controls these
|
||||||
Direction.setStatus(App::Property::Hidden,true);
|
Direction.setStatus(App::Property::ReadOnly,true);
|
||||||
XAxisDirection.setStatus(App::Property::Hidden,true);
|
XAxisDirection.setStatus(App::Property::ReadOnly,true);
|
||||||
Scale.setStatus(App::Property::ReadOnly,true);
|
Scale.setStatus(App::Property::ReadOnly,true);
|
||||||
ScaleType.setStatus(App::Property::ReadOnly,true);
|
ScaleType.setStatus(App::Property::ReadOnly,true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
namespace TechDraw
|
namespace TechDraw
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Base class of all View Features in the drawing module
|
|
||||||
*/
|
|
||||||
class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart
|
class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart
|
||||||
{
|
{
|
||||||
PROPERTY_HEADER(TechDraw::DrawProjGroupItem);
|
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>
|
<UserDocu>removeProjection(string projectionType) - Remove specified Projection Item from this Group. Returns int number of views in Group.</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</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">
|
<Methode Name="getItemByLabel">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>getItemByLabel(string projectionType) - return specified Projection Item</UserDocu>
|
<UserDocu>getItemByLabel(string projectionType) - return specified Projection Item</UserDocu>
|
||||||
|
|
|
@ -50,6 +50,14 @@ PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
|
||||||
return PyInt_FromLong((long) i);;
|
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)
|
PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
|
||||||
{
|
{
|
||||||
const char* projType;
|
const char* projType;
|
||||||
|
|
|
@ -68,6 +68,54 @@ int DrawViewCollection::addView(DrawView *view)
|
||||||
return Views.getSize();
|
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
|
short DrawViewCollection::mustExecute() const
|
||||||
{
|
{
|
||||||
// If Tolerance Property is touched
|
// If Tolerance Property is touched
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
short mustExecute() const;
|
short mustExecute() const;
|
||||||
|
|
||||||
int addView(DrawView *view);
|
int addView(DrawView *view);
|
||||||
|
int removeView(DrawView *view);
|
||||||
|
void rebuildViewList(void);
|
||||||
|
|
||||||
int countChildren();
|
int countChildren();
|
||||||
/** @name methods overide Feature */
|
/** @name methods overide Feature */
|
||||||
|
|
|
@ -13,6 +13,16 @@
|
||||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||||
<UserDocu>Feature for creating and manipulating Technical Drawing View Collections</UserDocu>
|
<UserDocu>Feature for creating and manipulating Technical Drawing View Collections</UserDocu>
|
||||||
</Documentation>
|
</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 />
|
<CustomAttributes />
|
||||||
</PythonExport>
|
</PythonExport>
|
||||||
</GenerateModel>
|
</GenerateModel>
|
||||||
|
|
|
@ -14,6 +14,41 @@ std::string DrawViewCollectionPy::representation(void) const
|
||||||
{
|
{
|
||||||
return std::string("<DrawViewCollection object>");
|
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
|
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.addProjection('%s')",multiViewName.c_str(),anchor.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Anchor = App.activeDocument().%s.getItemByLabel('%s')",
|
doCommand(Doc,"App.activeDocument().%s.Anchor = App.activeDocument().%s.getItemByLabel('%s')",
|
||||||
multiViewName.c_str(),multiViewName.c_str(),anchor.c_str());
|
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
|
// add the multiView to the page
|
||||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
|
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();
|
updateActive();
|
||||||
commitCommand();
|
commitCommand();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <Gui/Application.h>
|
#include <Gui/Application.h>
|
||||||
#include <Gui/BitmapFactory.h>
|
#include <Gui/BitmapFactory.h>
|
||||||
#include <Gui/Command.h>
|
#include <Gui/Command.h>
|
||||||
|
#include <Gui/Control.h>
|
||||||
|
#include <Gui/Document.h>
|
||||||
|
|
||||||
#include <Mod/Part/App/PartFeature.h>
|
#include <Mod/Part/App/PartFeature.h>
|
||||||
|
|
||||||
|
@ -56,8 +58,10 @@ using namespace TechDrawGui;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView) : ui(new Ui_TaskProjGroup),
|
TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
|
||||||
multiView(featView)
|
ui(new Ui_TaskProjGroup),
|
||||||
|
multiView(featView),
|
||||||
|
m_createMode(mode)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -84,8 +88,8 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView) : ui(new Ui_Task
|
||||||
|
|
||||||
// Slot for Scale Type
|
// Slot for Scale Type
|
||||||
connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int)));
|
connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int)));
|
||||||
connect(ui->scaleNum, SIGNAL(textEdited(const QString &)), this, SLOT(scaleManuallyChanged(const QString &)));
|
connect(ui->sbScaleNum, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int)));
|
||||||
connect(ui->scaleDenom, SIGNAL(textEdited(const QString &)), this, SLOT(scaleManuallyChanged(const QString &)));
|
connect(ui->sbScaleDen, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int)));
|
||||||
|
|
||||||
// Slot for Projection Type (layout)
|
// Slot for Projection Type (layout)
|
||||||
connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int)));
|
connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int)));
|
||||||
|
@ -148,7 +152,7 @@ void TaskProjGroup::projectionTypeChanged(int index)
|
||||||
if(blockUpdate)
|
if(blockUpdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Gui::Command::openCommand("Update projection type");
|
//Gui::Command::openCommand("Update projection type");
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
//layout per Page (Document)
|
//layout per Page (Document)
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,
|
Gui::Command::doCommand(Gui::Command::Doc,
|
||||||
|
@ -165,7 +169,7 @@ void TaskProjGroup::projectionTypeChanged(int index)
|
||||||
"App.activeDocument().%s.ProjectionType = '%s'",
|
"App.activeDocument().%s.ProjectionType = '%s'",
|
||||||
multiView->getNameInDocument(), "Third Angle");
|
multiView->getNameInDocument(), "Third Angle");
|
||||||
} else {
|
} else {
|
||||||
Gui::Command::abortCommand();
|
//Gui::Command::abortCommand();
|
||||||
Base::Console().Log("Error - TaskProjGroup::projectionTypeChanged - unknown projection layout: %d\n",
|
Base::Console().Log("Error - TaskProjGroup::projectionTypeChanged - unknown projection layout: %d\n",
|
||||||
index);
|
index);
|
||||||
return;
|
return;
|
||||||
|
@ -174,8 +178,8 @@ void TaskProjGroup::projectionTypeChanged(int index)
|
||||||
// Update checkboxes so checked state matches the drawing
|
// Update checkboxes so checked state matches the drawing
|
||||||
setupViewCheckboxes();
|
setupViewCheckboxes();
|
||||||
|
|
||||||
Gui::Command::commitCommand();
|
//Gui::Command::commitCommand();
|
||||||
Gui::Command::updateActive();
|
//Gui::Command::updateActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskProjGroup::scaleTypeChanged(int index)
|
void TaskProjGroup::scaleTypeChanged(int index)
|
||||||
|
@ -183,7 +187,7 @@ void TaskProjGroup::scaleTypeChanged(int index)
|
||||||
if(blockUpdate)
|
if(blockUpdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Gui::Command::openCommand("Update projection scale type");
|
//Gui::Command::openCommand("Update projection scale type");
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
//Automatic Scale Type
|
//Automatic Scale Type
|
||||||
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.ScaleType = '%s'", multiView->getNameInDocument()
|
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()
|
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.ScaleType = '%s'", multiView->getNameInDocument()
|
||||||
, "Custom");
|
, "Custom");
|
||||||
} else {
|
} else {
|
||||||
Gui::Command::abortCommand();
|
//Gui::Command::abortCommand();
|
||||||
Base::Console().Log("Error - TaskProjGroup::scaleTypeChanged - unknown scale type: %d\n",index);
|
Base::Console().Log("Error - TaskProjGroup::scaleTypeChanged - unknown scale type: %d\n",index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Gui::Command::commitCommand();
|
//Gui::Command::commitCommand();
|
||||||
Gui::Command::updateActive();
|
//Gui::Command::updateActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ** David Eppstein / UC Irvine / 8 Aug 1993
|
// ** David Eppstein / UC Irvine / 8 Aug 1993
|
||||||
|
@ -256,43 +260,40 @@ void TaskProjGroup::setFractionalScale(double newScale)
|
||||||
|
|
||||||
nearestFraction(newScale, num, den);
|
nearestFraction(newScale, num, den);
|
||||||
|
|
||||||
ui->scaleNum->setText(QString::number(num));
|
ui->sbScaleNum->setValue(num);
|
||||||
ui->scaleDenom->setText(QString::number(den));
|
ui->sbScaleDen->setValue(den);
|
||||||
blockUpdate = false;
|
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
|
//TODO: See what this is about - shouldn't be simplifying the scale ratio while it's being edited... IR
|
||||||
if(blockUpdate)
|
if(blockUpdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool ok1, ok2;
|
int a = ui->sbScaleNum->value();
|
||||||
|
int b = ui->sbScaleDen->value();
|
||||||
int a = ui->scaleNum->text().toInt(&ok1);
|
|
||||||
int b = ui->scaleDenom->text().toInt(&ok2);
|
|
||||||
|
|
||||||
double scale = (double) a / (double) b;
|
double scale = (double) a / (double) b;
|
||||||
if (ok1 && ok2) {
|
// If we were not in Custom, switch to Custom in two steps
|
||||||
// If we were not in Custom, switch to Custom in two steps
|
bool switchToCustom = (strcmp(multiView->ScaleType.getValueAsString(), "Custom") != 0);
|
||||||
bool switchToCustom = (strcmp(multiView->ScaleType.getValueAsString(), "Custom") != 0);
|
if(switchToCustom) {
|
||||||
if(switchToCustom) {
|
// First, send out command to put us into custom scale
|
||||||
// First, send out command to put us into custom scale
|
scaleTypeChanged(ui->cmbScaleType->findText(QString::fromLatin1("Custom")));
|
||||||
scaleTypeChanged(ui->cmbScaleType->findText(QString::fromLatin1("Custom")));
|
switchToCustom = true;
|
||||||
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")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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)
|
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
|
//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)
|
multiView(featView)
|
||||||
{
|
{
|
||||||
viewProvider = dynamic_cast<const ViewProviderProjGroup *>(featView);
|
//viewProvider = dynamic_cast<const ViewProviderProjGroup *>(featView);
|
||||||
widget = new TaskProjGroup(featView);
|
widget = new TaskProjGroup(featView,mode);
|
||||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-projgroup"),
|
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-projgroup"),
|
||||||
widget->windowTitle(), true, 0);
|
widget->windowTitle(), true, 0);
|
||||||
taskbox->groupLayout()->addWidget(widget);
|
taskbox->groupLayout()->addWidget(widget);
|
||||||
|
@ -384,9 +421,17 @@ void TaskDlgProjGroup::update()
|
||||||
widget->updateTask();
|
widget->updateTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskDlgProjGroup::setCreateMode(bool b)
|
||||||
|
{
|
||||||
|
widget->setCreateMode(b);
|
||||||
|
}
|
||||||
|
|
||||||
//==== calls from the TaskView ===============================================================
|
//==== calls from the TaskView ===============================================================
|
||||||
void TaskDlgProjGroup::open()
|
void TaskDlgProjGroup::open()
|
||||||
{
|
{
|
||||||
|
if (!widget->getCreateMode()) { //this is an edit session, start a transaction
|
||||||
|
Gui::Command::openCommand("Edit Projection Group");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDlgProjGroup::clicked(int)
|
void TaskDlgProjGroup::clicked(int)
|
||||||
|
@ -395,11 +440,13 @@ void TaskDlgProjGroup::clicked(int)
|
||||||
|
|
||||||
bool TaskDlgProjGroup::accept()
|
bool TaskDlgProjGroup::accept()
|
||||||
{
|
{
|
||||||
return true;//!widget->user_input();
|
widget->accept();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskDlgProjGroup::reject()
|
bool TaskDlgProjGroup::reject()
|
||||||
{
|
{
|
||||||
|
widget->reject();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <Mod/TechDraw/Gui/ui_TaskProjGroup.h>
|
#include <Mod/TechDraw/Gui/ui_TaskProjGroup.h>
|
||||||
|
|
||||||
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
||||||
|
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||||
|
|
||||||
|
|
||||||
class Ui_TaskProjGroup;
|
class Ui_TaskProjGroup;
|
||||||
|
@ -48,14 +49,18 @@ class TaskProjGroup : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskProjGroup(TechDraw::DrawProjGroup* featView);
|
TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode);
|
||||||
~TaskProjGroup();
|
~TaskProjGroup();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual bool accept();
|
||||||
|
virtual bool reject();
|
||||||
void updateTask();
|
void updateTask();
|
||||||
void nearestFraction(double val, int &a, int &b) const;
|
void nearestFraction(double val, int &a, int &b) const;
|
||||||
/// Sets the numerator and denominator widgets to match newScale
|
/// Sets the numerator and denominator widgets to match newScale
|
||||||
void setFractionalScale(double newScale);
|
void setFractionalScale(double newScale);
|
||||||
|
void setCreateMode(bool b) { m_createMode = b;}
|
||||||
|
bool getCreateMode() { return m_createMode; }
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void viewToggled(bool toggle);
|
void viewToggled(bool toggle);
|
||||||
|
@ -65,7 +70,7 @@ protected Q_SLOTS:
|
||||||
|
|
||||||
void projectionTypeChanged(int index);
|
void projectionTypeChanged(int index);
|
||||||
void scaleTypeChanged(int index);
|
void scaleTypeChanged(int index);
|
||||||
void scaleManuallyChanged(const QString & text);
|
void scaleManuallyChanged(int i);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
@ -87,6 +92,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
ViewProviderProjGroup *viewProvider;
|
ViewProviderProjGroup *viewProvider;
|
||||||
TechDraw::DrawProjGroup* multiView;
|
TechDraw::DrawProjGroup* multiView;
|
||||||
|
bool m_createMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Simulation dialog for the TaskView
|
/// Simulation dialog for the TaskView
|
||||||
|
@ -95,7 +101,7 @@ class TaskDlgProjGroup : public Gui::TaskView::TaskDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskDlgProjGroup(TechDraw::DrawProjGroup* featView);
|
TaskDlgProjGroup(TechDraw::DrawProjGroup* featView,bool mode);
|
||||||
~TaskDlgProjGroup();
|
~TaskDlgProjGroup();
|
||||||
|
|
||||||
const ViewProviderProjGroup * getViewProvider() const { return viewProvider; }
|
const ViewProviderProjGroup * getViewProvider() const { return viewProvider; }
|
||||||
|
@ -113,6 +119,7 @@ public:
|
||||||
virtual void helpRequested() { return;}
|
virtual void helpRequested() { return;}
|
||||||
virtual bool isAllowedAlterDocument(void) const
|
virtual bool isAllowedAlterDocument(void) const
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
void setCreateMode(bool b);
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0,0,1,0,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -132,12 +132,9 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="scaleNum">
|
<widget class="QSpinBox" name="sbScaleNum">
|
||||||
<property name="sizePolicy">
|
<property name="value">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<number>1</number>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -149,7 +146,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="scaleDenom"/>
|
<widget class="QSpinBox" name="sbScaleDen">
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -127,16 +127,19 @@ bool ViewProviderProjGroup::setEdit(int ModNum)
|
||||||
Gui::Selection().clearSelection();
|
Gui::Selection().clearSelection();
|
||||||
|
|
||||||
// start the edit dialog
|
// start the edit dialog
|
||||||
if (projDlg)
|
if (projDlg) {
|
||||||
|
projDlg->setCreateMode(false);
|
||||||
Gui::Control().showDialog(projDlg);
|
Gui::Control().showDialog(projDlg);
|
||||||
else
|
} else {
|
||||||
Gui::Control().showDialog(new TaskDlgProjGroup(getObject()));
|
Gui::Control().showDialog(new TaskDlgProjGroup(getObject(),false));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewProviderProjGroup::unsetEdit(int ModNum)
|
void ViewProviderProjGroup::unsetEdit(int ModNum)
|
||||||
{
|
{
|
||||||
|
Base::Console().Message("TRACE - VPPG::unSetEdit(%d) \n",ModNum);
|
||||||
Gui::Control().closeDialog();
|
Gui::Control().closeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user