Center new view on Page/ClipGroup
This commit is contained in:
parent
f2bad4598a
commit
131c34cf9e
|
@ -237,11 +237,19 @@ int DrawPage::addView(App::DocumentObject *docObj)
|
||||||
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
|
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<App::DocumentObject *> currViews = Views.getValues();
|
const std::vector<App::DocumentObject *> currViews = Views.getValues();
|
||||||
std::vector<App::DocumentObject *> newViews(currViews);
|
std::vector<App::DocumentObject *> newViews(currViews);
|
||||||
newViews.push_back(docObj);
|
newViews.push_back(docObj);
|
||||||
Views.setValues(newViews);
|
Views.setValues(newViews);
|
||||||
Views.touch();
|
Views.touch();
|
||||||
|
|
||||||
return Views.getSize();
|
return Views.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,8 @@ const char* DrawView::ScaleTypeEnums[]= {"Document",
|
||||||
|
|
||||||
PROPERTY_SOURCE(TechDraw::DrawView, App::DocumentObject)
|
PROPERTY_SOURCE(TechDraw::DrawView, App::DocumentObject)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DrawView::DrawView(void)
|
DrawView::DrawView(void)
|
||||||
|
: autoPos(true)
|
||||||
{
|
{
|
||||||
static const char *group = "Drawing view";
|
static const char *group = "Drawing view";
|
||||||
ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the page in modelling units (mm)");
|
ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the page in modelling units (mm)");
|
||||||
|
@ -73,8 +72,6 @@ DrawView::DrawView(void)
|
||||||
|
|
||||||
if (isRestoring()) {
|
if (isRestoring()) {
|
||||||
autoPos = false;
|
autoPos = false;
|
||||||
} else {
|
|
||||||
autoPos = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,11 +164,8 @@ void CmdTechDrawNewPageDef::activated(int iMsg)
|
||||||
Gui::WaitCursor wc;
|
Gui::WaitCursor wc;
|
||||||
openCommand("Drawing create page");
|
openCommand("Drawing create page");
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawPage','%s')",PageName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawPage','%s')",PageName.c_str());
|
||||||
|
|
||||||
// Create the Template Object to attach to the page
|
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawSVGTemplate','%s')",TemplateName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawSVGTemplate','%s')",TemplateName.c_str());
|
||||||
|
|
||||||
//TODO: why is "Template" property set twice?
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Template = '%s'",TemplateName.c_str(), templateFileName.toStdString().c_str());
|
doCommand(Doc,"App.activeDocument().%s.Template = '%s'",TemplateName.c_str(), templateFileName.toStdString().c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Template = App.activeDocument().%s",PageName.c_str(),TemplateName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.Template = App.activeDocument().%s",PageName.c_str(),TemplateName.c_str());
|
||||||
|
|
||||||
|
@ -307,16 +304,12 @@ void CmdTechDrawNewView::activated(int iMsg)
|
||||||
Gui::WaitCursor wc;
|
Gui::WaitCursor wc;
|
||||||
const std::vector<App::DocumentObject*> selectedProjections = getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId());
|
const std::vector<App::DocumentObject*> selectedProjections = getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId());
|
||||||
|
|
||||||
float newX = 10.0;
|
|
||||||
float newY = 10.0;
|
|
||||||
float newScale = 1.0;
|
float newScale = 1.0;
|
||||||
float newRotation = 0.0;
|
float newRotation = 0.0;
|
||||||
Base::Vector3d newDirection(0.0, 0.0, 1.0);
|
Base::Vector3d newDirection(0.0, 0.0, 1.0);
|
||||||
if (!selectedProjections.empty()) {
|
if (!selectedProjections.empty()) {
|
||||||
const TechDraw::DrawView* const myView = dynamic_cast<TechDraw::DrawView*>(selectedProjections.front());
|
const TechDraw::DrawView* const myView = dynamic_cast<TechDraw::DrawView*>(selectedProjections.front());
|
||||||
|
|
||||||
newX = myView->X.getValue();
|
|
||||||
newY = myView->Y.getValue();
|
|
||||||
newScale = myView->Scale.getValue();
|
newScale = myView->Scale.getValue();
|
||||||
newRotation = myView->Rotation.getValue();
|
newRotation = myView->Rotation.getValue();
|
||||||
|
|
||||||
|
@ -335,8 +328,6 @@ void CmdTechDrawNewView::activated(int iMsg)
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewPart','%s')",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewPart','%s')",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument());
|
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Direction = (%e,%e,%e)",FeatName.c_str(), newDirection.x, newDirection.y, newDirection.z);
|
doCommand(Doc,"App.activeDocument().%s.Direction = (%e,%e,%e)",FeatName.c_str(), newDirection.x, newDirection.y, newDirection.z);
|
||||||
doCommand(Doc,"App.activeDocument().%s.X = %e",FeatName.c_str(), newX);
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Y = %e",FeatName.c_str(), newY);
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Scale = %e",FeatName.c_str(), newScale);
|
doCommand(Doc,"App.activeDocument().%s.Scale = %e",FeatName.c_str(), newScale);
|
||||||
doCommand(Doc,"App.activeDocument().%s.Rotation = %e",FeatName.c_str(), newRotation);
|
doCommand(Doc,"App.activeDocument().%s.Rotation = %e",FeatName.c_str(), newRotation);
|
||||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||||
|
@ -390,10 +381,6 @@ void CmdTechDrawNewViewSection::activated(int iMsg)
|
||||||
std::string FeatName = getUniqueObjectName("Section");
|
std::string FeatName = getUniqueObjectName("Section");
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSection','%s')",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSection','%s')",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument());
|
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Direction = (0.0,0.0,1.0)",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.X = 10.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Y = 10.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Scale = 1.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||||
}
|
}
|
||||||
updateActive();
|
updateActive();
|
||||||
|
@ -446,9 +433,6 @@ void CmdTechDrawProjGroup::activated(int iMsg)
|
||||||
std::string SourceName = (*shapes.begin())->getNameInDocument();
|
std::string SourceName = (*shapes.begin())->getNameInDocument();
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawProjGroup','%s')",multiViewName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawProjGroup','%s')",multiViewName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",multiViewName.c_str(),SourceName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",multiViewName.c_str(),SourceName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.X = %f", multiViewName.c_str(), page->getPageWidth() / 2);
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Y = %f", multiViewName.c_str(), page->getPageHeight() / 2);
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Scale = 1.0",multiViewName.c_str());
|
|
||||||
|
|
||||||
App::DocumentObject *docObj = getDocument()->getObject(multiViewName.c_str());
|
App::DocumentObject *docObj = getDocument()->getObject(multiViewName.c_str());
|
||||||
TechDraw::DrawProjGroup *multiView = dynamic_cast<TechDraw::DrawProjGroup *>(docObj);
|
TechDraw::DrawProjGroup *multiView = dynamic_cast<TechDraw::DrawProjGroup *>(docObj);
|
||||||
|
@ -506,8 +490,6 @@ void CmdTechDrawAnnotation::activated(int iMsg)
|
||||||
std::string FeatName = getUniqueObjectName("Annotation");
|
std::string FeatName = getUniqueObjectName("Annotation");
|
||||||
openCommand("Create Annotation");
|
openCommand("Create Annotation");
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewAnnotation','%s')",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewAnnotation','%s')",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.X = 10.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Y = 10.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||||
updateActive();
|
updateActive();
|
||||||
commitCommand();
|
commitCommand();
|
||||||
|
@ -748,8 +730,6 @@ void CmdTechDrawSymbol::activated(int iMsg)
|
||||||
doCommand(Doc,"svg = f.read()");
|
doCommand(Doc,"svg = f.read()");
|
||||||
doCommand(Doc,"f.close()");
|
doCommand(Doc,"f.close()");
|
||||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSymbol','%s')",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSymbol','%s')",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.X = 10.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Y = 10.0",FeatName.c_str());
|
|
||||||
doCommand(Doc,"App.activeDocument().%s.Symbol = svg",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.Symbol = svg",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||||
updateActive();
|
updateActive();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user