Leader and RichText block improvements
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
#include "DrawViewDetail.h"
|
||||
#include "DrawViewBalloon.h"
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "DrawTextLeader.h"
|
||||
#include "DrawRichAnno.h"
|
||||
|
||||
namespace TechDraw {
|
||||
extern PyObject* initModule();
|
||||
@@ -83,7 +83,7 @@ PyMOD_INIT_FUNC(TechDraw)
|
||||
TechDraw::DrawViewDetail ::init();
|
||||
TechDraw::DrawViewBalloon ::init();
|
||||
TechDraw::DrawLeaderLine ::init();
|
||||
TechDraw::DrawTextLeader ::init();
|
||||
TechDraw::DrawRichAnno ::init();
|
||||
|
||||
TechDraw::DrawTemplate ::init();
|
||||
TechDraw::DrawParametricTemplate::init();
|
||||
@@ -103,6 +103,6 @@ PyMOD_INIT_FUNC(TechDraw)
|
||||
TechDraw::DrawTemplatePython ::init();
|
||||
TechDraw::DrawViewSymbolPython::init();
|
||||
TechDraw::DrawLeaderLinePython::init();
|
||||
TechDraw::DrawTextLeaderPython::init();
|
||||
TechDraw::DrawRichAnnoPython::init();
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ generate_from_xml(DrawProjGroupPy)
|
||||
generate_from_xml(DrawProjGroupItemPy)
|
||||
generate_from_xml(DrawViewAnnotationPy)
|
||||
generate_from_xml(DrawLeaderLinePy)
|
||||
generate_from_xml(DrawTextLeaderPy)
|
||||
generate_from_xml(DrawRichAnnoPy)
|
||||
|
||||
|
||||
SET(Draw_SRCS
|
||||
@@ -97,8 +97,8 @@ SET(Draw_SRCS
|
||||
DrawViewDetail.h
|
||||
DrawLeaderLine.cpp
|
||||
DrawLeaderLine.h
|
||||
DrawTextLeader.cpp
|
||||
DrawTextLeader.h
|
||||
DrawRichAnno.cpp
|
||||
DrawRichAnno.h
|
||||
)
|
||||
|
||||
SET(TechDraw_SRCS
|
||||
@@ -158,8 +158,8 @@ SET(Python_SRCS
|
||||
DrawViewAnnotationPyImp.cpp
|
||||
DrawLeaderLinePy.xml
|
||||
DrawLeaderLinePyImp.cpp
|
||||
DrawTextLeaderPy.xml
|
||||
DrawTextLeaderPyImp.cpp
|
||||
DrawRichAnnoPy.xml
|
||||
DrawRichAnnoPyImp.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})
|
||||
|
||||
@@ -57,6 +57,7 @@ DrawLeaderLine::DrawLeaderLine(void)
|
||||
ADD_PROPERTY_TYPE(StartSymbol, (-1), group, App::Prop_None, "Symbol (arrowhead) for start of line");
|
||||
ADD_PROPERTY_TYPE(EndSymbol, (-1), group, App::Prop_None, "Symbol (arrowhead) for end of line");
|
||||
ADD_PROPERTY_TYPE(Scalable ,(false),group,App::Prop_None,"Scale line with LeaderParent");
|
||||
ADD_PROPERTY_TYPE(AutoHorizontal ,(getDefAuto()),group,App::Prop_None,"Forces last line segment horizontal");
|
||||
|
||||
//hide the DrawView properties that don't apply to Leader
|
||||
ScaleType.setStatus(App::Property::ReadOnly,true);
|
||||
@@ -76,11 +77,9 @@ DrawLeaderLine::~DrawLeaderLine()
|
||||
|
||||
void DrawLeaderLine::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//nothing in particular
|
||||
}
|
||||
// if (!isRestoring()) {
|
||||
// }
|
||||
DrawView::onChanged(prop);
|
||||
|
||||
}
|
||||
|
||||
short DrawLeaderLine::mustExecute() const
|
||||
@@ -113,6 +112,15 @@ App::DocumentObjectExecReturn *DrawLeaderLine::execute(void)
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
//this doesn't really work because LeaderParent is not available?
|
||||
void DrawLeaderLine::onDocumentRestored(void)
|
||||
{
|
||||
// Base::Console().Message("DLL::onDocumentRestored()\n");
|
||||
requestPaint();
|
||||
DrawView::onDocumentRestored();
|
||||
}
|
||||
|
||||
|
||||
DrawView* DrawLeaderLine::getBaseView(void) const
|
||||
{
|
||||
DrawView* result = nullptr;
|
||||
@@ -168,6 +176,33 @@ Base::Vector3d DrawLeaderLine::getAttachPoint(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawLeaderLine::adjustLastSegment(void)
|
||||
{
|
||||
// Base::Console().Message("DLL::adjustLastSegment()\n");
|
||||
bool adjust = AutoHorizontal.getValue();
|
||||
std::vector<Base::Vector3d> wp = WayPoints.getValues();
|
||||
if (adjust) {
|
||||
if (wp.size() > 1) {
|
||||
int iLast = wp.size() - 1;
|
||||
int iPen = wp.size() - 2;
|
||||
Base::Vector3d last = wp.at(iLast);
|
||||
Base::Vector3d penUlt = wp.at(iPen);
|
||||
last.y = penUlt.y;
|
||||
wp.at(iLast) = last;
|
||||
}
|
||||
}
|
||||
WayPoints.setValues(wp);
|
||||
}
|
||||
|
||||
bool DrawLeaderLine::getDefAuto(void) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/LeaderLines");
|
||||
bool result = hGrp->GetBool("AutoHorizontal",true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PyObject *DrawLeaderLine::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
|
||||
@@ -47,9 +47,12 @@ public:
|
||||
App::PropertyInteger StartSymbol;
|
||||
App::PropertyInteger EndSymbol;
|
||||
App::PropertyBool Scalable;
|
||||
App::PropertyBool AutoHorizontal;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
virtual void onDocumentRestored(void) override;
|
||||
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderLeader";
|
||||
@@ -62,6 +65,9 @@ public:
|
||||
virtual App::DocumentObject* getBaseObject(void) const;
|
||||
bool keepUpdated(void);
|
||||
double getScale(void);
|
||||
void adjustLastSegment(void);
|
||||
bool getDefAuto(void) const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
@@ -32,31 +32,35 @@
|
||||
|
||||
#include "DrawUtil.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawTextLeaderPy.h> // generated from DrawTextLeaderPy.xml
|
||||
#include "DrawTextLeader.h"
|
||||
#include <Mod/TechDraw/App/DrawRichAnnoPy.h> // generated from DrawRichAnnoPy.xml
|
||||
#include "DrawRichAnno.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
//===========================================================================
|
||||
// DrawTextLeader - DrawLeaderLine + movable text block
|
||||
// DrawRichAnno - movable rich text block
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawTextLeader, TechDraw::DrawLeaderLine)
|
||||
PROPERTY_SOURCE(TechDraw::DrawRichAnno, TechDraw::DrawView)
|
||||
|
||||
DrawTextLeader::DrawTextLeader(void)
|
||||
DrawRichAnno::DrawRichAnno(void)
|
||||
{
|
||||
static const char *group = "Text Leader";
|
||||
static const char *group = "Text Block";
|
||||
|
||||
ADD_PROPERTY_TYPE(LeaderText, (""), group, App::Prop_None, "Leader text");
|
||||
Base::Vector3d pos(0.0,0.0,0.0);
|
||||
ADD_PROPERTY_TYPE(TextPosition, (pos), group, App::Prop_None, "Text position relative to parent");
|
||||
ADD_PROPERTY_TYPE(AnnoParent,(0),group,(App::PropertyType)(App::Prop_None),
|
||||
"Object to which this annontation is attached");
|
||||
ADD_PROPERTY_TYPE(AnnoText, (""), group, App::Prop_None, "Anno text");
|
||||
// Base::Vector3d pos(0.0,0.0,0.0);
|
||||
// ADD_PROPERTY_TYPE(TextPosition, (pos), group, App::Prop_None, "Anno position relative to parent");
|
||||
ADD_PROPERTY_TYPE(ShowFrame, (true), group, App::Prop_None, "Outline rectangle on/off");
|
||||
ADD_PROPERTY_TYPE(MaxWidth, (-1.0), group, App::Prop_None, "Width limit before auto wrap");
|
||||
}
|
||||
|
||||
DrawTextLeader::~DrawTextLeader()
|
||||
DrawRichAnno::~DrawRichAnno()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawTextLeader::onChanged(const App::Property* prop)
|
||||
void DrawRichAnno::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//nothing in particular
|
||||
@@ -65,11 +69,11 @@ void DrawTextLeader::onChanged(const App::Property* prop)
|
||||
|
||||
}
|
||||
|
||||
short DrawTextLeader::mustExecute() const
|
||||
short DrawRichAnno::mustExecute() const
|
||||
{
|
||||
bool result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (LeaderText.isTouched());
|
||||
result = (AnnoText.isTouched());
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -78,20 +82,35 @@ short DrawTextLeader::mustExecute() const
|
||||
return DrawView::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawTextLeader::execute(void)
|
||||
App::DocumentObjectExecReturn *DrawRichAnno::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DTL::execute()\n");
|
||||
// Base::Console().Message("DRA::execute()\n");
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
PyObject *DrawTextLeader::getPyObject(void)
|
||||
DrawView* DrawRichAnno::getBaseView(void) const
|
||||
{
|
||||
// Base::Console().Message("DRA::getBaseView() - %s\n", getNameInDocument());
|
||||
DrawView* result = nullptr;
|
||||
App::DocumentObject* baseObj = AnnoParent.getValue();
|
||||
if (baseObj != nullptr) {
|
||||
DrawView* cast = dynamic_cast<DrawView*>(baseObj);
|
||||
if (cast != nullptr) {
|
||||
result = cast;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PyObject *DrawRichAnno::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawTextLeaderPy(this),true);
|
||||
PythonObject = Py::Object(new DrawRichAnnoPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
@@ -100,13 +119,13 @@ PyObject *DrawTextLeader::getPyObject(void)
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawTextLeaderPython, TechDraw::DrawTextLeader)
|
||||
template<> const char* TechDraw::DrawTextLeaderPython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderTextLeader";
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawRichAnnoPython, TechDraw::DrawRichAnno)
|
||||
template<> const char* TechDraw::DrawRichAnnoPython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderRichAnno";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawTextLeader>;
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawRichAnno>;
|
||||
}
|
||||
|
||||
@@ -20,37 +20,42 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _TechDraw_DrawTextLeader_h_
|
||||
#define _TechDraw_DrawTextLeader_h_
|
||||
#ifndef _TechDraw_DrawRichAnno_h_
|
||||
#define _TechDraw_DrawRichAnno_h_
|
||||
|
||||
# include <App/DocumentObject.h>
|
||||
# include <App/FeaturePython.h>
|
||||
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "DrawView.h"
|
||||
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class TechDrawExport DrawTextLeader : public TechDraw::DrawLeaderLine
|
||||
class TechDrawExport DrawRichAnno : public TechDraw::DrawView
|
||||
{
|
||||
PROPERTY_HEADER(TechDraw::DrawTextLeader);
|
||||
PROPERTY_HEADER(TechDraw::DrawRichAnno);
|
||||
|
||||
public:
|
||||
DrawTextLeader();
|
||||
virtual ~DrawTextLeader();
|
||||
DrawRichAnno();
|
||||
virtual ~DrawRichAnno();
|
||||
|
||||
App::PropertyString LeaderText;
|
||||
App::PropertyVector TextPosition;
|
||||
App::PropertyLink AnnoParent;
|
||||
App::PropertyString AnnoText;
|
||||
// App::PropertyVector TextPosition;
|
||||
App::PropertyBool ShowFrame;
|
||||
App::PropertyFloat MaxWidth;
|
||||
App::PropertyVector AttachPoint;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderTextLeader";
|
||||
return "TechDrawGui::ViewProviderRichAnno";
|
||||
}
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual QRectF getRect() const { return QRectF(0,0,1,1);}
|
||||
DrawView* getBaseView(void) const;
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
@@ -58,7 +63,7 @@ protected:
|
||||
private:
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<DrawTextLeader> DrawTextLeaderPython;
|
||||
typedef App::FeaturePythonT<DrawRichAnno> DrawRichAnnoPython;
|
||||
|
||||
} //namespace TechDraw
|
||||
#endif
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DrawLeaderLinePy"
|
||||
Name="DrawTextLeaderPy"
|
||||
Twin="DrawTextLeader"
|
||||
TwinPointer="DrawTextLeader"
|
||||
Include="Mod/TechDraw/App/DrawTextLeader.h"
|
||||
Father="DrawViewPy"
|
||||
Name="DrawRichAnnoPy"
|
||||
Twin="DrawRichAnno"
|
||||
TwinPointer="DrawRichAnno"
|
||||
Include="Mod/TechDraw/App/DrawRichAnno.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="Mod/TechDraw/App/DrawLeaderLinePy.h"
|
||||
FatherInclude="Mod/TechDraw/App/DrawViewPy.h"
|
||||
FatherNamespace="TechDraw">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for adding text leaders to Technical Drawings</UserDocu>
|
||||
<UserDocu>Feature for adding rich annotation blocks to Technical Drawings</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
@@ -28,27 +28,27 @@
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include "DrawTextLeader.h"
|
||||
#include "DrawRichAnno.h"
|
||||
|
||||
// inclusion of the generated files (generated out of DrawTextLeaderPy.xml)
|
||||
// inclusion of the generated files (generated out of DrawRichAnnoPy.xml)
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Mod/TechDraw/App/DrawTextLeaderPy.h>
|
||||
#include <Mod/TechDraw/App/DrawTextLeaderPy.cpp>
|
||||
#include <Mod/TechDraw/App/DrawRichAnnoPy.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnnoPy.cpp>
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string DrawTextLeaderPy::representation(void) const
|
||||
std::string DrawRichAnnoPy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawTextLeader object>");
|
||||
return std::string("<DrawRichAnno object>");
|
||||
}
|
||||
|
||||
PyObject *DrawTextLeaderPy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject *DrawRichAnnoPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawTextLeaderPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
int DrawRichAnnoPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "ViewProviderGeomHatch.h"
|
||||
#include "ViewProviderSpreadsheet.h"
|
||||
#include "ViewProviderImage.h"
|
||||
#include "ViewProviderRichAnno.h"
|
||||
#include "ViewProviderLeader.h"
|
||||
|
||||
|
||||
@@ -130,7 +131,7 @@ PyMOD_INIT_FUNC(TechDrawGui)
|
||||
TechDrawGui::ViewProviderSpreadsheet::init();
|
||||
TechDrawGui::ViewProviderImage::init();
|
||||
TechDrawGui::ViewProviderLeader::init();
|
||||
TechDrawGui::ViewProviderTextLeader::init();
|
||||
TechDrawGui::ViewProviderRichAnno::init();
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawImp> ("TechDraw");
|
||||
|
||||
@@ -38,11 +38,12 @@ set(TechDrawGui_MOC_HDRS
|
||||
DlgTemplateField.h
|
||||
TaskSectionView.h
|
||||
TaskGeomHatch.h
|
||||
TaskTextLeader.h
|
||||
TaskLeaderLine.h
|
||||
TaskRichAnno.h
|
||||
QGEPath.h
|
||||
QGTracker.h
|
||||
QGILeaderLine.h
|
||||
QGITextLeader.h
|
||||
QGIRichAnno.h
|
||||
QGMText.h
|
||||
mrichtextedit.h
|
||||
mtextedit.h
|
||||
@@ -65,7 +66,8 @@ set(TechDrawGui_UIC_SRCS
|
||||
DlgTemplateField.ui
|
||||
TaskSectionView.ui
|
||||
TaskGeomHatch.ui
|
||||
TaskTextLeader.ui
|
||||
TaskLeaderLine.ui
|
||||
TaskRichAnno.ui
|
||||
mrichtextedit.ui
|
||||
)
|
||||
|
||||
@@ -123,9 +125,12 @@ SET(TechDrawGui_SRCS
|
||||
TaskGeomHatch.ui
|
||||
TaskGeomHatch.cpp
|
||||
TaskGeomHatch.h
|
||||
TaskTextLeader.ui
|
||||
TaskTextLeader.cpp
|
||||
TaskTextLeader.h
|
||||
TaskLeaderLine.ui
|
||||
TaskLeaderLine.cpp
|
||||
TaskLeaderLine.h
|
||||
TaskRichAnno.ui
|
||||
TaskRichAnno.cpp
|
||||
TaskRichAnno.h
|
||||
DrawGuiUtil.cpp
|
||||
DrawGuiUtil.h
|
||||
Rez.cpp
|
||||
@@ -215,8 +220,8 @@ SET(TechDrawGuiView_SRCS
|
||||
QGTracker.h
|
||||
QGILeaderLine.cpp
|
||||
QGILeaderLine.h
|
||||
QGITextLeader.cpp
|
||||
QGITextLeader.h
|
||||
QGIRichAnno.cpp
|
||||
QGIRichAnno.h
|
||||
QGMText.h
|
||||
QGMText.cpp
|
||||
TemplateTextField.cpp
|
||||
@@ -258,6 +263,8 @@ SET(TechDrawGuiViewProvider_SRCS
|
||||
ViewProviderImage.h
|
||||
ViewProviderLeader.cpp
|
||||
ViewProviderLeader.h
|
||||
ViewProviderRichAnno.cpp
|
||||
ViewProviderRichAnno.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP("MRTE" FILES ${MRTE_SRCS})
|
||||
@@ -270,7 +277,8 @@ SET(TechDrawGuiTaskDlgs_SRCS
|
||||
TaskLinkDim.ui
|
||||
TaskSectionView.ui
|
||||
TaskGeomHatch.ui
|
||||
TaskTextLeader.ui
|
||||
TaskLeaderLine.ui
|
||||
TaskRichAnno.ui
|
||||
mrichtextedit.ui
|
||||
)
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "TaskGeomHatch.h"
|
||||
#include "TaskTextLeader.h"
|
||||
#include "TaskLeaderLine.h"
|
||||
#include "TaskRichAnno.h"
|
||||
#include "ViewProviderGeomHatch.h"
|
||||
#include "ViewProviderPage.h"
|
||||
|
||||
@@ -89,9 +90,6 @@ CmdTechDrawLeaderLine::CmdTechDrawLeaderLine()
|
||||
void CmdTechDrawLeaderLine::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Not Available"),
|
||||
QObject::tr("Line function is not available. Use Text Leader."));
|
||||
return;
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg != nullptr) {
|
||||
@@ -120,12 +118,8 @@ void CmdTechDrawLeaderLine::activated(int iMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgTextLeader(LINEMODE,
|
||||
baseFeat,
|
||||
Gui::Control().showDialog(new TechDrawGui::TaskDlgLeaderLine(baseFeat,
|
||||
page));
|
||||
// Gui::Control().showDialog(new TaskDlgLeaderLine(1,
|
||||
// baseFeat,
|
||||
// page));
|
||||
}
|
||||
|
||||
bool CmdTechDrawLeaderLine::isActive(void)
|
||||
@@ -136,24 +130,24 @@ bool CmdTechDrawLeaderLine::isActive(void)
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_TextLeader
|
||||
// TechDraw_RichAnno
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawTextLeader);
|
||||
DEF_STD_CMD_A(CmdTechDrawRichAnno);
|
||||
|
||||
CmdTechDrawTextLeader::CmdTechDrawTextLeader()
|
||||
: Command("TechDraw_TextLeader")
|
||||
CmdTechDrawRichAnno::CmdTechDrawRichAnno()
|
||||
: Command("TechDraw_RichAnno")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Add a text leader to a view");
|
||||
sToolTipText = QT_TR_NOOP("Add a text leader to a view");
|
||||
sWhatsThis = "TechDraw_TextLeader";
|
||||
sMenuText = QT_TR_NOOP("Add a rich text annotation");
|
||||
sToolTipText = QT_TR_NOOP("Add a rich text annotation");
|
||||
sWhatsThis = "TechDraw_RichAnno";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/techdraw-textleader";
|
||||
}
|
||||
|
||||
void CmdTechDrawTextLeader::activated(int iMsg)
|
||||
void CmdTechDrawRichAnno::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
@@ -172,23 +166,22 @@ void CmdTechDrawTextLeader::activated(int iMsg)
|
||||
TechDraw::DrawView* baseFeat = nullptr;
|
||||
if (!selection.empty()) {
|
||||
baseFeat = dynamic_cast<TechDraw::DrawView *>(selection[0].getObject());
|
||||
if( baseFeat == nullptr ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("Can not attach leader. No base View selected."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("You must select a base View for the line."));
|
||||
return;
|
||||
// if( baseFeat == nullptr ) {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
// QObject::tr("Can not attach leader. No base View selected."));
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
// QObject::tr("You must select a base View for the line."));
|
||||
// return;
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgTextLeader(TEXTMODE,
|
||||
baseFeat,
|
||||
page));
|
||||
Gui::Control().showDialog(new TaskDlgRichAnno(baseFeat,
|
||||
page));
|
||||
}
|
||||
|
||||
bool CmdTechDrawTextLeader::isActive(void)
|
||||
bool CmdTechDrawRichAnno::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this, false);
|
||||
@@ -477,7 +470,7 @@ void CreateTechDrawCommandsDecorate(void)
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToggleFrame());
|
||||
// rcCmdMgr.addCommand(new CmdTechDrawRedrawPage());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawLeaderLine());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawTextLeader());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawRichAnno());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewSymbol.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGIDrawingTemplate.h"
|
||||
@@ -96,6 +97,8 @@
|
||||
#include "ViewProviderPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "QGIRichAnno.h"
|
||||
#include "QGMText.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -167,6 +170,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||
//therefore we need to make sure parentage of the graphics representation is set properly. bit of a kludge.
|
||||
setDimensionGroups();
|
||||
setBalloonGroups();
|
||||
setLeaderGroups();
|
||||
|
||||
App::DocumentObject *obj = m_vpPage->getDrawPage()->Template.getValue();
|
||||
auto pageTemplate( dynamic_cast<TechDraw::DrawTemplate *>(obj) );
|
||||
@@ -228,6 +232,23 @@ void MDIViewPage::setBalloonGroups(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::setLeaderGroups(void)
|
||||
{
|
||||
const std::vector<QGIView *> &allItems = m_view->getViews();
|
||||
std::vector<QGIView *>::const_iterator itInspect;
|
||||
int leadItemType = QGraphicsItem::UserType + 232;
|
||||
|
||||
for (itInspect = allItems.begin(); itInspect != allItems.end(); itInspect++) {
|
||||
if (((*itInspect)->type() == leadItemType) && (!(*itInspect)->group())) {
|
||||
QGIView* parent = m_view->findParent((*itInspect));
|
||||
if (parent) {
|
||||
QGILeaderLine* lead = dynamic_cast<QGILeaderLine*>((*itInspect));
|
||||
m_view->addLeaderToParent(lead,parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::setDocumentObject(const std::string& name)
|
||||
{
|
||||
m_objectName = name;
|
||||
@@ -238,7 +259,6 @@ void MDIViewPage::setDocumentName(const std::string& name)
|
||||
m_documentName = name;
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::closeEvent(QCloseEvent* ev)
|
||||
{
|
||||
MDIView::closeEvent(ev);
|
||||
@@ -338,6 +358,9 @@ bool MDIViewPage::attachView(App::DocumentObject *obj)
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) ) {
|
||||
qview = m_view->addViewLeader( static_cast<TechDraw::DrawLeaderLine *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId()) ) {
|
||||
qview = m_view->addRichAnno( static_cast<TechDraw::DrawRichAnno*>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()) ) {
|
||||
//Hatch is not attached like other Views (since it isn't really a View)
|
||||
return true;
|
||||
@@ -1107,7 +1130,7 @@ void MDIViewPage::sceneSelectionChanged()
|
||||
setTreeToSceneSelect();
|
||||
}
|
||||
|
||||
//Note: no guarantee of selection order???
|
||||
//Note: Qt says: "no guarantee of selection order"!!!
|
||||
void MDIViewPage::setTreeToSceneSelect(void)
|
||||
{
|
||||
bool saveBlock = blockConnection(true); // block selectionChanged signal from Tree/Observer
|
||||
@@ -1118,6 +1141,8 @@ void MDIViewPage::setTreeToSceneSelect(void)
|
||||
for (QList<QGraphicsItem*>::iterator it = sceneSel.begin(); it != sceneSel.end(); ++it) {
|
||||
QGIView *itemView = dynamic_cast<QGIView *>(*it);
|
||||
if(itemView == 0) {
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - selection not QGIView - type: %d\n",
|
||||
// (*it)->type() - QGraphicsItem::UserType);
|
||||
QGIEdge *edge = dynamic_cast<QGIEdge *>(*it);
|
||||
if(edge) {
|
||||
QGraphicsItem*parent = edge->parentItem();
|
||||
@@ -1214,7 +1239,48 @@ void MDIViewPage::setTreeToSceneSelect(void)
|
||||
//bool accepted =
|
||||
static_cast<void> (Gui::Selection().addSelection(dimObj->getDocument()->getName(),dimObj->getNameInDocument()));
|
||||
}
|
||||
|
||||
QGMText *mText = dynamic_cast<QGMText*>(*it);
|
||||
if(mText) {
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mTextSelected!\n");
|
||||
QGraphicsItem* textParent = mText->QGraphicsItem::parentItem();
|
||||
if(!textParent) {
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mText has no parent item\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
QGIView *parent = dynamic_cast<QGIView *>(textParent);
|
||||
|
||||
if(!parent) {
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mText parent is not QGIV\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
TechDraw::DrawView *parentFeat = parent->getViewObject();
|
||||
if (!parentFeat) {
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mText has no parent Feature\n");
|
||||
continue;
|
||||
}
|
||||
// if (!parentFeat->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
// //mtext is parented to something other than Leader
|
||||
// //need special cases here?
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mText parentFeat is not LeaderLine\n");
|
||||
// continue;
|
||||
// }
|
||||
const char* name = parentFeat->getNameInDocument();
|
||||
if (!name) { //can happen during undo/redo if Dim is selected???
|
||||
// Base::Console().Message("INFO - MDIVP::sceneSelectionChanged - parentFeat name is null!\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
//bool accepted =
|
||||
static_cast<void> (Gui::Selection().addSelection(parentFeat->getDocument()->getName(),parentFeat->getNameInDocument()));
|
||||
}
|
||||
|
||||
} else {
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - selection IS a QGIView - type: %d\n",
|
||||
// itemView->type() - QGraphicsItem::UserType);
|
||||
|
||||
TechDraw::DrawView *viewObj = itemView->getViewObject();
|
||||
if (viewObj && !viewObj->isRemoving()) {
|
||||
std::string doc_name = viewObj->getDocument()->getName();
|
||||
|
||||
@@ -127,6 +127,7 @@ protected:
|
||||
QPrinter::PaperSize getPaperSize(int w, int h) const;
|
||||
void setDimensionGroups(void);
|
||||
void setBalloonGroups(void);
|
||||
void setLeaderGroups(void);
|
||||
void showStatusMsg(const char* s1, const char* s2, const char* s3) const;
|
||||
|
||||
void onDeleteObject(const App::DocumentObject& obj);
|
||||
|
||||
@@ -48,9 +48,9 @@ public:
|
||||
int type() const { return Type;}
|
||||
|
||||
void setHighlighted(bool state);
|
||||
void setPrettyNormal();
|
||||
void setPrettyPre();
|
||||
void setPrettySel();
|
||||
virtual void setPrettyNormal();
|
||||
virtual void setPrettyPre();
|
||||
virtual void setPrettySel();
|
||||
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
virtual void centerAt(QPointF centerPos);
|
||||
|
||||
@@ -174,8 +174,8 @@ QGEPath::QGEPath() :
|
||||
m_parentItem(nullptr)
|
||||
{
|
||||
setHandlesChildEvents(false);
|
||||
setAcceptHoverEvents(false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
setAcceptHoverEvents(true);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
// setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
|
||||
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
|
||||
@@ -190,12 +190,47 @@ QGEPath::QGEPath() :
|
||||
|
||||
QVariant QGEPath::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
// Base::Console().Message("QGEPath::itemChange(%d)\n",change);
|
||||
// Q_EMIT dragging();
|
||||
|
||||
// Base::Console().Message("QGEP::itemChange(%d) - type: %d\n", change,type() - QGraphicsItem::UserType);
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
Q_EMIT selected(true);
|
||||
setPrettySel();
|
||||
} else {
|
||||
Q_EMIT selected(false);
|
||||
setPrettyNormal();
|
||||
}
|
||||
}
|
||||
return QGIPrimPath::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGEPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_EMIT hover(true);
|
||||
if (!isSelected()) {
|
||||
setPrettyPre();
|
||||
}
|
||||
QGIPrimPath::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void QGEPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGIView *view = dynamic_cast<QGIView *> (parentItem());
|
||||
assert(view != 0);
|
||||
Q_UNUSED(view);
|
||||
|
||||
Q_EMIT hover(false);
|
||||
QGraphicsItem* parent = parentItem();
|
||||
bool parentSel(false);
|
||||
if (parent != nullptr) {
|
||||
parentSel = parent->isSelected();
|
||||
}
|
||||
if (!parentSel && !isSelected()) {
|
||||
setPrettyNormal();
|
||||
}
|
||||
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||
// QGIPrimPath::hoverLeaveEvent(event); //QGIPP::hoverleave will reset pretty to normal
|
||||
}
|
||||
|
||||
void QGEPath::startPathEdit()
|
||||
{
|
||||
// Base::Console().Message("QGEPath::startPathEdit()\n");
|
||||
@@ -325,7 +360,7 @@ void QGEPath::updatePath(void)
|
||||
}
|
||||
}
|
||||
setPath(result);
|
||||
setPrettyNormal();
|
||||
// setPrettyNormal();
|
||||
}
|
||||
|
||||
void QGEPath::makeDeltasFromPoints(std::vector<QPointF> pts)
|
||||
|
||||
@@ -120,9 +120,13 @@ public Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
void pointsUpdated(std::vector<QPointF> pts);
|
||||
void hover(bool state);
|
||||
void selected(bool state);
|
||||
|
||||
protected:
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
std::vector<QPointF> m_deltas; //deltas between points 1:1 scale, starts at (0,0)
|
||||
std::vector<QGMarker*> m_markers;
|
||||
QPointF m_attach;
|
||||
|
||||
@@ -74,11 +74,13 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
|
||||
TechDraw::DrawLeaderLine* leader) :
|
||||
m_parentItem(myParent),
|
||||
m_lineWidth(0.0),
|
||||
m_lineColor(Qt::black)
|
||||
m_lineColor(Qt::black),
|
||||
m_hasHover(false)
|
||||
|
||||
{
|
||||
setHandlesChildEvents(false);
|
||||
setAcceptHoverEvents(false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
setAcceptHoverEvents(true);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
|
||||
@@ -88,11 +90,13 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
|
||||
m_lineColor = Qt::blue;
|
||||
|
||||
m_line = new QGEPath();
|
||||
m_line->setNormalColor(getNormalColor());
|
||||
// m_line->setPrettyNormal();
|
||||
|
||||
addToGroup(m_line);
|
||||
m_line->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
m_line->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
|
||||
m_line->setAcceptHoverEvents(false);
|
||||
m_line->setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
m_arrow1 = new QGIArrow();
|
||||
@@ -112,19 +116,48 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
|
||||
m_line, SIGNAL(pointsUpdated(std::vector<QPointF>)),
|
||||
this , SLOT (onLineEditFinished(std::vector<QPointF>))
|
||||
);
|
||||
QObject::connect(
|
||||
m_line, SIGNAL(selected(bool)),
|
||||
this , SLOT (select(bool)));
|
||||
|
||||
QObject::connect(
|
||||
m_line, SIGNAL(hover(bool)),
|
||||
this , SLOT (hover(bool)));
|
||||
|
||||
}
|
||||
|
||||
QVariant QGILeaderLine::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
// Base::Console().Message("QGIV::itemChange(%d)\n", change);
|
||||
// Base::Console().Message("QGILL::itemChange(%d)\n", change);
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
//There's nothing special for QGIVL to do when selection changes!
|
||||
if(isSelected()) {
|
||||
m_line->setSelected(true);
|
||||
m_arrow1->setSelected(true);
|
||||
m_arrow2->setSelected(true);
|
||||
} else {
|
||||
m_line->setSelected(false);
|
||||
m_arrow1->setSelected(false);
|
||||
m_arrow2->setSelected(false);
|
||||
}
|
||||
draw();
|
||||
} else if(change == ItemSceneChange && scene()) {
|
||||
// nothing special!
|
||||
}
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGILeaderLine::select(bool state)
|
||||
{
|
||||
setSelected(state);
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGILeaderLine::hover(bool state)
|
||||
{
|
||||
m_hasHover = state;
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGILeaderLine::onLineEditFinished(std::vector<QPointF> pts)
|
||||
{
|
||||
// Base::Console().Message("QGIVL::onLineEditFinished(%d)\n",pts.size());
|
||||
@@ -135,7 +168,7 @@ void QGILeaderLine::onLineEditFinished(std::vector<QPointF> pts)
|
||||
}
|
||||
|
||||
if (m_parentItem == nullptr) {
|
||||
Base::Console().Log("QGIVL::onLineEditFinished - m_parentItem is NULL\n");
|
||||
Base::Console().Log("QGILL::onLineEditFinished - m_parentItem is NULL\n");
|
||||
} else {
|
||||
QGIView* qgiv = dynamic_cast<QGIView*>(m_parentItem);
|
||||
if (qgiv != nullptr) {
|
||||
@@ -158,7 +191,7 @@ void QGILeaderLine::updateView(bool update)
|
||||
Q_UNUSED(update);
|
||||
auto leadFeat( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
|
||||
if ( leadFeat == nullptr ) {
|
||||
Base::Console().Log("QGIL::updateView - no feature!\n");
|
||||
Base::Console().Log("QGILL::updateView - no feature!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -172,7 +205,7 @@ void QGILeaderLine::updateView(bool update)
|
||||
|
||||
void QGILeaderLine::draw()
|
||||
{
|
||||
// Base::Console().("QGIL::draw()- %s\n", getViewObject()->getNameInDocument());
|
||||
// Base::Console().Message("QGILL::draw()- %s\n", getViewObject()->getNameInDocument());
|
||||
if (!isVisible()) {
|
||||
Base::Console().Log("QGIL::draw - not visible\n");
|
||||
return;
|
||||
@@ -224,7 +257,6 @@ void QGILeaderLine::draw()
|
||||
Base::Console().Log("QGIL::draw - no points\n");
|
||||
return;
|
||||
}
|
||||
// m_line->setAttach(aPoint);
|
||||
m_line->setStyle(m_lineStyle);
|
||||
double scaler = 1.0;
|
||||
m_line->setWidth(scaler * m_lineWidth);
|
||||
@@ -239,7 +271,19 @@ void QGILeaderLine::draw()
|
||||
|
||||
setArrows(qPoints);
|
||||
|
||||
QGIView::draw();
|
||||
if (m_hasHover && !isSelected()) {
|
||||
m_arrow1->setPrettyPre();
|
||||
m_arrow2->setPrettyPre();
|
||||
m_line->setPrettyPre();
|
||||
} else if (isSelected()) {
|
||||
m_arrow1->setPrettySel();
|
||||
m_arrow2->setPrettySel();
|
||||
m_line->setPrettySel();
|
||||
} else {
|
||||
m_arrow1->setPrettyNormal();
|
||||
m_arrow2->setPrettyNormal();
|
||||
m_line->setPrettyNormal();
|
||||
}
|
||||
}
|
||||
|
||||
void QGILeaderLine::drawBorder()
|
||||
@@ -285,6 +329,8 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow1->setDirMode(true);
|
||||
m_arrow1->setDirection(stdX);
|
||||
m_arrow1->setNormalColor(m_lineColor);
|
||||
|
||||
if (pathPoints.size() > 1) {
|
||||
auto it = pathPoints.begin();
|
||||
QPointF s = (*it);
|
||||
@@ -292,9 +338,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
QPointF qsVec = s - e;
|
||||
Base::Vector3d sVec(qsVec.x(),qsVec.y(),0.0);
|
||||
m_arrow1->setDirection(sVec);
|
||||
m_arrow1->setNormalColor(m_lineColor);
|
||||
m_arrow1->setPos(0.0,0.0);
|
||||
m_arrow1->setPrettyNormal();
|
||||
}
|
||||
m_arrow1->draw();
|
||||
m_arrow1->show();
|
||||
@@ -307,6 +351,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
m_arrow2->setWidth(m_lineWidth);
|
||||
m_arrow2->setDirMode(true);
|
||||
m_arrow2->setDirection(-stdX);
|
||||
m_arrow2->setNormalColor(m_lineColor);
|
||||
if (pathPoints.size() > 1) {
|
||||
auto itr = pathPoints.rbegin();
|
||||
QPointF s = (*itr);
|
||||
@@ -314,9 +359,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
QPointF qeVec = s - e;
|
||||
Base::Vector3d eVec(qeVec.x(),qeVec.y(),0.0);
|
||||
m_arrow2->setDirection(eVec);
|
||||
m_arrow2->setNormalColor(m_lineColor);
|
||||
m_arrow2->setPos(lastOffset);
|
||||
m_arrow2->setPrettyNormal();
|
||||
}
|
||||
m_arrow2->draw();
|
||||
m_arrow2->show();
|
||||
@@ -355,6 +398,27 @@ double QGILeaderLine::getEdgeFuzz(void) const
|
||||
return result;
|
||||
}
|
||||
|
||||
QColor QGILeaderLine::getNormalColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/LeaderLinens");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
|
||||
m_colNormal = fcColor.asValue<QColor>();
|
||||
|
||||
auto lead( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
|
||||
if( lead == nullptr )
|
||||
return m_colNormal;
|
||||
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
m_colNormal = vp->Color.getValue().asValue<QColor>();
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
QRectF QGILeaderLine::boundingRect() const
|
||||
{
|
||||
return childrenBoundingRect();
|
||||
|
||||
@@ -82,6 +82,8 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void onLineEditFinished(std::vector<QPointF> pts); //QGEPath is finished editing points
|
||||
void select(bool state);
|
||||
void hover(bool state);
|
||||
|
||||
Q_SIGNALS:
|
||||
void editComplete(std::vector<QPointF> pts, QGIView* parent); //tell caller that edit session is finished
|
||||
@@ -94,6 +96,8 @@ protected:
|
||||
Base::Vector3d m_attachPoint;
|
||||
|
||||
protected:
|
||||
QColor getNormalColor();
|
||||
|
||||
QGraphicsItem* m_parentItem;
|
||||
QGEPath* m_line;
|
||||
QGIArrow* m_arrow1;
|
||||
@@ -101,6 +105,7 @@ protected:
|
||||
double m_lineWidth;
|
||||
QColor m_lineColor;
|
||||
Qt::PenStyle m_lineStyle;
|
||||
bool m_hasHover;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ QGIPrimPath::QGIPrimPath():
|
||||
|
||||
QVariant QGIPrimPath::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::itemChange(%d) - type: %d\n", change,type() - QGraphicsItem::UserType);
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
setPrettySel();
|
||||
@@ -85,15 +86,13 @@ void QGIPrimPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void QGIPrimPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
// QGIView *view = dynamic_cast<QGIView *> (parentItem()); //this is temp for debug??
|
||||
// assert(view != 0);
|
||||
// Q_UNUSED(view);
|
||||
if(!isSelected() && !isHighlighted) {
|
||||
if(!isSelected()) {
|
||||
setPrettyNormal();
|
||||
}
|
||||
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
//set highlighted is obsolete
|
||||
void QGIPrimPath::setHighlighted(bool b)
|
||||
{
|
||||
isHighlighted = b;
|
||||
|
||||
@@ -51,46 +51,52 @@
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawTextLeader.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "QGIArrow.h"
|
||||
#include "ViewProviderLeader.h"
|
||||
#include "ViewProviderRichAnno.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIPrimPath.h"
|
||||
#include "QGEPath.h"
|
||||
#include "QGMText.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "QGIView.h"
|
||||
|
||||
#include "QGITextLeader.h"
|
||||
#include "QGIRichAnno.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
|
||||
//**************************************************************
|
||||
QGITextLeader::QGITextLeader(QGraphicsItem* myParent,
|
||||
TechDraw::DrawTextLeader* leader) :
|
||||
QGILeaderLine(myParent,leader)
|
||||
QGIRichAnno::QGIRichAnno(QGraphicsItem* myParent,
|
||||
TechDraw::DrawRichAnno* anno)
|
||||
{
|
||||
// Base::Console().Message("QGITL::QGITL() - %s\n", leader->getNameInDocument());
|
||||
setHandlesChildEvents(false);
|
||||
setAcceptHoverEvents(false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false); //we actually select & drag m_text
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
|
||||
|
||||
if (myParent != nullptr) {
|
||||
setParentItem(myParent);
|
||||
}
|
||||
setViewFeature(anno);
|
||||
|
||||
m_text = new QGMText();
|
||||
m_text->setTextInteractionFlags(Qt::NoTextInteraction);
|
||||
addToGroup(m_text);
|
||||
// m_text->setZValue(ZVALUE::DIMENSION);
|
||||
m_text->setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
// we should be able to just drag QGIRA instead of m_text item??
|
||||
QObject::connect(
|
||||
m_text, SIGNAL(dragging()),
|
||||
this , SLOT (textDragging())
|
||||
@@ -99,24 +105,31 @@ QGITextLeader::QGITextLeader(QGraphicsItem* myParent,
|
||||
m_text, SIGNAL(dragFinished()),
|
||||
this , SLOT (textDragFinished())
|
||||
);
|
||||
QObject::connect(
|
||||
m_text, SIGNAL(selected(bool)),
|
||||
this , SLOT (select(bool)));
|
||||
|
||||
QObject::connect(
|
||||
m_text, SIGNAL(hover(bool)),
|
||||
this , SLOT (hover(bool)));
|
||||
}
|
||||
|
||||
QVariant QGITextLeader::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
QVariant QGIRichAnno::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
//There's nothing special for QGIVL to do when selection changes!
|
||||
//There's nothing special for QGIRA to do when selection changes!
|
||||
} else if(change == ItemSceneChange && scene()) {
|
||||
// nothing special!
|
||||
}
|
||||
return QGILeaderLine::itemChange(change, value);
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGITextLeader::textDragging(void)
|
||||
void QGIRichAnno::textDragging(void)
|
||||
{
|
||||
// Base::Console().Message("QGIL::textDragging()\n");
|
||||
//this is the long way around. can we do it without crossing the App/Gui boundary?
|
||||
//just update graphics until drag finished.
|
||||
// auto lead( dynamic_cast<TechDraw::DrawTextLeader*>(getFeature()) );
|
||||
// auto lead( dynamic_cast<TechDraw::DrawRichAnno*>(getFeature()) );
|
||||
|
||||
// if( lead == nullptr ) {
|
||||
// return;
|
||||
@@ -131,68 +144,90 @@ void QGITextLeader::textDragging(void)
|
||||
// draw();
|
||||
}
|
||||
|
||||
void QGITextLeader::textDragFinished(void)
|
||||
void QGIRichAnno::textDragFinished(void)
|
||||
{
|
||||
// Base::Console().Message("QGIL::textDragFinished()\n");
|
||||
auto lead( dynamic_cast<TechDraw::DrawTextLeader*>(getFeature()) );
|
||||
auto anno( dynamic_cast<TechDraw::DrawRichAnno*>(getFeature()) );
|
||||
|
||||
if( lead == nullptr ) {
|
||||
if( anno == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
double x = Rez::appX(m_text->x()),
|
||||
y = Rez::appX(m_text->y());
|
||||
Base::Vector3d tPos(x,-y,0.0);
|
||||
lead->TextPosition.setValue(tPos);
|
||||
y = - Rez::appX(m_text->y());
|
||||
anno->X.setValue(x);
|
||||
anno->Y.setValue(y);
|
||||
}
|
||||
|
||||
void QGITextLeader::onTextSelect(bool state)
|
||||
void QGIRichAnno::select(bool state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
setSelected(state);
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGITextLeader::draw()
|
||||
void QGIRichAnno::hover(bool state)
|
||||
{
|
||||
// Base::Console().Message("QGITL::draw()- %s\n", getViewObject()->getNameInDocument());
|
||||
m_hasHover = state;
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIRichAnno::updateView(bool update)
|
||||
{
|
||||
// Base::Console().Message("QGIRA::updateView() - %s\n", getViewName());
|
||||
Q_UNUSED(update);
|
||||
auto annoFeat( dynamic_cast<TechDraw::DrawRichAnno*>(getViewObject()) );
|
||||
if ( annoFeat == nullptr ) {
|
||||
Base::Console().Log("QGIRA::updateView - no feature!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIRichAnno::drawBorder()
|
||||
{
|
||||
////Leaders have no border!
|
||||
// QGIView::drawBorder(); //good for debugging
|
||||
}
|
||||
|
||||
|
||||
void QGIRichAnno::draw()
|
||||
{
|
||||
// Base::Console().Log("QGITL::draw() - %s\n",getFeature()->getNameInDocument());
|
||||
if (!isVisible()) {
|
||||
Base::Console().Log("QGITL::draw - not visible\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawTextLeader* leadFeat = getFeature();
|
||||
if((!leadFeat) ) {
|
||||
TechDraw::DrawRichAnno* annoFeat = getFeature();
|
||||
if((!annoFeat) ) {
|
||||
Base::Console().Log("QGITL::draw - no feature\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderTextLeader*>(getViewProvider(getFeature()));
|
||||
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(getFeature()));
|
||||
if ( vp == nullptr ) {
|
||||
Base::Console().Log("QGITL::draw - no viewprovider\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawView* parent = leadFeat->getBaseView();
|
||||
QGVPage* view = QGILeaderLine::getGraphicsView(parent);
|
||||
if (view == nullptr) {
|
||||
Base::Console().Log("QGITL::draw - no graphcisView for parent!! - setup?\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// double scale = leadFeat->getScale();
|
||||
QGILeaderLine::draw();
|
||||
QGIView::draw();
|
||||
|
||||
setTextItem();
|
||||
|
||||
}
|
||||
|
||||
void QGITextLeader::setTextItem()
|
||||
void QGIRichAnno::setTextItem()
|
||||
{
|
||||
// Base::Console().Message("QGIVL::setTextItem()\n");
|
||||
TechDraw::DrawTextLeader* leadFeat = getFeature();
|
||||
auto vp = static_cast<ViewProviderTextLeader*>(getViewProvider(getFeature()));
|
||||
// Base::Console().Message("QGIRA::setTextItem() - %s\n",getViewName());
|
||||
TechDraw::DrawRichAnno* annoFeat = getFeature();
|
||||
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(annoFeat));
|
||||
if ( vp == nullptr ) {
|
||||
Base::Console().Log("QGIVL::setTextItem - no ViewProvider\n");
|
||||
Base::Console().Log("QGIRA::setTextItem - no ViewProvider\n");
|
||||
return;
|
||||
}
|
||||
QFont font = m_text->font();
|
||||
@@ -202,7 +237,7 @@ void QGITextLeader::setTextItem()
|
||||
|
||||
//convert point font sizes to (Rez,mm) font sizes
|
||||
QRegExp rxFontSize(QString::fromUtf8("font-size:([0-9]*)pt;"));
|
||||
QString inHtml = QString::fromUtf8(leadFeat->LeaderText.getValue());
|
||||
QString inHtml = QString::fromUtf8(annoFeat->AnnoText.getValue());
|
||||
QString match;
|
||||
double mmPerPoint = 0.353;
|
||||
double sizeConvert = Rez::getRezFactor() * mmPerPoint;
|
||||
@@ -230,48 +265,50 @@ void QGITextLeader::setTextItem()
|
||||
}
|
||||
|
||||
m_text->setHtml(outHtml);
|
||||
m_text->setPrettyNormal();
|
||||
|
||||
m_text->setTextWidth(Rez::guiX(vp->MaxWidth.getValue()));
|
||||
m_text->showBox(vp->ShowFrame.getValue());
|
||||
m_text->setTextWidth(Rez::guiX(annoFeat->MaxWidth.getValue()));
|
||||
m_text->showBox(annoFeat->ShowFrame.getValue());
|
||||
|
||||
double scale = getScale();
|
||||
Base::Vector3d textPos = Rez::guiX(leadFeat->TextPosition.getValue());
|
||||
double x = Rez::guiX(annoFeat->X.getValue());
|
||||
double y = Rez::guiX(annoFeat->Y.getValue());
|
||||
Base::Vector3d textPos(x,y,0.0);
|
||||
QPointF tPos(textPos.x * scale,- textPos.y * scale);
|
||||
m_text->setPos(tPos);
|
||||
}
|
||||
|
||||
//void QGITextLeader::drawBorder()
|
||||
//void QGIRichAnno::drawBorder()
|
||||
//{
|
||||
//////Leaders have no border!
|
||||
//// QGIView::drawBorder(); //good for debugging
|
||||
//}
|
||||
|
||||
|
||||
TechDraw::DrawTextLeader* QGITextLeader::getFeature(void)
|
||||
TechDraw::DrawRichAnno* QGIRichAnno::getFeature(void)
|
||||
{
|
||||
TechDraw::DrawTextLeader* result =
|
||||
static_cast<TechDraw::DrawTextLeader*>(getViewObject());
|
||||
TechDraw::DrawRichAnno* result =
|
||||
static_cast<TechDraw::DrawRichAnno*>(getViewObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
QRectF QGITextLeader::boundingRect() const
|
||||
QRectF QGIRichAnno::boundingRect() const
|
||||
{
|
||||
return childrenBoundingRect();
|
||||
QRectF rect = mapFromItem(m_text,m_text->boundingRect()).boundingRect();
|
||||
return rect.adjusted(-10.,-10.,10.,10.);
|
||||
}
|
||||
|
||||
QPainterPath QGITextLeader::shape() const
|
||||
QPainterPath QGIRichAnno::shape() const
|
||||
{
|
||||
return QGraphicsItemGroup::shape();
|
||||
}
|
||||
|
||||
void QGITextLeader::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
void QGIRichAnno::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
// painter->drawRect(boundingRect()); //good for debugging
|
||||
|
||||
QGILeaderLine::paint (painter, &myOption, widget);
|
||||
QGIView::paint (painter, &myOption, widget);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGITextLeader.cpp>
|
||||
#include <Mod/TechDraw/Gui/moc_QGIRichAnno.cpp>
|
||||
@@ -20,8 +20,8 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef DRAWINGGUI_QGRAPHICSITEMTEXTLEADER_H
|
||||
#define DRAWINGGUI_QGRAPHICSITEMTEXTLEADER_H
|
||||
#ifndef TECHDRAWGUI_QGIRICHANNO_H
|
||||
#define TECHDRAWGUI_QGIRICHANNO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QGraphicsView>
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "QGILeaderLine.h"
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawTextLeader;
|
||||
class DrawRichAnno;
|
||||
class DrawLeaderLine;
|
||||
}
|
||||
|
||||
@@ -51,16 +51,16 @@ class QGMText;
|
||||
|
||||
//*******************************************************************
|
||||
|
||||
class TechDrawGuiExport QGITextLeader : public QGILeaderLine
|
||||
class TechDrawGuiExport QGIRichAnno : public QGIView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum {Type = QGraphicsItem::UserType + 233};
|
||||
|
||||
explicit QGITextLeader(QGraphicsItem* myParent = nullptr,
|
||||
TechDraw::DrawTextLeader* lead = nullptr);
|
||||
~QGITextLeader() = default;
|
||||
explicit QGIRichAnno(QGraphicsItem* myParent = nullptr,
|
||||
TechDraw::DrawRichAnno* lead = nullptr);
|
||||
~QGIRichAnno() = default;
|
||||
|
||||
int type() const override { return Type;}
|
||||
virtual void paint( QPainter * painter,
|
||||
@@ -68,16 +68,19 @@ public:
|
||||
QWidget * widget = 0 ) override;
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual QPainterPath shape(void) const override;
|
||||
/* virtual void updateView(bool update = false) override;*/
|
||||
|
||||
virtual void drawBorder() override;
|
||||
virtual void updateView(bool update = false) override;
|
||||
|
||||
void setTextItem(void);
|
||||
|
||||
virtual TechDraw::DrawTextLeader* getFeature(void);
|
||||
virtual TechDraw::DrawRichAnno* getFeature(void);
|
||||
|
||||
public Q_SLOTS:
|
||||
void textDragging(void);
|
||||
void textDragFinished(void);
|
||||
void onTextSelect(bool state);
|
||||
void hover(bool state);
|
||||
void select(bool state);
|
||||
|
||||
protected:
|
||||
virtual void draw() override;
|
||||
@@ -86,8 +89,10 @@ protected:
|
||||
|
||||
protected:
|
||||
QGMText* m_text;
|
||||
bool m_hasHover;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DRAWINGGUI_QGRAPHICSITEMTEXTLEADER_H
|
||||
#endif // TECHDRAWGUI_QGIRICHANNO_H
|
||||
@@ -43,7 +43,7 @@ QGCustomImage: 201
|
||||
QGIMatting: 205
|
||||
QGTracker: 210
|
||||
QGILeaderLine: 232
|
||||
QGITextLeader: 233
|
||||
QGIRichAnno: 233
|
||||
QGMText: 300
|
||||
QGEPath: 301
|
||||
QGMarker: 302
|
||||
|
||||
@@ -226,10 +226,6 @@ void QGIView::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
// Base::Console().Message("QGIV::mousePressEvent() - %s\n",getViewName());
|
||||
signalSelectPoint(this, event->pos());
|
||||
|
||||
if(m_locked) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGMText::QGMText()
|
||||
QGMText::QGMText() :
|
||||
m_showBox(false),
|
||||
m_prettyState("Normal")
|
||||
{
|
||||
setCacheMode(QGCustomText::NoCache);
|
||||
setFlag(ItemSendsGeometryChanges, true);
|
||||
@@ -94,11 +96,30 @@ void QGMText::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
QGCustomText::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
void QGMText::setPrettySel(void)
|
||||
{
|
||||
m_prettyState = "Sel";
|
||||
QGCustomText::setPrettySel();
|
||||
}
|
||||
|
||||
void QGMText::setPrettyPre(void)
|
||||
{
|
||||
m_prettyState = "Pre";
|
||||
QGCustomText::setPrettyPre();
|
||||
}
|
||||
|
||||
void QGMText::setPrettyNormal(void)
|
||||
{
|
||||
m_prettyState = "Normal";
|
||||
QGCustomText::setPrettyNormal();
|
||||
}
|
||||
|
||||
void QGMText::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
// painter->drawRect(boundingRect()); //good for debugging
|
||||
//TODO: this should be changed to a rectItem in the parent
|
||||
if (showBox()) {
|
||||
painter->drawRect(boundingRect().adjusted(1,1,-1,-1));
|
||||
}
|
||||
|
||||
@@ -59,6 +59,10 @@ public:
|
||||
virtual void showBox(bool b) { m_showBox = b; }
|
||||
virtual bool showBox(void) { return m_showBox; }
|
||||
|
||||
virtual void setPrettyNormal() override;
|
||||
virtual void setPrettyPre() override;
|
||||
virtual void setPrettySel() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void dragging();
|
||||
void hover(bool state);
|
||||
@@ -74,6 +78,8 @@ protected:
|
||||
|
||||
private:
|
||||
bool m_showBox;
|
||||
std::string m_prettyState;
|
||||
QPointF m_lastClick;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <QTransform>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
#include <Base/Console.h>
|
||||
@@ -52,7 +54,9 @@ using namespace TechDrawGui;
|
||||
QGTracker::QGTracker(QGraphicsScene* inScene, TrackerMode m):
|
||||
m_width(0),
|
||||
m_sleep(false),
|
||||
m_qgParent(nullptr)
|
||||
m_qgParent(nullptr),
|
||||
m_lastClick(QPointF(FLT_MAX,FLT_MAX)),
|
||||
m_2clickPending(false)
|
||||
{
|
||||
setTrackerMode(m);
|
||||
if (inScene != nullptr) {
|
||||
@@ -76,7 +80,6 @@ QGTracker::QGTracker(QGraphicsScene* inScene, TrackerMode m):
|
||||
double tWeight = getTrackerWeight();
|
||||
setWidth(tWeight);
|
||||
setStyle(Qt::DashLine);
|
||||
// setStyle(Qt::SolidLine);
|
||||
setNormalColor(tailColor);
|
||||
setPrettyNormal();
|
||||
|
||||
@@ -110,32 +113,47 @@ QVariant QGTracker::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
|
||||
void QGTracker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
QPointF myScenePos = event->scenePos();
|
||||
if (!m_sleep) {
|
||||
QPointF scenePos(event->scenePos());
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
scenePos = snapToAngle(scenePos);
|
||||
}
|
||||
onMousePress(scenePos);
|
||||
double someLimit = Rez::guiX(10.0);
|
||||
QPointF manhat = myScenePos - m_lastClick;
|
||||
// Base::Console().Message("QGT::mousePressEvent - scenePos: (%.3f, %.3f) lastClick:(%.3f,%.3f)\n",
|
||||
// myScenePos.x(), myScenePos.y(), m_lastClick.x(),m_lastClick.y());
|
||||
// Base::Console().Message("QGT::mousePressEvent - manhat(%.3f, %.3f) mLength: %.3f\n",
|
||||
// manhat.x(),manhat.y(), manhat.manhattanLength());
|
||||
if (manhat.manhattanLength() < someLimit) {
|
||||
// Base::Console().Message("QGT::mousePressEvent - too close to last click\n");
|
||||
} else {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
myScenePos = snapToAngle(myScenePos);
|
||||
}
|
||||
onMousePress(myScenePos);
|
||||
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
terminateDrawing();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
terminateDrawing();
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lastClick = myScenePos;
|
||||
QGIPrimPath::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void QGTracker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
m_lastClick = event->scenePos();
|
||||
QGIPrimPath::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//TODO: fix this to handle click-release-doubleclick-release nonsense.
|
||||
// can generate two add points
|
||||
void QGTracker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGT::mouseDoubleClickEvent()\n");
|
||||
if (!m_sleep) {
|
||||
onDoubleClick(event->scenePos());
|
||||
}
|
||||
m_lastClick = event->scenePos();
|
||||
QGIPrimPath::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ private:
|
||||
TrackerMode m_trackerMode;
|
||||
QPen m_trackPen;
|
||||
QPen m_tailPen;
|
||||
QPointF m_lastClick;
|
||||
bool m_2clickPending;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawTextLeader.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGIDrawingTemplate.h"
|
||||
@@ -89,7 +89,7 @@
|
||||
#include "QGIViewImage.h"
|
||||
#include "QGIFace.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "QGITextLeader.h"
|
||||
#include "QGIRichAnno.h"
|
||||
|
||||
#include "ZVALUE.h"
|
||||
#include "ViewProviderPage.h"
|
||||
@@ -469,43 +469,63 @@ void QGVPage::addDimToParent(QGIViewDimension* dim, QGIView* parent)
|
||||
dim->setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
|
||||
QGIView * QGVPage::addViewLeader(TechDraw::DrawLeaderLine *leader)
|
||||
{
|
||||
// Base::Console().Message("QGVP::addViewLeader(%s)\n",leader->getNameInDocument());
|
||||
QGILeaderLine* leaderGroup = nullptr;
|
||||
QGITextLeader* textGroup = nullptr;
|
||||
|
||||
App::DocumentObject* parentObj = leader->LeaderParent.getValue();
|
||||
TechDraw::DrawView* parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
|
||||
TechDraw::DrawTextLeader* textFeat = dynamic_cast<TechDraw::DrawTextLeader*>(leader);
|
||||
|
||||
|
||||
//NOTE: if Leaders are ever allowed to not be attached to a View, this next bit will have to change
|
||||
if (parentDV != nullptr) {
|
||||
QGIView* parentQV = findQViewForDocObj(parentObj);
|
||||
if (parentQV != nullptr) {
|
||||
if (textFeat != nullptr) {
|
||||
textGroup = new QGITextLeader(parentQV, textFeat);
|
||||
textGroup->updateView(true);
|
||||
return textGroup;
|
||||
} else {
|
||||
leaderGroup = new QGILeaderLine(parentQV, leader);
|
||||
leaderGroup->updateView(true); //this is different from everybody else,
|
||||
//but it works.
|
||||
return leaderGroup;
|
||||
}
|
||||
} else {
|
||||
throw Base::TypeError("QGVP::addViewLeader - parent DV has no QGIV");
|
||||
leaderGroup = new QGILeaderLine(parentQV, leader);
|
||||
leaderGroup->updateView(true); //this is different from everybody else,
|
||||
//but it works.
|
||||
return leaderGroup;
|
||||
}
|
||||
// } else if (parentDP != nullptr) {
|
||||
// leaderGroup = new QGILeaderLine(nullptr,leader);
|
||||
// ourScene->addItem(leaderGroup);
|
||||
} else {
|
||||
//TARFU
|
||||
throw Base::TypeError("QGVP::addViewLeader - parent obj wrong type");
|
||||
throw Base::TypeError("QGVP::addViewLeader - parent DV has no QGIV");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void QGVPage::addLeaderToParent(QGILeaderLine* lead, QGIView* parent)
|
||||
{
|
||||
assert(lead);
|
||||
assert(parent); //blow up if we don't have Leader or Parent
|
||||
QPointF posRef(0.,0.);
|
||||
QPointF mapPos = lead->mapToItem(parent, posRef);
|
||||
lead->moveBy(-mapPos.x(), -mapPos.y());
|
||||
parent->addToGroup(lead); //vs lead->setParentItem(parent)??
|
||||
lead->setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
QGIView * QGVPage::addRichAnno(TechDraw::DrawRichAnno* anno)
|
||||
{
|
||||
QGIRichAnno* annoGroup = nullptr;
|
||||
TechDraw::DrawView* parentDV = nullptr;
|
||||
|
||||
App::DocumentObject* parentObj = anno->AnnoParent.getValue();
|
||||
if (parentObj != nullptr) {
|
||||
parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
|
||||
}
|
||||
if (parentDV != nullptr) {
|
||||
QGIView* parentQV = findQViewForDocObj(parentObj);
|
||||
annoGroup = new QGIRichAnno(parentQV, anno);
|
||||
annoGroup->updateView(true);
|
||||
} else {
|
||||
annoGroup = new QGIRichAnno(nullptr, anno);
|
||||
if (annoGroup->scene() == nullptr) {
|
||||
scene()->addItem(annoGroup);
|
||||
}
|
||||
annoGroup->updateView(true);
|
||||
}
|
||||
return annoGroup;
|
||||
}
|
||||
|
||||
//! find the graphic for a DocumentObject
|
||||
QGIView * QGVPage::findQViewForDocObj(App::DocumentObject *obj) const
|
||||
{
|
||||
@@ -593,8 +613,23 @@ QGIView * QGVPage::findParent(QGIView *view) const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If type is LeaderLine we check LeaderParent
|
||||
TechDraw::DrawLeaderLine *lead = 0;
|
||||
lead = dynamic_cast<TechDraw::DrawLeaderLine *>(myFeat);
|
||||
|
||||
if(lead) {
|
||||
App::DocumentObject* obj = lead->LeaderParent.getValue();
|
||||
if(obj != nullptr) {
|
||||
std::string parentName = obj->getNameInDocument();
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), parentName.c_str()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Not found a parent
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ class DrawViewCollection;
|
||||
class DrawViewSpreadsheet;
|
||||
class DrawViewImage;
|
||||
class DrawLeaderLine;
|
||||
class DrawViewBalloon;}
|
||||
class DrawViewBalloon;
|
||||
class DrawRichAnno;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
@@ -52,6 +54,7 @@ class QGITemplate;
|
||||
class ViewProviderPage;
|
||||
class QGIViewBalloon;
|
||||
class QGILeaderLine;
|
||||
class QGIRichAnno;
|
||||
|
||||
class TechDrawGuiExport QGVPage : public QGraphicsView
|
||||
{
|
||||
@@ -79,6 +82,7 @@ public:
|
||||
QGIView * addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view);
|
||||
QGIView * addDrawViewImage(TechDraw::DrawViewImage *view);
|
||||
QGIView * addViewLeader(TechDraw::DrawLeaderLine* view);
|
||||
QGIView * addRichAnno(TechDraw::DrawRichAnno* anno);
|
||||
|
||||
QGIView* findQViewForDocObj(App::DocumentObject *obj) const;
|
||||
QGIView* getQGIVByName(std::string name);
|
||||
@@ -86,6 +90,8 @@ public:
|
||||
|
||||
void addBalloonToParent(QGIViewBalloon* balloon, QGIView* parent);
|
||||
void addDimToParent(QGIViewDimension* dim, QGIView* parent);
|
||||
void addLeaderToParent(QGILeaderLine* lead, QGIView* parent);
|
||||
|
||||
// const std::vector<QGIView *> & getViews() const { return views; } //only used in MDIVP
|
||||
std::vector<QGIView *> getViews() const; //only used in MDIVP
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawTextLeader.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskTextLeader.h>
|
||||
#include <Mod/TechDraw/Gui/ui_TaskLeaderLine.h>
|
||||
|
||||
#include "DrawGuiStd.h"
|
||||
#include "QGVPage.h"
|
||||
@@ -58,25 +58,20 @@
|
||||
#include "ViewProviderLeader.h"
|
||||
#include "QGTracker.h"
|
||||
#include "QGEPath.h"
|
||||
#include "QGMText.h"
|
||||
#include "QGITextLeader.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "Rez.h"
|
||||
#include "mrichtextedit.h"
|
||||
#include "mtextedit.h"
|
||||
|
||||
#include "TaskTextLeader.h"
|
||||
#include "TaskLeaderLine.h"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
//ctor for edit
|
||||
TaskTextLeader::TaskTextLeader(int mode,
|
||||
TechDrawGui::ViewProviderLeader* leadVP) :
|
||||
ui(new Ui_TaskTextLeader),
|
||||
TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
|
||||
ui(new Ui_TaskLeaderLine),
|
||||
m_tracker(nullptr),
|
||||
m_lineVP(leadVP),
|
||||
m_textVP(nullptr),
|
||||
m_baseFeat(nullptr),
|
||||
m_basePage(nullptr),
|
||||
m_lineFeat(nullptr),
|
||||
@@ -84,24 +79,16 @@ TaskTextLeader::TaskTextLeader(int mode,
|
||||
m_leadLine(nullptr),
|
||||
m_inProgressLock(false),
|
||||
m_qgLine(nullptr),
|
||||
m_qgText(nullptr),
|
||||
m_textDialog(nullptr),
|
||||
m_rte(nullptr),
|
||||
m_mode(mode),
|
||||
m_pbTrackerState(TRACKEREDIT)
|
||||
{
|
||||
if (m_lineVP == nullptr) {
|
||||
//should be caught in CMD caller
|
||||
Base::Console().Error("TaskTextLeader - bad parameters. Can not proceed.\n");
|
||||
Base::Console().Error("TaskLeaderLine - bad parameters. Can not proceed.\n");
|
||||
return;
|
||||
}
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lineFeat = m_lineVP->getFeature();
|
||||
if (m_mode == TEXTMODE) {
|
||||
m_textFeat = static_cast<DrawTextLeader*>(m_lineFeat);
|
||||
m_textVP = static_cast<ViewProviderTextLeader*>(m_lineVP);
|
||||
}
|
||||
|
||||
App::DocumentObject* obj = m_lineFeat->LeaderParent.getValue();
|
||||
if ( obj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()) ) {
|
||||
@@ -109,10 +96,11 @@ TaskTextLeader::TaskTextLeader(int mode,
|
||||
}
|
||||
m_basePage = m_lineFeat->findParentPage();
|
||||
|
||||
//TODO: when/if leaders are allowed to be parented to Page, check for m_baseFeat will be removed
|
||||
if ( (m_lineFeat == nullptr) ||
|
||||
(m_baseFeat == nullptr) ||
|
||||
(m_basePage == nullptr) ) {
|
||||
Base::Console().Error("TaskTextLeader - bad parameters (2). Can not proceed.\n");
|
||||
Base::Console().Error("TaskLeaderLine - bad parameters (2). Can not proceed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,19 +116,14 @@ TaskTextLeader::TaskTextLeader(int mode,
|
||||
|
||||
connect(ui->pbTracker, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onTrackerClicked(bool)));
|
||||
if (m_mode == TEXTMODE) {
|
||||
connect(ui->pbEditor, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onEditorClicked(bool)));
|
||||
}
|
||||
|
||||
m_trackerMode = QGTracker::TrackerMode::Line;
|
||||
}
|
||||
|
||||
//ctor for creation
|
||||
TaskTextLeader::TaskTextLeader(int mode,
|
||||
TechDraw::DrawView* baseFeat,
|
||||
TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page) :
|
||||
ui(new Ui_TaskTextLeader),
|
||||
ui(new Ui_TaskLeaderLine),
|
||||
m_tracker(nullptr),
|
||||
m_lineVP(nullptr),
|
||||
m_baseFeat(baseFeat),
|
||||
@@ -150,16 +133,12 @@ TaskTextLeader::TaskTextLeader(int mode,
|
||||
m_leadLine(nullptr),
|
||||
m_inProgressLock(false),
|
||||
m_qgLine(nullptr),
|
||||
m_qgText(nullptr),
|
||||
m_textDialog(nullptr),
|
||||
m_rte(nullptr),
|
||||
m_mode(mode),
|
||||
m_pbTrackerState(TRACKERPICK)
|
||||
{
|
||||
if ( (m_basePage == nullptr) ||
|
||||
(m_baseFeat == nullptr) ) {
|
||||
//should be caught in CMD caller
|
||||
Base::Console().Error("TaskTextLeader - bad parameters. Can not proceed.\n");
|
||||
Base::Console().Error("TaskLeaderLine - bad parameters. Can not proceed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,44 +155,34 @@ TaskTextLeader::TaskTextLeader(int mode,
|
||||
|
||||
connect(ui->pbTracker, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onTrackerClicked(bool)));
|
||||
if (mode == TEXTMODE) {
|
||||
connect(ui->pbEditor, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onEditorClicked(bool)));
|
||||
}
|
||||
|
||||
m_trackerMode = QGTracker::TrackerMode::Line;
|
||||
}
|
||||
|
||||
TaskTextLeader::~TaskTextLeader()
|
||||
TaskLeaderLine::~TaskLeaderLine()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskTextLeader::updateTask()
|
||||
void TaskLeaderLine::updateTask()
|
||||
{
|
||||
// blockUpdate = true;
|
||||
|
||||
// blockUpdate = false;
|
||||
}
|
||||
|
||||
void TaskTextLeader::changeEvent(QEvent *e)
|
||||
void TaskLeaderLine::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTextLeader::setUiPrimary()
|
||||
void TaskLeaderLine::setUiPrimary()
|
||||
{
|
||||
// Base::Console().Message("TTL::setUiPrimary() - m_mode: %d\n",m_mode);
|
||||
// Base::Console().Message("TTL::setUiPrimary()\n");
|
||||
enableVPUi(false);
|
||||
if (m_mode == TEXTMODE) {
|
||||
setWindowTitle(QObject::tr("New Text Leader"));
|
||||
enableTextUi(true);
|
||||
} else {
|
||||
setWindowTitle(QObject::tr("New Leader Line"));
|
||||
enableTextUi(false);
|
||||
}
|
||||
setWindowTitle(QObject::tr("New Leader Line"));
|
||||
|
||||
if (m_baseFeat != nullptr) {
|
||||
std::string baseName = m_baseFeat->getNameInDocument();
|
||||
@@ -225,31 +194,19 @@ void TaskTextLeader::setUiPrimary()
|
||||
ui->cboxStartSym->setCurrentIndex(aSize);
|
||||
}
|
||||
|
||||
void TaskTextLeader::enableTextUi(bool b)
|
||||
{
|
||||
ui->pbEditor->setEnabled(b);
|
||||
ui->teLeaderText->setEnabled(b);
|
||||
}
|
||||
|
||||
void TaskTextLeader::enableVPUi(bool b)
|
||||
void TaskLeaderLine::enableVPUi(bool b)
|
||||
{
|
||||
ui->cpLineColor->setEnabled(b);
|
||||
ui->dsbWeight->setEnabled(b);
|
||||
ui->cboxStyle->setEnabled(b);
|
||||
}
|
||||
|
||||
void TaskTextLeader::setUiEdit()
|
||||
void TaskLeaderLine::setUiEdit()
|
||||
{
|
||||
// Base::Console().Message("TTL::setUiEdit() - m_mode: %d\n",m_mode);
|
||||
// Base::Console().Message("TTL::setUiEdit()\n");
|
||||
enableVPUi(true);
|
||||
if (m_mode == TEXTMODE) {
|
||||
setWindowTitle(QObject::tr("Edit Text Leader"));
|
||||
enableTextUi(true);
|
||||
} else {
|
||||
setWindowTitle(QObject::tr("Edit Leader Line"));
|
||||
enableTextUi(false);
|
||||
}
|
||||
|
||||
setWindowTitle(QObject::tr("Edit Leader Line"));
|
||||
|
||||
if (m_lineFeat != nullptr) {
|
||||
std::string baseName = m_lineFeat->LeaderParent.getValue()->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
@@ -258,67 +215,21 @@ void TaskTextLeader::setUiEdit()
|
||||
ui->pbTracker->setText(QString::fromUtf8("Edit points"));
|
||||
ui->pbTracker->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
if (m_lineVP != nullptr) {
|
||||
ui->cpLineColor->setColor(m_lineVP->Color.getValue().asValue<QColor>());
|
||||
ui->dsbWeight->setValue(m_lineVP->LineWidth.getValue());
|
||||
ui->cboxStyle->setCurrentIndex(m_lineVP->LineStyle.getValue());
|
||||
}
|
||||
|
||||
if (m_textFeat != nullptr) {
|
||||
ui->teLeaderText->setHtml(QString::fromUtf8(m_textFeat->LeaderText.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTextLeader::onEditorClicked(bool b)
|
||||
{
|
||||
// Base::Console().Message("TL::onEditorClicked(%d)\n",b);
|
||||
Q_UNUSED(b);
|
||||
m_textDialog = new QDialog(0);
|
||||
QString leadText = ui->teLeaderText->toHtml();
|
||||
m_rte = new MRichTextEdit(m_textDialog, leadText);
|
||||
//m_rte->setTextWidth(m_lineVP->MaxWidth);
|
||||
QGridLayout* gl = new QGridLayout(m_textDialog);
|
||||
gl->addWidget(m_rte,0,0,1,1);
|
||||
m_textDialog->setWindowTitle(QObject::tr("Leader text editor"));
|
||||
m_textDialog->setMinimumWidth (400);
|
||||
m_textDialog->setMinimumHeight(400);
|
||||
|
||||
connect(m_rte, SIGNAL(saveText(QString)),
|
||||
this, SLOT(onSaveAndExit(QString)));
|
||||
connect(m_rte, SIGNAL(editorFinished(void)),
|
||||
this, SLOT(onEditorExit(void)));
|
||||
|
||||
m_textDialog->show();
|
||||
}
|
||||
|
||||
void TaskTextLeader::onSaveAndExit(QString qs)
|
||||
{
|
||||
ui->teLeaderText->setHtml(qs);
|
||||
//dialog clean up should be handled by accept() call in dialog
|
||||
m_textDialog->accept();
|
||||
m_textDialog = nullptr;
|
||||
m_rte = nullptr;
|
||||
}
|
||||
|
||||
void TaskTextLeader::onEditorExit(void)
|
||||
{
|
||||
m_textDialog->reject();
|
||||
m_textDialog = nullptr;
|
||||
m_rte = nullptr;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void TaskTextLeader::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
{
|
||||
Base::Console().Message("TTL::createLeaderFeature() - m_mode: %d\n",m_mode);
|
||||
if (m_mode == TEXTMODE) {
|
||||
m_leaderName = m_basePage->getDocument()->getUniqueObjectName("DrawTextLeader");
|
||||
m_leaderType = "TechDraw::DrawTextLeader";
|
||||
} else {
|
||||
m_leaderName = m_basePage->getDocument()->getUniqueObjectName("DrawLeaderLine");
|
||||
m_leaderType = "TechDraw::DrawLeaderLine";
|
||||
}
|
||||
// Base::Console().Message("TTL::createLeaderFeature()\n");
|
||||
m_leaderName = m_basePage->getDocument()->getUniqueObjectName("DrawLeaderLine");
|
||||
m_leaderType = "TechDraw::DrawLeaderLine";
|
||||
|
||||
std::string PageName = m_basePage->getNameInDocument();
|
||||
|
||||
@@ -332,18 +243,10 @@ void TaskTextLeader::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
|
||||
App::DocumentObject* obj = m_basePage->getDocument()->getObject(m_leaderName.c_str());
|
||||
if (obj == nullptr) {
|
||||
throw Base::RuntimeError("TaskTextLeader - new markup object not found");
|
||||
throw Base::RuntimeError("TaskLeaderLine - new markup object not found");
|
||||
}
|
||||
if (obj->isDerivedFrom(TechDraw::DrawTextLeader::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
m_lineFeat = static_cast<TechDraw::DrawLeaderLine*>(obj);
|
||||
m_textFeat = static_cast<TechDraw::DrawTextLeader*>(obj);
|
||||
commonFeatureUpdate(converted);
|
||||
QPointF qTemp = calcTextStartPos(m_lineFeat->getScale());
|
||||
Base::Vector3d vTemp(qTemp.x(), qTemp.y());
|
||||
m_textFeat->TextPosition.setValue(Rez::appX(vTemp));
|
||||
} else if (obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
m_lineFeat = static_cast<TechDraw::DrawLeaderLine*>(obj);
|
||||
m_textFeat = nullptr;
|
||||
commonFeatureUpdate(converted);
|
||||
}
|
||||
|
||||
@@ -352,9 +255,9 @@ void TaskTextLeader::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
m_lineFeat->requestPaint();
|
||||
}
|
||||
|
||||
void TaskTextLeader::updateLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
void TaskLeaderLine::updateLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
{
|
||||
// Base::Console().Message("TTL::updateLeaderFeature(%d) - m_mode: %d\n",converted.size(),m_mode);
|
||||
// Base::Console().Message("TTL::updateLeaderFeature(%d)\n",converted.size());
|
||||
Gui::Command::openCommand("Edit Leader");
|
||||
commonFeatureUpdate(converted);
|
||||
App::Color ac;
|
||||
@@ -367,29 +270,28 @@ void TaskTextLeader::updateLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
m_lineFeat->requestPaint();
|
||||
}
|
||||
|
||||
void TaskTextLeader::commonFeatureUpdate(std::vector<Base::Vector3d> converted)
|
||||
void TaskLeaderLine::commonFeatureUpdate(std::vector<Base::Vector3d> converted)
|
||||
{
|
||||
// Base::Console().Message("TTL::commonFeatureUpdate()\n");
|
||||
m_lineFeat->setPosition(Rez::appX(m_attachPoint.x),Rez::appX(- m_attachPoint.y), true);
|
||||
if (!converted.empty()) {
|
||||
m_lineFeat->WayPoints.setValues(converted);
|
||||
if (m_lineFeat->AutoHorizontal.getValue()) {
|
||||
m_lineFeat->adjustLastSegment();
|
||||
}
|
||||
}
|
||||
int start = ui->cboxStartSym->currentIndex() - 1;
|
||||
int end = ui->cboxEndSym->currentIndex() - 1;
|
||||
m_lineFeat->StartSymbol.setValue(start);
|
||||
m_lineFeat->EndSymbol.setValue(end);
|
||||
if (m_mode == TEXTMODE) {
|
||||
m_textFeat->LeaderText.setValue(ui->teLeaderText->toHtml().toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTextLeader::removeFeature(void)
|
||||
void TaskLeaderLine::removeFeature(void)
|
||||
{
|
||||
// Base::Console().Message("TTL::removeFeature()\n");
|
||||
if (m_lineFeat != nullptr) {
|
||||
if (m_createMode) {
|
||||
try {
|
||||
// this doesn't remove the QGMText item??
|
||||
std::string PageName = m_basePage->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)",
|
||||
PageName.c_str(),m_lineFeat->getNameInDocument());
|
||||
@@ -405,62 +307,18 @@ void TaskTextLeader::removeFeature(void)
|
||||
std::vector<std::string> undos = Gui::Application::Instance->activeDocument()->getUndoVector();
|
||||
Gui::Application::Instance->activeDocument()->undo(1);
|
||||
} else {
|
||||
Base::Console().Log("TaskTextLeader: Edit mode - NO command is active\n");
|
||||
Base::Console().Log("TaskLeaderLine: Edit mode - NO command is active\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we don't know the bounding rect of the text, so we have to calculate a reasonable
|
||||
//guess at the size of the text block.
|
||||
QPointF TaskTextLeader::calcTextStartPos(double scale)
|
||||
{
|
||||
// Base::Console().Message("TTL::calcTextStartPos(%.3f) - m_mode: %d\n", scale, m_mode);
|
||||
double textWidth = 100.0;
|
||||
double textHeight = 20.0;
|
||||
double horizGap(20.0);
|
||||
double tPosX(0.0);
|
||||
double tPosY(0.0);
|
||||
|
||||
Gui::ViewProvider* vp = QGIView::getViewProvider(m_textFeat);
|
||||
if (vp != nullptr) {
|
||||
ViewProviderTextLeader* vpl = dynamic_cast<ViewProviderTextLeader*>(vp);
|
||||
if (vpl != nullptr) {
|
||||
double adjust = 2.0;
|
||||
double fsize = vpl->Fontsize.getValue();
|
||||
textHeight = fsize * adjust;
|
||||
double width = vpl->MaxWidth.getValue();
|
||||
if (width > 0 ) {
|
||||
textWidth = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_trackerPoints.empty() ) {
|
||||
QPointF lastPoint(m_trackerPoints.back().x, m_trackerPoints.back().y);
|
||||
QPointF firstPoint(m_trackerPoints.front().x, m_trackerPoints.front().y);
|
||||
QPointF lastOffset = lastPoint;
|
||||
lastPoint = m_qgParent->mapFromScene(lastPoint) * scale;
|
||||
firstPoint = m_qgParent->mapFromScene(firstPoint) * scale;
|
||||
|
||||
if (lastPoint.x() < firstPoint.x()) { //last is left of first
|
||||
tPosX = lastOffset.x() - horizGap - textWidth; //left of last
|
||||
tPosY = lastOffset.y() - textHeight;
|
||||
} else { //last is right of first
|
||||
tPosX = lastOffset.x() + horizGap; //right of last
|
||||
tPosY = lastOffset.y() - textHeight;
|
||||
}
|
||||
}
|
||||
QPointF result(tPosX, -tPosY);
|
||||
return result;
|
||||
}
|
||||
|
||||
//********** Tracker routines *******************************************************************
|
||||
void TaskTextLeader::onTrackerClicked(bool b)
|
||||
void TaskLeaderLine::onTrackerClicked(bool b)
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
// Base::Console().Message("TTL::onTrackerClicked() - m_mode: %d, m_pbTrackerState: %d\n",
|
||||
// m_mode, m_pbTrackerState);
|
||||
// Base::Console().Message("TTL::onTrackerClicked() m_pbTrackerState: %d\n",
|
||||
// m_pbTrackerState);
|
||||
if (m_pbTrackerState == TRACKERCANCEL) {
|
||||
removeTracker();
|
||||
|
||||
@@ -486,6 +344,7 @@ void TaskTextLeader::onTrackerClicked(bool b)
|
||||
m_saveContextPolicy = m_mdi->contextMenuPolicy();
|
||||
m_mdi->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
m_trackerMode = QGTracker::TrackerMode::Line;
|
||||
setEditCursor(Qt::CrossCursor);
|
||||
startTracker();
|
||||
|
||||
QString msg = tr("Pick a starting point for leader line");
|
||||
@@ -507,7 +366,7 @@ void TaskTextLeader::onTrackerClicked(bool b)
|
||||
|
||||
if (qgLead == nullptr) {
|
||||
//tarfu
|
||||
Base::Console().Error("TaskTextLeader - can't find leader graphic\n");
|
||||
Base::Console().Error("TaskLeaderLine - can't find leader graphic\n");
|
||||
//now what? throw will generate "unknown unhandled exception"
|
||||
} else {
|
||||
m_qgLine = qgLead;
|
||||
@@ -535,6 +394,7 @@ void TaskTextLeader::onTrackerClicked(bool b)
|
||||
m_saveContextPolicy = m_mdi->contextMenuPolicy();
|
||||
m_mdi->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
m_trackerMode = QGTracker::TrackerMode::Line;
|
||||
setEditCursor(Qt::CrossCursor);
|
||||
startTracker();
|
||||
|
||||
QString msg = tr("Pick a starting point for leader line");
|
||||
@@ -548,7 +408,7 @@ void TaskTextLeader::onTrackerClicked(bool b)
|
||||
} //end edit mode
|
||||
}
|
||||
|
||||
void TaskTextLeader::startTracker(void)
|
||||
void TaskLeaderLine::startTracker(void)
|
||||
{
|
||||
// Base::Console().Message("TTL::startTracker()\n");
|
||||
if (m_trackerMode == QGTracker::TrackerMode::None) {
|
||||
@@ -571,11 +431,11 @@ void TaskTextLeader::startTracker(void)
|
||||
Gui::getMainWindow()->showMessage(msg,3000);
|
||||
}
|
||||
|
||||
void TaskTextLeader::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent)
|
||||
void TaskLeaderLine::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent)
|
||||
{
|
||||
// Base::Console().Message("TTL::onTrackerFinished()\n");
|
||||
if (pts.empty()) {
|
||||
Base::Console().Error("TaskTextLeader - no points available\n");
|
||||
Base::Console().Error("TaskLeaderLine - no points available\n");
|
||||
return;
|
||||
}
|
||||
QGIView* qgiv = dynamic_cast<QGIView*>(qgParent);
|
||||
@@ -601,7 +461,7 @@ void TaskTextLeader::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgPare
|
||||
setEditCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void TaskTextLeader::removeTracker(void)
|
||||
void TaskLeaderLine::removeTracker(void)
|
||||
{
|
||||
// Base::Console().Message("TTL::removeTracker()\n");
|
||||
if ( (m_tracker != nullptr) &&
|
||||
@@ -612,7 +472,7 @@ void TaskTextLeader::removeTracker(void)
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTextLeader::setEditCursor(QCursor c)
|
||||
void TaskLeaderLine::setEditCursor(QCursor c)
|
||||
{
|
||||
if (m_baseFeat != nullptr) {
|
||||
QGIView* qgivBase = m_view->findQViewForDocObj(m_baseFeat);
|
||||
@@ -621,7 +481,7 @@ void TaskTextLeader::setEditCursor(QCursor c)
|
||||
}
|
||||
|
||||
//from 1:1 scale scene QPointF to zero origin Vector3d points
|
||||
void TaskTextLeader::convertTrackerPoints(std::vector<QPointF> pts)
|
||||
void TaskLeaderLine::convertTrackerPoints(std::vector<QPointF> pts)
|
||||
{
|
||||
// Base::Console().Message("TTL::convertTrackerPoints(%d)\n", pts.size());
|
||||
m_trackerPoints.clear();
|
||||
@@ -633,7 +493,7 @@ void TaskTextLeader::convertTrackerPoints(std::vector<QPointF> pts)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void TaskTextLeader::onPointEditComplete(std::vector<QPointF> pts, QGIView* parent)
|
||||
void TaskLeaderLine::onPointEditComplete(std::vector<QPointF> pts, QGIView* parent)
|
||||
{
|
||||
// Base::Console().Message("TTL::onPointEditComplete(%d)\n", pts.size());
|
||||
if (pts.empty()) {
|
||||
@@ -667,7 +527,7 @@ void TaskTextLeader::onPointEditComplete(std::vector<QPointF> pts, QGIView* pare
|
||||
enableTaskButtons(true);
|
||||
}
|
||||
|
||||
void TaskTextLeader::abandonEditSession(void)
|
||||
void TaskLeaderLine::abandonEditSession(void)
|
||||
{
|
||||
if (m_qgLine != nullptr) {
|
||||
m_qgLine->abandonEdit();
|
||||
@@ -684,20 +544,20 @@ void TaskTextLeader::abandonEditSession(void)
|
||||
setEditCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void TaskTextLeader::saveButtons(QPushButton* btnOK,
|
||||
void TaskLeaderLine::saveButtons(QPushButton* btnOK,
|
||||
QPushButton* btnCancel)
|
||||
{
|
||||
m_btnOK = btnOK;
|
||||
m_btnCancel = btnCancel;
|
||||
}
|
||||
|
||||
void TaskTextLeader::enableTaskButtons(bool b)
|
||||
void TaskLeaderLine::enableTaskButtons(bool b)
|
||||
{
|
||||
m_btnOK->setEnabled(b);
|
||||
m_btnCancel->setEnabled(b);
|
||||
}
|
||||
|
||||
int TaskTextLeader::getPrefArrowStyle()
|
||||
int TaskLeaderLine::getPrefArrowStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
@@ -705,12 +565,11 @@ int TaskTextLeader::getPrefArrowStyle()
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
bool TaskTextLeader::accept()
|
||||
bool TaskLeaderLine::accept()
|
||||
{
|
||||
// Base::Console().Message("TTL::accept() - m_mode: %d\n", m_mode);
|
||||
// Base::Console().Message("TTL::accept()\n");
|
||||
if (m_inProgressLock) {
|
||||
// Base::Console().Message("TTL::accept - edit in progress!!\n");
|
||||
abandonEditSession();
|
||||
@@ -733,7 +592,7 @@ bool TaskTextLeader::accept()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskTextLeader::reject()
|
||||
bool TaskLeaderLine::reject()
|
||||
{
|
||||
if (m_inProgressLock) {
|
||||
// Base::Console().Message("TTL::reject - edit in progress!!\n");
|
||||
@@ -745,7 +604,9 @@ bool TaskTextLeader::reject()
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
if (!doc) return false;
|
||||
|
||||
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
if (m_mdi != nullptr) {
|
||||
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
}
|
||||
if (getCreateMode() &&
|
||||
(m_lineFeat != nullptr) ) {
|
||||
removeFeature();
|
||||
@@ -760,49 +621,37 @@ bool TaskTextLeader::reject()
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TaskDlgTextLeader::TaskDlgTextLeader(int mode,
|
||||
TechDraw::DrawView* baseFeat,
|
||||
TaskDlgLeaderLine::TaskDlgLeaderLine(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskTextLeader(mode,baseFeat,page);
|
||||
if (mode == TEXTMODE) {
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-textleader"),
|
||||
widget->windowTitle(), true, 0);
|
||||
} else { //if (mode == 1)
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-mline"),
|
||||
widget = new TaskLeaderLine(baseFeat,page);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-mline"),
|
||||
widget->windowTitle(), true, 0);
|
||||
}
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgTextLeader::TaskDlgTextLeader(int mode,
|
||||
TechDrawGui::ViewProviderLeader* leadVP)
|
||||
TaskDlgLeaderLine::TaskDlgLeaderLine(TechDrawGui::ViewProviderLeader* leadVP)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskTextLeader(mode,leadVP);
|
||||
if (mode == TEXTMODE) {
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-textleader"),
|
||||
widget = new TaskLeaderLine(leadVP);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-mline"),
|
||||
widget->windowTitle(), true, 0);
|
||||
} else { //if (mode == 1)
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-mline"),
|
||||
widget->windowTitle(), true, 0);
|
||||
}
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgTextLeader::~TaskDlgTextLeader()
|
||||
TaskDlgLeaderLine::~TaskDlgLeaderLine()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgTextLeader::update()
|
||||
void TaskDlgLeaderLine::update()
|
||||
{
|
||||
// widget->updateTask();
|
||||
}
|
||||
|
||||
void TaskDlgTextLeader::modifyStandardButtons(QDialogButtonBox* box)
|
||||
void TaskDlgLeaderLine::modifyStandardButtons(QDialogButtonBox* box)
|
||||
{
|
||||
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
|
||||
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
|
||||
@@ -810,24 +659,24 @@ void TaskDlgTextLeader::modifyStandardButtons(QDialogButtonBox* box)
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgTextLeader::open()
|
||||
void TaskDlgLeaderLine::open()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgTextLeader::clicked(int)
|
||||
void TaskDlgLeaderLine::clicked(int)
|
||||
{
|
||||
}
|
||||
|
||||
bool TaskDlgTextLeader::accept()
|
||||
bool TaskDlgLeaderLine::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgTextLeader::reject()
|
||||
bool TaskDlgLeaderLine::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_TaskTextLeader.cpp>
|
||||
#include <Mod/TechDraw/Gui/moc_TaskLeaderLine.cpp>
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskTextLeader.h>
|
||||
#include <Mod/TechDraw/Gui/ui_TaskLeaderLine.h>
|
||||
|
||||
#include "QGTracker.h"
|
||||
|
||||
@@ -38,9 +38,7 @@
|
||||
#define TRACKERCANCEL 2
|
||||
#define TRACKERCANCELEDIT 3
|
||||
|
||||
class MRichTextEdit;
|
||||
|
||||
class Ui_TaskTextLeader;
|
||||
class Ui_TaskLeaderLine;
|
||||
|
||||
namespace App {
|
||||
class DocumentObject;
|
||||
@@ -50,12 +48,9 @@ namespace TechDraw
|
||||
{
|
||||
class DrawPage;
|
||||
class DrawView;
|
||||
class DrawTextLeader;
|
||||
class DrawLeaderLine;
|
||||
}
|
||||
|
||||
#define TEXTMODE 0
|
||||
#define LINEMODE 1
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGVPage;
|
||||
@@ -65,26 +60,23 @@ class MDIViewPage;
|
||||
class QGTracker;
|
||||
class QGEPath;
|
||||
class QGMText;
|
||||
class QGITextLeader;
|
||||
class QGILeaderLine;
|
||||
class ViewProviderLeader;
|
||||
class ViewProviderTextLeader;
|
||||
|
||||
class TaskTextLeader : public QWidget
|
||||
class TaskLeaderLine : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskTextLeader(int mode,
|
||||
TechDraw::DrawView* baseFeat,
|
||||
TaskLeaderLine(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page);
|
||||
TaskTextLeader(int mode,
|
||||
TechDrawGui::ViewProviderLeader* leadVP);
|
||||
~TaskTextLeader();
|
||||
TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP);
|
||||
~TaskLeaderLine();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onTrackerClicked(bool b);
|
||||
void onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent);
|
||||
void onEditorClicked(bool b);
|
||||
/* void onEditorClicked(bool b);*/
|
||||
/* void onViewPicked(QPointF pos, QGIView* qgParent);*/
|
||||
|
||||
public:
|
||||
@@ -101,8 +93,8 @@ public:
|
||||
protected Q_SLOTS:
|
||||
void convertTrackerPoints(std::vector<QPointF> pts);
|
||||
void onPointEditComplete(std::vector<QPointF> pts, QGIView* parent);
|
||||
void onSaveAndExit(QString);
|
||||
void onEditorExit(void);
|
||||
/* void onSaveAndExit(QString);*/
|
||||
/* void onEditorExit(void);*/
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
@@ -115,7 +107,7 @@ protected:
|
||||
void commonFeatureUpdate(std::vector<Base::Vector3d> converted);
|
||||
void removeFeature(void);
|
||||
|
||||
QPointF calcTextStartPos(double scale);
|
||||
/* QPointF calcTextStartPos(double scale);*/
|
||||
|
||||
void blockButtons(bool b);
|
||||
void setUiPrimary(void);
|
||||
@@ -128,7 +120,7 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
Ui_TaskTextLeader * ui;
|
||||
Ui_TaskLeaderLine * ui;
|
||||
bool blockUpdate;
|
||||
|
||||
QGTracker* m_tracker;
|
||||
@@ -137,10 +129,8 @@ private:
|
||||
QGraphicsScene* m_scene;
|
||||
QGVPage* m_view;
|
||||
ViewProviderLeader* m_lineVP;
|
||||
ViewProviderTextLeader* m_textVP;
|
||||
TechDraw::DrawView* m_baseFeat;
|
||||
TechDraw::DrawPage* m_basePage;
|
||||
TechDraw::DrawTextLeader* m_textFeat;
|
||||
TechDraw::DrawLeaderLine* m_lineFeat;
|
||||
std::string m_leaderName;
|
||||
std::string m_leaderType;
|
||||
@@ -152,34 +142,27 @@ private:
|
||||
|
||||
bool m_createMode;
|
||||
QGEPath* m_leadLine;
|
||||
QGMText* m_text;
|
||||
|
||||
QGTracker::TrackerMode m_trackerMode;
|
||||
Qt::ContextMenuPolicy m_saveContextPolicy;
|
||||
bool m_inProgressLock;
|
||||
|
||||
QGILeaderLine* m_qgLine;
|
||||
QGITextLeader* m_qgText;
|
||||
QPushButton* m_btnOK;
|
||||
QPushButton* m_btnCancel;
|
||||
|
||||
QDialog* m_textDialog;
|
||||
MRichTextEdit* m_rte;
|
||||
int m_mode;
|
||||
int m_pbTrackerState;
|
||||
};
|
||||
|
||||
class TaskDlgTextLeader : public Gui::TaskView::TaskDialog
|
||||
class TaskDlgLeaderLine : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgTextLeader(int mode,
|
||||
TechDraw::DrawView* baseFeat,
|
||||
TaskDlgLeaderLine(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page);
|
||||
TaskDlgTextLeader(int mode,
|
||||
TechDrawGui::ViewProviderLeader* leadVP);
|
||||
~TaskDlgTextLeader();
|
||||
TaskDlgLeaderLine(TechDrawGui::ViewProviderLeader* leadVP);
|
||||
~TaskDlgLeaderLine();
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
@@ -201,7 +184,7 @@ public:
|
||||
protected:
|
||||
|
||||
private:
|
||||
TaskTextLeader * widget;
|
||||
TaskLeaderLine * widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::TaskTextLeader</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskTextLeader">
|
||||
<class>TechDrawGui::TaskLeaderLine</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskLeaderLine">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>409</width>
|
||||
<height>560</height>
|
||||
<height>405</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -23,11 +23,11 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Text Leader</string>
|
||||
<string>Leader Line</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="Resources/TechDraw.qrc">
|
||||
<normaloff>:/icons/actions/techdraw-textleader.svg</normaloff>:/icons/actions/techdraw-textleader.svg</iconset>
|
||||
<normaloff>:/icons/actions/techdraw-mline.svg</normaloff>:/icons/actions/techdraw-mline.svg</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
@@ -132,6 +132,9 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cboxStartSym">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>No Symbol</string>
|
||||
@@ -326,41 +329,23 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Leader Text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbEditor">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Editor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="teLeaderText"/>
|
||||
</item>
|
||||
</layout>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
560
src/Mod/TechDraw/Gui/TaskRichAnno.cpp
Normal file
560
src/Mod/TechDraw/Gui/TaskRichAnno.cpp
Normal file
@@ -0,0 +1,560 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wandererfan <wandererfan@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <cmath>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <QStatusBar>
|
||||
#include <QGraphicsScene>
|
||||
#include <QDialog>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskRichAnno.h>
|
||||
|
||||
#include "DrawGuiStd.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGIPrimPath.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "ViewProviderRichAnno.h"
|
||||
#include "QGMText.h"
|
||||
#include "QGIRichAnno.h"
|
||||
#include "Rez.h"
|
||||
#include "mrichtextedit.h"
|
||||
#include "mtextedit.h"
|
||||
|
||||
#include "TaskRichAnno.h"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
//ctor for edit
|
||||
TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
|
||||
ui(new Ui_TaskRichAnno),
|
||||
m_annoVP(annoVP),
|
||||
m_baseFeat(nullptr),
|
||||
m_basePage(nullptr),
|
||||
m_annoFeat(nullptr),
|
||||
m_createMode(false),
|
||||
m_inProgressLock(false),
|
||||
m_qgAnno(nullptr),
|
||||
m_textDialog(nullptr),
|
||||
m_rte(nullptr)
|
||||
{
|
||||
if (m_annoVP == nullptr) {
|
||||
//should be caught in CMD caller
|
||||
Base::Console().Error("TaskRichAnno - bad parameters. Can not proceed.\n");
|
||||
return;
|
||||
}
|
||||
ui->setupUi(this);
|
||||
|
||||
m_annoFeat = m_annoVP->getFeature();
|
||||
|
||||
//m_baseFeat can be null
|
||||
App::DocumentObject* obj = m_annoFeat->AnnoParent.getValue();
|
||||
if (obj != nullptr) {
|
||||
if ( obj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()) ) {
|
||||
m_baseFeat = static_cast<TechDraw::DrawView*>(m_annoFeat->AnnoParent.getValue());
|
||||
}
|
||||
}
|
||||
m_basePage = m_annoFeat->findParentPage();
|
||||
if ( m_basePage == nullptr ) {
|
||||
Base::Console().Error("TaskRichAnno - bad parameters (2). Can not proceed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
setUiEdit();
|
||||
// m_title = QObject::tr("Rich text editor");
|
||||
|
||||
m_mdi = m_annoVP->getMDIViewPage();
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_view = m_mdi->getQGVPage();
|
||||
if (m_baseFeat != nullptr) {
|
||||
m_qgParent = m_view->findQViewForDocObj(m_baseFeat);
|
||||
}
|
||||
|
||||
m_saveContextPolicy = m_mdi->contextMenuPolicy();
|
||||
|
||||
m_attachPoint = Rez::guiX(Base::Vector3d(m_annoFeat->X.getValue(),
|
||||
-m_annoFeat->Y.getValue(),
|
||||
0.0));
|
||||
|
||||
connect(ui->pbEditor, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onEditorClicked(bool)));
|
||||
}
|
||||
|
||||
//ctor for creation
|
||||
TaskRichAnno::TaskRichAnno(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page) :
|
||||
ui(new Ui_TaskRichAnno),
|
||||
m_annoVP(nullptr),
|
||||
m_baseFeat(baseFeat),
|
||||
m_basePage(page),
|
||||
m_annoFeat(nullptr),
|
||||
m_createMode(true),
|
||||
m_inProgressLock(false),
|
||||
m_qgAnno(nullptr),
|
||||
m_textDialog(nullptr),
|
||||
m_rte(nullptr)
|
||||
{
|
||||
if (m_basePage == nullptr) {
|
||||
//should be caught in CMD caller
|
||||
Base::Console().Error("TaskRichAnno - bad parameters. Can not proceed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ui->setupUi(this);
|
||||
m_title = QObject::tr("Rich text creator");
|
||||
|
||||
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
|
||||
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_view = m_mdi->getQGVPage();
|
||||
if (baseFeat != nullptr) {
|
||||
m_qgParent = m_view->findQViewForDocObj(baseFeat);
|
||||
}
|
||||
|
||||
m_saveContextPolicy = m_mdi->contextMenuPolicy();
|
||||
|
||||
setUiPrimary();
|
||||
|
||||
connect(ui->pbEditor, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onEditorClicked(bool)));
|
||||
}
|
||||
|
||||
TaskRichAnno::~TaskRichAnno()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskRichAnno::updateTask()
|
||||
{
|
||||
// blockUpdate = true;
|
||||
|
||||
// blockUpdate = false;
|
||||
}
|
||||
|
||||
void TaskRichAnno::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskRichAnno::setUiPrimary()
|
||||
{
|
||||
// Base::Console().Message("TRA::setUiPrimary()\n");
|
||||
enableVPUi(false);
|
||||
setWindowTitle(m_title);
|
||||
|
||||
if (m_baseFeat != nullptr) {
|
||||
std::string baseName = m_baseFeat->getNameInDocument();
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskRichAnno::enableTextUi(bool b)
|
||||
{
|
||||
ui->pbEditor->setEnabled(b);
|
||||
ui->teAnnoText->setEnabled(b);
|
||||
}
|
||||
|
||||
void TaskRichAnno::enableVPUi(bool b)
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
// ui->cpLineColor->setEnabled(b);
|
||||
// ui->dsbWeight->setEnabled(b);
|
||||
// ui->cboxStyle->setEnabled(b);
|
||||
}
|
||||
|
||||
void TaskRichAnno::setUiEdit()
|
||||
{
|
||||
// Base::Console().Message("TRA::setUiEdit());
|
||||
enableVPUi(true);
|
||||
setWindowTitle(m_title);
|
||||
enableTextUi(true);
|
||||
|
||||
if (m_annoFeat != nullptr) {
|
||||
std::string baseName("None");
|
||||
App::DocumentObject* docObj = m_annoFeat->AnnoParent.getValue();
|
||||
if (docObj != nullptr) {
|
||||
baseName = docObj->getNameInDocument();
|
||||
}
|
||||
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
|
||||
ui->teAnnoText->setHtml(QString::fromUtf8(m_annoFeat->AnnoText.getValue()));
|
||||
ui->dsbMaxWidth->setValue(m_annoFeat->MaxWidth.getValue());
|
||||
ui->cbShowFrame->setChecked(m_annoFeat->ShowFrame.getValue());
|
||||
}
|
||||
|
||||
if (m_annoVP != nullptr) {
|
||||
// ui->cpLineColor->setColor(m_annoVP->Color.getValue().asValue<QColor>());
|
||||
// ui->dsbWeight->setValue(m_annoVP->LineWidth.getValue());
|
||||
// ui->cboxStyle->setCurrentIndex(m_annoVP->LineStyle.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskRichAnno::onEditorClicked(bool b)
|
||||
{
|
||||
// Base::Console().Message("TL::onEditorClicked(%d)\n",b);
|
||||
Q_UNUSED(b);
|
||||
m_textDialog = new QDialog(0);
|
||||
QString leadText = ui->teAnnoText->toHtml();
|
||||
m_rte = new MRichTextEdit(m_textDialog, leadText);
|
||||
//m_rte->setTextWidth(m_annoVP->MaxWidth);
|
||||
QGridLayout* gl = new QGridLayout(m_textDialog);
|
||||
gl->addWidget(m_rte,0,0,1,1);
|
||||
m_textDialog->setWindowTitle(QObject::tr("Rich text editor"));
|
||||
m_textDialog->setMinimumWidth (400);
|
||||
m_textDialog->setMinimumHeight(400);
|
||||
|
||||
connect(m_rte, SIGNAL(saveText(QString)),
|
||||
this, SLOT(onSaveAndExit(QString)));
|
||||
connect(m_rte, SIGNAL(editorFinished(void)),
|
||||
this, SLOT(onEditorExit(void)));
|
||||
|
||||
// m_textDialog->setFont(m_annoVP->Font.getValue());
|
||||
// m_textDialog->setFontSize(m_annoVP->FontSize.getValue());
|
||||
m_textDialog->show();
|
||||
}
|
||||
|
||||
void TaskRichAnno::onSaveAndExit(QString qs)
|
||||
{
|
||||
ui->teAnnoText->setHtml(qs);
|
||||
//dialog clean up should be handled by accept() call in dialog
|
||||
m_textDialog->accept();
|
||||
m_textDialog = nullptr;
|
||||
m_rte = nullptr;
|
||||
}
|
||||
|
||||
void TaskRichAnno::onEditorExit(void)
|
||||
{
|
||||
m_textDialog->reject();
|
||||
m_textDialog = nullptr;
|
||||
m_rte = nullptr;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void TaskRichAnno::createAnnoFeature()
|
||||
{
|
||||
// Base::Console().Message("TRA::createAnnoFeature()");
|
||||
std::string annoName = m_basePage->getDocument()->getUniqueObjectName("DrawRichAnno");
|
||||
std::string annoType = "TechDraw::DrawRichAnno";
|
||||
|
||||
std::string PageName = m_basePage->getNameInDocument();
|
||||
|
||||
Gui::Command::openCommand("Create Leader");
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
|
||||
annoType.c_str(),annoName.c_str());
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
|
||||
PageName.c_str(),annoName.c_str());
|
||||
|
||||
if (m_baseFeat != nullptr) {
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.AnnoParent = App.activeDocument().%s",
|
||||
annoName.c_str(),m_baseFeat->getNameInDocument());
|
||||
}
|
||||
App::DocumentObject* obj = m_basePage->getDocument()->getObject(annoName.c_str());
|
||||
if (obj == nullptr) {
|
||||
throw Base::RuntimeError("TaskRichAnno - new RichAnno object not found");
|
||||
}
|
||||
if (obj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
|
||||
m_annoFeat = static_cast<TechDraw::DrawRichAnno*>(obj);
|
||||
commonFeatureUpdate();
|
||||
QPointF qTemp = calcTextStartPos(m_annoFeat->getScale());
|
||||
Base::Vector3d vTemp(qTemp.x(), qTemp.y());
|
||||
// m_annoFeat->TextPosition.setValue(Rez::appX(vTemp));
|
||||
m_annoFeat->X.setValue(Rez::appX(vTemp.x));
|
||||
m_annoFeat->Y.setValue(Rez::appX(vTemp.y));
|
||||
}
|
||||
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
m_annoFeat->requestPaint();
|
||||
}
|
||||
|
||||
void TaskRichAnno::updateAnnoFeature()
|
||||
{
|
||||
// Base::Console().Message("TRA::updateAnnoFeature()\n");
|
||||
Gui::Command::openCommand("Edit Leader");
|
||||
commonFeatureUpdate();
|
||||
// App::Color ac;
|
||||
// ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
// m_annoVP->Color.setValue(ac);
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
m_annoFeat->requestPaint();
|
||||
}
|
||||
|
||||
void TaskRichAnno::commonFeatureUpdate(void)
|
||||
{
|
||||
// Base::Console().Message("TRA::commonFeatureUpdate()\n");
|
||||
m_annoFeat->setPosition(Rez::appX(m_attachPoint.x),Rez::appX(- m_attachPoint.y), true);
|
||||
m_annoFeat->AnnoText.setValue(ui->teAnnoText->toHtml().toUtf8());
|
||||
m_annoFeat->MaxWidth.setValue(ui->dsbMaxWidth->value());
|
||||
m_annoFeat->ShowFrame.setValue(ui->cbShowFrame->isChecked());
|
||||
}
|
||||
|
||||
void TaskRichAnno::removeFeature(void)
|
||||
{
|
||||
// Base::Console().Message("TRA::removeFeature()\n");
|
||||
if (m_annoFeat != nullptr) {
|
||||
if (m_createMode) {
|
||||
try {
|
||||
// this doesn't remove the QGMText item??
|
||||
std::string PageName = m_basePage->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)",
|
||||
PageName.c_str(),m_annoFeat->getNameInDocument());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",
|
||||
m_annoFeat->getNameInDocument());
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Warning("TRA::removeFeature - failed to delete feature\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Gui::Command::hasPendingCommand()) {
|
||||
std::vector<std::string> undos = Gui::Application::Instance->activeDocument()->getUndoVector();
|
||||
Gui::Application::Instance->activeDocument()->undo(1);
|
||||
} else {
|
||||
Base::Console().Log("TaskRichAnno: Edit mode - NO command is active\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we don't know the bounding rect of the text, so we have to calculate a reasonable
|
||||
//guess at the size of the text block.
|
||||
QPointF TaskRichAnno::calcTextStartPos(double scale)
|
||||
{
|
||||
// Base::Console().Message("TRA::calcTextStartPos(%.3f)\n", scale);
|
||||
double textWidth = 100.0;
|
||||
double textHeight = 20.0;
|
||||
double horizGap(20.0);
|
||||
double tPosX(0.0);
|
||||
double tPosY(0.0);
|
||||
|
||||
Gui::ViewProvider* vp = QGIView::getViewProvider(m_annoFeat);
|
||||
|
||||
if (vp != nullptr) {
|
||||
ViewProviderRichAnno* vpra = dynamic_cast<ViewProviderRichAnno*>(vp);
|
||||
if (vpra != nullptr) {
|
||||
double adjust = 2.0;
|
||||
double fsize = vpra->Fontsize.getValue();
|
||||
textHeight = fsize * adjust;
|
||||
double width = m_annoFeat->MaxWidth.getValue();
|
||||
if (width > 0 ) {
|
||||
textWidth = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> points;
|
||||
if (m_baseFeat != nullptr) {
|
||||
if (m_baseFeat->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
TechDraw::DrawLeaderLine* dll = dynamic_cast<TechDraw::DrawLeaderLine*>(m_baseFeat);
|
||||
points = dll->WayPoints.getValues();
|
||||
} else {
|
||||
Base::Console().Log("TRA::calcTextPos - m_baseFeat is not Leader\n");
|
||||
QPointF result(0.0,0.0);
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
if (m_basePage != nullptr) {
|
||||
double w = Rez::guiX(m_basePage->getPageWidth() / 2.0);
|
||||
double h = Rez::guiX(m_basePage->getPageHeight() / 2.0);
|
||||
QPointF result(w,h);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!points.empty()) {
|
||||
QPointF lastPoint(points.back().x, points.back().y);
|
||||
QPointF firstPoint(points.front().x, points.front().y);
|
||||
QPointF lastOffset = lastPoint;
|
||||
lastPoint = m_qgParent->mapFromScene(lastPoint) * scale;
|
||||
firstPoint = m_qgParent->mapFromScene(firstPoint) * scale;
|
||||
|
||||
if (lastPoint.x() < firstPoint.x()) { //last is left of first
|
||||
tPosX = lastOffset.x() - horizGap - textWidth; //left of last
|
||||
tPosY = lastOffset.y() - textHeight;
|
||||
} else { //last is right of first
|
||||
tPosX = lastOffset.x() + horizGap; //right of last
|
||||
tPosY = lastOffset.y() - textHeight;
|
||||
}
|
||||
}
|
||||
QPointF result(tPosX, -tPosY);
|
||||
return result;
|
||||
}
|
||||
|
||||
void TaskRichAnno::saveButtons(QPushButton* btnOK,
|
||||
QPushButton* btnCancel)
|
||||
{
|
||||
m_btnOK = btnOK;
|
||||
m_btnCancel = btnCancel;
|
||||
}
|
||||
|
||||
void TaskRichAnno::enableTaskButtons(bool b)
|
||||
{
|
||||
m_btnOK->setEnabled(b);
|
||||
m_btnCancel->setEnabled(b);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
bool TaskRichAnno::accept()
|
||||
{
|
||||
// Base::Console().Message("TRA::accept()\n");
|
||||
if (m_inProgressLock) {
|
||||
// Base::Console().Message("TRA::accept - edit in progress!!\n");
|
||||
//TODO: kill MRTE dialog?
|
||||
return true;
|
||||
}
|
||||
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
if (!doc) return false;
|
||||
|
||||
if (!getCreateMode()) {
|
||||
updateAnnoFeature();
|
||||
} else {
|
||||
createAnnoFeature();
|
||||
}
|
||||
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskRichAnno::reject()
|
||||
{
|
||||
Base::Console().Message("TRA::reject()\n");
|
||||
if (m_inProgressLock) {
|
||||
// Base::Console().Message("TRA::reject - edit in progress!!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_basePage != nullptr) {
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
|
||||
if (!doc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Base::Console().Message("TRA::reject() - m_mdi: %X\n", m_mdi);
|
||||
if (m_mdi != nullptr) {
|
||||
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
|
||||
}
|
||||
if (getCreateMode() &&
|
||||
(m_annoFeat != nullptr) ) {
|
||||
removeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
//make sure any dangling objects are cleaned up
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TaskDlgRichAnno::TaskDlgRichAnno(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskRichAnno(baseFeat,page);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-textleader"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgRichAnno::TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskRichAnno(leadVP);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-textleader"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgRichAnno::~TaskDlgRichAnno()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgRichAnno::update()
|
||||
{
|
||||
// widget->updateTask();
|
||||
}
|
||||
|
||||
void TaskDlgRichAnno::modifyStandardButtons(QDialogButtonBox* box)
|
||||
{
|
||||
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
|
||||
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
|
||||
widget->saveButtons(btnOK, btnCancel);
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgRichAnno::open()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgRichAnno::clicked(int)
|
||||
{
|
||||
}
|
||||
|
||||
bool TaskDlgRichAnno::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgRichAnno::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_TaskRichAnno.cpp>
|
||||
170
src/Mod/TechDraw/Gui/TaskRichAnno.h
Normal file
170
src/Mod/TechDraw/Gui/TaskRichAnno.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TECHDRAWGUI_TASKRICHANNO_H
|
||||
#define TECHDRAWGUI_TASKRICHANNO_H
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskRichAnno.h>
|
||||
|
||||
class MRichTextEdit;
|
||||
|
||||
class Ui_TaskRichAnno;
|
||||
|
||||
namespace App {
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawPage;
|
||||
class DrawView;
|
||||
class DrawRichAnno;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
class MDIViewPage;
|
||||
class QGMText;
|
||||
class QGIRichAnno;
|
||||
class ViewProviderRichAnno;
|
||||
|
||||
class TaskRichAnno : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskRichAnno(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page);
|
||||
TaskRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP);
|
||||
~TaskRichAnno();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onEditorClicked(bool b);
|
||||
/* void onViewPicked(QPointF pos, QGIView* qgParent);*/
|
||||
|
||||
public:
|
||||
virtual bool accept();
|
||||
virtual bool reject();
|
||||
virtual void setCreateMode(bool b) { m_createMode = b; }
|
||||
virtual bool getCreateMode(void) { return m_createMode; }
|
||||
void updateTask();
|
||||
void saveButtons(QPushButton* btnOK,
|
||||
QPushButton* btnCancel);
|
||||
void enableTaskButtons(bool b);
|
||||
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onSaveAndExit(QString);
|
||||
void onEditorExit(void);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
void createAnnoFeature(void);
|
||||
void updateAnnoFeature(void);
|
||||
void commonFeatureUpdate(void);
|
||||
void removeFeature(void);
|
||||
|
||||
QPointF calcTextStartPos(double scale);
|
||||
|
||||
void blockButtons(bool b);
|
||||
void setUiPrimary(void);
|
||||
void setUiEdit(void);
|
||||
void enableTextUi(bool b);
|
||||
void enableVPUi(bool b);
|
||||
|
||||
private:
|
||||
Ui_TaskRichAnno * ui;
|
||||
bool blockUpdate;
|
||||
|
||||
MDIViewPage* m_mdi;
|
||||
QGraphicsScene* m_scene;
|
||||
QGVPage* m_view;
|
||||
ViewProviderRichAnno* m_annoVP;
|
||||
TechDraw::DrawView* m_baseFeat;
|
||||
TechDraw::DrawPage* m_basePage;
|
||||
TechDraw::DrawRichAnno* m_annoFeat;
|
||||
QGIView* m_qgParent;
|
||||
std::string m_qgParentName;
|
||||
|
||||
Base::Vector3d m_attachPoint;
|
||||
|
||||
bool m_createMode;
|
||||
QGMText* m_text;
|
||||
|
||||
Qt::ContextMenuPolicy m_saveContextPolicy;
|
||||
bool m_inProgressLock;
|
||||
|
||||
QGIRichAnno* m_qgAnno;
|
||||
QPushButton* m_btnOK;
|
||||
QPushButton* m_btnCancel;
|
||||
|
||||
QDialog* m_textDialog;
|
||||
MRichTextEdit* m_rte;
|
||||
QString m_title;
|
||||
};
|
||||
|
||||
class TaskDlgRichAnno : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgRichAnno(TechDraw::DrawView* baseFeat,
|
||||
TechDraw::DrawPage* page);
|
||||
TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP);
|
||||
~TaskDlgRichAnno();
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
/// is called by the framework if the user presses the help button
|
||||
virtual void helpRequested() { return;}
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
void update();
|
||||
|
||||
void modifyStandardButtons(QDialogButtonBox* box);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
TaskRichAnno * widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace TechDrawGui
|
||||
|
||||
#endif // #ifndef TECHDRAWGUI_TASKRICHANNO_H
|
||||
156
src/Mod/TechDraw/Gui/TaskRichAnno.ui
Normal file
156
src/Mod/TechDraw/Gui/TaskRichAnno.ui
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::TaskRichAnno</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskRichAnno">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>409</width>
|
||||
<height>386</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Rich Text Annotation Block</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="Resources/TechDraw.qrc">
|
||||
<normaloff>:/icons/actions/techdraw-textleader.svg</normaloff>:/icons/actions/techdraw-textleader.svg</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0" columnstretch="3,1,3">
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="2">
|
||||
<widget class="QDoubleSpinBox" name="dsbMaxWidth">
|
||||
<property name="minimum">
|
||||
<double>-1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Max Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Base Feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="leBaseView">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="cbShowFrame">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Show Frame</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbEditor">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Rich Text Editor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="teAnnoText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="Resources/TechDraw.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -61,6 +61,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderDrawingView, Gui::ViewProviderDocumentO
|
||||
|
||||
ViewProviderDrawingView::ViewProviderDrawingView()
|
||||
{
|
||||
// Base::Console().Message("VPDV::VPDV\n");
|
||||
sPixmap = "TechDraw_Tree_View";
|
||||
static const char *group = "Base";
|
||||
|
||||
@@ -78,6 +79,7 @@ ViewProviderDrawingView::~ViewProviderDrawingView()
|
||||
|
||||
void ViewProviderDrawingView::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
// Base::Console().Message("VPDV::attach(%s)\n", pcFeat->getNameInDocument());
|
||||
ViewProviderDocumentObject::attach(pcFeat);
|
||||
|
||||
auto bnd = boost::bind(&ViewProviderDrawingView::onGuiRepaint, this, _1);
|
||||
@@ -238,7 +240,6 @@ MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
|
||||
|
||||
void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
|
||||
{
|
||||
// Base::Console().Message("VPDV::onGuiRepaint(%s)\n",dv->getNameInDocument());
|
||||
if (dv == getViewObject()) {
|
||||
if (!dv->isRemoving() &&
|
||||
!dv->isRestoring()) {
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
|
||||
#include <Mod/TechDraw/App/LineGroup.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawTextLeader.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "TaskTextLeader.h"
|
||||
#include "TaskLeaderLine.h"
|
||||
#include "ViewProviderLeader.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -92,7 +92,7 @@ bool ViewProviderLeader::setEdit(int ModNum)
|
||||
}
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Control().showDialog(new TaskDlgTextLeader(LINEMODE, this));
|
||||
Gui::Control().showDialog(new TaskDlgLeaderLine(this));
|
||||
return true;
|
||||
} else {
|
||||
return ViewProviderDrawingView::setEdit(ModNum);
|
||||
@@ -134,7 +134,27 @@ void ViewProviderLeader::onChanged(const App::Property* p)
|
||||
}
|
||||
}
|
||||
ViewProviderDrawingView::onChanged(p);
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderLeader::claimChildren(void) const
|
||||
{
|
||||
// Collect any child Document Objects and put them in the right place in the Feature tree
|
||||
// valid children of a ViewLeader are:
|
||||
// - Rich Annotations
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
const std::vector<App::DocumentObject *> &views = getFeature()->getInList();
|
||||
try {
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
catch (...) {
|
||||
std::vector<App::DocumentObject*> tmp;
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::DrawLeaderLine* ViewProviderLeader::getViewObject() const
|
||||
@@ -168,109 +188,4 @@ App::Color ViewProviderLeader::getDefLineColor(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderTextLeader, TechDrawGui::ViewProviderLeader)
|
||||
|
||||
ViewProviderTextLeader::ViewProviderTextLeader()
|
||||
{
|
||||
sPixmap = "actions/techdraw-textleader";
|
||||
|
||||
static const char *group = "Text Format";
|
||||
|
||||
ADD_PROPERTY_TYPE(Font ,(getDefFont().c_str()),group,App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(getDefFontSize()) ,group,(App::PropertyType)(App::Prop_None),
|
||||
"Text size in internal units");
|
||||
ADD_PROPERTY_TYPE(MaxWidth,(-1) ,group,(App::PropertyType)(App::Prop_None),
|
||||
"Maximum width of text in mm");
|
||||
ADD_PROPERTY_TYPE(ShowFrame,(true) ,group,(App::PropertyType)(App::Prop_None),
|
||||
"Draw a box around text or not");
|
||||
}
|
||||
|
||||
ViewProviderTextLeader::~ViewProviderTextLeader()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderTextLeader::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
ViewProviderLeader::attach(pcFeat);
|
||||
}
|
||||
|
||||
bool ViewProviderTextLeader::setEdit(int ModNum)
|
||||
{
|
||||
// Base::Console().Message("VPTL::setEdit(%d)\n",ModNum);
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
if (Gui::Control().activeDialog()) { //TaskPanel already open!
|
||||
return false;
|
||||
}
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Control().showDialog(new TaskDlgTextLeader(TEXTMODE, this));
|
||||
return true;
|
||||
} else {
|
||||
return ViewProviderLeader::setEdit(ModNum);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderTextLeader::unsetEdit(int ModNum)
|
||||
{
|
||||
Q_UNUSED(ModNum);
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
ViewProviderLeader::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderTextLeader::doubleClicked(void)
|
||||
{
|
||||
// Base::Console().Message("VPTL::doubleClicked()\n");
|
||||
setEdit(ViewProvider::Default);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderTextLeader::updateData(const App::Property* p)
|
||||
{
|
||||
ViewProviderLeader::updateData(p);
|
||||
}
|
||||
|
||||
void ViewProviderTextLeader::onChanged(const App::Property* p)
|
||||
{
|
||||
if ((p == &Font) ||
|
||||
(p == &Fontsize) ||
|
||||
(p == &MaxWidth) ||
|
||||
(p == &ShowFrame)) {
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
}
|
||||
ViewProviderLeader::onChanged(p);
|
||||
|
||||
}
|
||||
|
||||
TechDraw::DrawTextLeader* ViewProviderTextLeader::getFeature() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawTextLeader*>(pcObject);
|
||||
}
|
||||
|
||||
std::string ViewProviderTextLeader::getDefFont(void) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Labels");
|
||||
std::string result = hGrp->GetASCII("LabelFont", "osifont");
|
||||
return result;
|
||||
}
|
||||
|
||||
double ViewProviderTextLeader::getDefFontSize(void) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
double result = hGrp->GetFloat("FontSize", 6.0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "ViewProviderDrawingView.h"
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawTextLeader;
|
||||
class DrawRichAnno;
|
||||
class DrawLeaderLine;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
std::vector<App::DocumentObject*> claimChildren(void) const;
|
||||
|
||||
virtual TechDraw::DrawLeaderLine* getViewObject() const;
|
||||
TechDraw::DrawLeaderLine* getFeature() const;
|
||||
|
||||
@@ -70,37 +72,6 @@ protected:
|
||||
App::Color getDefLineColor(void);
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
class TechDrawGuiExport ViewProviderTextLeader : public ViewProviderLeader
|
||||
{
|
||||
PROPERTY_HEADER(TechDrawGui::ViewProviderTextLeader);
|
||||
|
||||
public:
|
||||
ViewProviderTextLeader();
|
||||
virtual ~ViewProviderTextLeader();
|
||||
|
||||
App::PropertyFont Font;
|
||||
App::PropertyLength Fontsize;
|
||||
App::PropertyFloat MaxWidth;
|
||||
App::PropertyBool ShowFrame;
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual void onChanged(const App::Property* p);
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
/* virtual TechDraw::DrawTextLeader* getViewObject() const;*/
|
||||
TechDraw::DrawTextLeader* getFeature() const;
|
||||
|
||||
protected:
|
||||
std::string getDefFont(void) const;
|
||||
double getDefFontSize(void) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
@@ -272,12 +273,22 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
TechDraw::DrawView* featView = dynamic_cast<TechDraw::DrawView*> (*it);
|
||||
App::DocumentObject *docObj = *it;
|
||||
//DrawRichAnno with no parent is child of Page
|
||||
TechDraw::DrawRichAnno* dra = dynamic_cast<TechDraw::DrawRichAnno*> (*it);
|
||||
if (dra != nullptr) {
|
||||
if (dra->AnnoParent.getValue() == nullptr) {
|
||||
temp.push_back(*it);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't collect if dimension, projection group item, hatch or member of ClipGroup as these should be grouped elsewhere
|
||||
if(docObj->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) ||
|
||||
(featView && featView->isInClip()) )
|
||||
continue;
|
||||
else
|
||||
|
||||
174
src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp
Normal file
174
src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Sequencer.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "TaskRichAnno.h"
|
||||
#include "ViewProviderRichAnno.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderRichAnno, TechDrawGui::ViewProviderDrawingView)
|
||||
|
||||
//**************************************************************************
|
||||
// Construction/Destruction
|
||||
|
||||
ViewProviderRichAnno::ViewProviderRichAnno()
|
||||
{
|
||||
sPixmap = "actions/techdraw-textleader";
|
||||
|
||||
static const char *group = "Text Format";
|
||||
|
||||
ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"The color of the Markup");
|
||||
ADD_PROPERTY_TYPE(Font ,(getDefFont().c_str()),group,App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(getDefFontSize()) ,group,(App::PropertyType)(App::Prop_None),
|
||||
"Text size in internal units");
|
||||
Color.setStatus(App::Property::ReadOnly,true);
|
||||
Font.setStatus(App::Property::ReadOnly,true);
|
||||
Fontsize.setStatus(App::Property::ReadOnly,true);
|
||||
}
|
||||
|
||||
ViewProviderRichAnno::~ViewProviderRichAnno()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderRichAnno::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
ViewProviderDrawingView::attach(pcFeat);
|
||||
}
|
||||
|
||||
bool ViewProviderRichAnno::setEdit(int ModNum)
|
||||
{
|
||||
// Base::Console().Message("VPRA::setEdit(%d)\n",ModNum);
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
if (Gui::Control().activeDialog()) { //TaskPanel already open!
|
||||
return false;
|
||||
}
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Control().showDialog(new TaskDlgRichAnno(this));
|
||||
return true;
|
||||
} else {
|
||||
return ViewProviderDrawingView::setEdit(ModNum);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderRichAnno::unsetEdit(int ModNum)
|
||||
{
|
||||
Q_UNUSED(ModNum);
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
ViewProviderDrawingView::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderRichAnno::doubleClicked(void)
|
||||
{
|
||||
// Base::Console().Message("VPRA::doubleClicked()\n");
|
||||
setEdit(ViewProvider::Default);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderRichAnno::updateData(const App::Property* p)
|
||||
{
|
||||
ViewProviderDrawingView::updateData(p);
|
||||
}
|
||||
|
||||
void ViewProviderRichAnno::onChanged(const App::Property* p)
|
||||
{
|
||||
// if ((p == &Font) ||
|
||||
// (p == &Fontsize) ||
|
||||
// (p == &Color)) {
|
||||
// QGIView* qgiv = getQView();
|
||||
// if (qgiv) {
|
||||
// qgiv->updateView(true);
|
||||
// }
|
||||
// }
|
||||
ViewProviderDrawingView::onChanged(p);
|
||||
}
|
||||
|
||||
TechDraw::DrawRichAnno* ViewProviderRichAnno::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawRichAnno*>(pcObject);
|
||||
}
|
||||
|
||||
TechDraw::DrawRichAnno* ViewProviderRichAnno::getFeature() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawRichAnno*>(pcObject);
|
||||
}
|
||||
|
||||
App::Color ViewProviderRichAnno::getDefLineColor(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Markups");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string ViewProviderRichAnno::getDefFont(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
return fontName;
|
||||
}
|
||||
|
||||
double ViewProviderRichAnno::getDefFontSize()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
double fontSize = hGrp->GetFloat("FontSize", 5.0);
|
||||
return fontSize;
|
||||
}
|
||||
78
src/Mod/TechDraw/Gui/ViewProviderRichAnno.h
Normal file
78
src/Mod/TechDraw/Gui/ViewProviderRichAnno.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TECHDRAWGUI_VIEWPROVIDERRICHANNO_H
|
||||
#define TECHDRAWGUI_VIEWPROVIDERRICHANNO_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
|
||||
#include "ViewProviderDrawingView.h"
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawRichAnno;
|
||||
}
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class TechDrawGuiExport ViewProviderRichAnno : public ViewProviderDrawingView
|
||||
{
|
||||
PROPERTY_HEADER(TechDrawGui::ViewProviderRichAnno);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderRichAnno();
|
||||
/// destructor
|
||||
virtual ~ViewProviderRichAnno();
|
||||
|
||||
App::PropertyFont Font;
|
||||
App::PropertyLength Fontsize;
|
||||
App::PropertyColor Color;
|
||||
App::PropertyFloat MaxWidth;
|
||||
App::PropertyBool ShowFrame;
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
/* virtual void setDisplayMode(const char* ModeName);*/
|
||||
virtual bool useNewSelectionModel(void) const {return false;}
|
||||
/* virtual std::vector<std::string> getDisplayModes(void) const;*/
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual void onChanged(const App::Property* p);
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
virtual TechDraw::DrawRichAnno* getViewObject() const;
|
||||
TechDraw::DrawRichAnno* getFeature() const;
|
||||
|
||||
protected:
|
||||
App::Color getDefLineColor(void);
|
||||
std::string getDefFont(void);
|
||||
double getDefFontSize(void);
|
||||
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
#endif // TECHDRAWGUI_VIEWPROVIDERRICHANNO_H
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawViewMulti.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawGeomHatch.h>
|
||||
@@ -164,6 +165,7 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren(void) cons
|
||||
// - Leaders
|
||||
// - Hatches
|
||||
// - GeomHatches
|
||||
// - Leaders
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
const std::vector<App::DocumentObject *> &views = getViewPart()->getInList();
|
||||
try {
|
||||
@@ -188,6 +190,8 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren(void) cons
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
*draw << "TechDraw_ToggleFrame";
|
||||
// *decor << "TechDraw_RedrawPage";
|
||||
*draw << "TechDraw_LeaderLine";
|
||||
*draw << "TechDraw_TextLeader";
|
||||
*draw << "TechDraw_RichAnno";
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
*decor << "TechDraw_ToggleFrame";
|
||||
// *decor << "TechDraw_RedrawPage";
|
||||
*decor << "TechDraw_LeaderLine";
|
||||
*decor << "TechDraw_TextLeader";
|
||||
*decor << "TechDraw_RichAnno";
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
*decor << "TechDraw_ToggleFrame";
|
||||
// *decor << "TechDraw_RedrawPage";
|
||||
*decor << "TechDraw_LeaderLine";
|
||||
*decor << "TechDraw_TextLeader";
|
||||
*decor << "TechDraw_RichAnno";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ MRichTextEdit::MRichTextEdit(QWidget *parent, QString textIn) : QWidget(parent)
|
||||
connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool)));
|
||||
connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool)));
|
||||
|
||||
// f_textedit->setLineWrapMode(QTextEdit::FixedColumnWidth);
|
||||
// f_textedit->setLineWrapColumnOrWidth(????));
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged()));
|
||||
#endif
|
||||
|
||||
@@ -40,6 +40,7 @@ class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit {
|
||||
QTextDocument *document() { return f_textedit->document(); }
|
||||
QTextCursor textCursor() const { return f_textedit->textCursor(); }
|
||||
void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); }
|
||||
void setMaxWidth(double w);
|
||||
|
||||
public slots:
|
||||
void setText(const QString &text);
|
||||
|
||||
Reference in New Issue
Block a user