Basic working ViewImage
This commit is contained in:
parent
4f511f663a
commit
5bfdad804a
|
@ -35,6 +35,7 @@
|
|||
#include "DrawViewArch.h"
|
||||
#include "DrawViewSpreadsheet.h"
|
||||
#include "DrawViewMulti.h"
|
||||
#include "DrawViewImage.h"
|
||||
|
||||
namespace TechDraw {
|
||||
extern PyObject* initModule();
|
||||
|
@ -81,6 +82,7 @@ PyMODINIT_FUNC initTechDraw()
|
|||
TechDraw::DrawHatch ::init();
|
||||
TechDraw::DrawViewDraft ::init();
|
||||
TechDraw::DrawViewArch ::init();
|
||||
TechDraw::DrawViewImage ::init();
|
||||
|
||||
// Python Types
|
||||
TechDraw::DrawViewPython ::init();
|
||||
|
|
|
@ -80,7 +80,9 @@ SET(Draw_SRCS
|
|||
DrawViewArch.cpp
|
||||
DrawViewArch.h
|
||||
DrawViewMulti.cpp
|
||||
DrawViewMulti.h)
|
||||
DrawViewMulti.h
|
||||
DrawViewImage.cpp
|
||||
DrawViewImage.h)
|
||||
|
||||
SET(TechDraw_SRCS
|
||||
AppTechDraw.cpp
|
||||
|
|
98
src/Mod/TechDraw/App/DrawViewImage.cpp
Normal file
98
src/Mod/TechDraw/App/DrawViewImage.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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 <sstream>
|
||||
#endif
|
||||
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include "DrawViewImage.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// DrawViewImage
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawViewImage, TechDraw::DrawView)
|
||||
|
||||
|
||||
DrawViewImage::DrawViewImage(void)
|
||||
{
|
||||
static const char *vgroup = "Image";
|
||||
|
||||
ADD_PROPERTY_TYPE(ImageFile,(""),vgroup,App::Prop_None,"The file containing this bitmap");
|
||||
ADD_PROPERTY_TYPE(Width ,(100),vgroup,App::Prop_None,"The width of the image view");
|
||||
ADD_PROPERTY_TYPE(Height ,(100),vgroup,App::Prop_None,"The height of the view");
|
||||
ScaleType.setValue("Custom");
|
||||
}
|
||||
|
||||
DrawViewImage::~DrawViewImage()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawViewImage::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &ImageFile) {
|
||||
if (!isRestoring()) {
|
||||
}
|
||||
}
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewImage::execute(void)
|
||||
{
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
QRectF DrawViewImage::getRect() const
|
||||
{
|
||||
QRectF result(0.0,0.0,Width.getValue(),Height.getValue());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawViewImagePython, TechDraw::DrawViewImage)
|
||||
template<> const char* TechDraw::DrawViewImagePython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderImage";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawViewImage>;
|
||||
}
|
74
src/Mod/TechDraw/App/DrawViewImage.h
Normal file
74
src/Mod/TechDraw/App/DrawViewImage.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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 _DrawViewImage_h_
|
||||
#define _DrawViewImage_h_
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include <App/PropertyFile.h>
|
||||
#include "DrawView.h"
|
||||
#include <App/FeaturePython.h>
|
||||
|
||||
#include <Base/BoundBox.h>
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
|
||||
class TechDrawExport DrawViewImage : public TechDraw::DrawView
|
||||
{
|
||||
PROPERTY_HEADER(TechDraw::DrawViewImage);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
DrawViewImage(void);
|
||||
virtual ~DrawViewImage();
|
||||
|
||||
App::PropertyFile ImageFile;
|
||||
App::PropertyFloat Width;
|
||||
App::PropertyFloat Height;
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
//@}
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderImage";
|
||||
}
|
||||
virtual QRectF getRect() const;
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
Base::BoundBox3d bbox;
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<DrawViewImage> DrawViewImagePython;
|
||||
|
||||
|
||||
} //namespace TechDraw
|
||||
|
||||
|
||||
#endif
|
|
@ -48,6 +48,8 @@
|
|||
#include "ViewProviderViewClip.h"
|
||||
#include "ViewProviderHatch.h"
|
||||
#include "ViewProviderSpreadsheet.h"
|
||||
#include "ViewProviderImage.h"
|
||||
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreateTechDrawCommands(void);
|
||||
|
@ -100,6 +102,7 @@ void TechDrawGuiExport initTechDrawGui()
|
|||
TechDrawGui::ViewProviderArch::init();
|
||||
TechDrawGui::ViewProviderHatch::init();
|
||||
TechDrawGui::ViewProviderSpreadsheet::init();
|
||||
TechDrawGui::ViewProviderImage::init();
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawImp> ("TechDraw");
|
||||
|
|
|
@ -103,6 +103,8 @@ SET(TechDrawGuiView_SRCS
|
|||
QGCustomLabel.h
|
||||
QGCustomBorder.cpp
|
||||
QGCustomBorder.h
|
||||
QGCustomImage.cpp
|
||||
QGCustomImage.h
|
||||
QGIView.cpp
|
||||
QGIView.h
|
||||
QGIArrow.cpp
|
||||
|
@ -135,6 +137,8 @@ SET(TechDrawGuiView_SRCS
|
|||
QGIViewSymbol.h
|
||||
QGIViewSpreadsheet.cpp
|
||||
QGIViewSpreadsheet.h
|
||||
QGIViewImage.cpp
|
||||
QGIViewImage.h
|
||||
QGIViewClip.cpp
|
||||
QGIViewClip.h
|
||||
QGIPrimPath.cpp
|
||||
|
@ -180,6 +184,8 @@ SET(TechDrawGuiViewProvider_SRCS
|
|||
ViewProviderViewClip.h
|
||||
ViewProviderHatch.cpp
|
||||
ViewProviderHatch.h
|
||||
ViewProviderImage.cpp
|
||||
ViewProviderImage.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Mod" FILES ${TechDrawGui_SRCS})
|
||||
|
|
|
@ -126,6 +126,58 @@ bool CmdTechDrawNewHatch::isActive(void)
|
|||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_Image
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawImage);
|
||||
|
||||
CmdTechDrawImage::CmdTechDrawImage()
|
||||
: Command("TechDraw_Image")
|
||||
{
|
||||
// setting the Gui eye-candy
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Insert bitmap image");
|
||||
sToolTipText = QT_TR_NOOP("Inserts a bitmap from a file in the active drawing");
|
||||
sWhatsThis = "TechDraw_Image";
|
||||
sStatusTip = QT_TR_NOOP("Inserts a bitmap from a file in the active drawing");
|
||||
sPixmap = "actions/techdraw-image";
|
||||
}
|
||||
|
||||
void CmdTechDrawImage::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
std::string PageName = page->getNameInDocument();
|
||||
|
||||
// Reading an image
|
||||
std::string defaultDir = App::Application::getResourceDir();
|
||||
QString qDir = QString::fromUtf8(defaultDir.data(),defaultDir.size());
|
||||
QString fileName = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
|
||||
QString::fromUtf8(QT_TR_NOOP("Select an Image File")),
|
||||
qDir,
|
||||
QString::fromUtf8(QT_TR_NOOP("Image (*.png *.jpg *.jpeg)")));
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
std::string FeatName = getUniqueObjectName("Image");
|
||||
openCommand("Create Image");
|
||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewImage','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.ImageFile = '%s'",FeatName.c_str(),fileName.toUtf8().constData());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdTechDrawImage::isActive(void)
|
||||
{
|
||||
return DrawGuiUtil::needPage(this);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ToggleFrame
|
||||
//===========================================================================
|
||||
|
@ -178,6 +230,7 @@ void CreateTechDrawCommandsDecorate(void)
|
|||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
||||
rcCmdMgr.addCommand(new CmdTechDrawNewHatch());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawImage());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToggleFrame());
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include <Mod/TechDraw/App/DrawViewSection.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSymbol.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
#include "QGIDrawingTemplate.h"
|
||||
#include "QGIView.h"
|
||||
|
@ -315,6 +316,9 @@ bool MDIViewPage::attachView(App::DocumentObject *obj)
|
|||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewSpreadsheet::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewSpreadsheet( static_cast<TechDraw::DrawViewSpreadsheet *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewImage::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewImage( static_cast<TechDraw::DrawViewImage *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()) ) {
|
||||
//Hatch is not attached like other Views (since it isn't really a View)
|
||||
return true;
|
||||
|
|
92
src/Mod/TechDraw/Gui/QGCustomImage.cpp
Normal file
92
src/Mod/TechDraw/Gui/QGCustomImage.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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 <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QtGlobal>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <QRectF>
|
||||
#include <QPixmap>
|
||||
#include "QGCustomImage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGCustomImage::QGCustomImage()
|
||||
{
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setAcceptHoverEvents(false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
}
|
||||
|
||||
QGCustomImage::~QGCustomImage()
|
||||
{
|
||||
}
|
||||
|
||||
void QGCustomImage::centerAt(QPointF centerPos)
|
||||
{
|
||||
centerAt(centerPos.x(),centerPos.y());
|
||||
}
|
||||
|
||||
void QGCustomImage::centerAt(double cX, double cY)
|
||||
{
|
||||
// QGraphicsItemGroup* g = group();
|
||||
// if (g == nullptr) {
|
||||
// return;
|
||||
// }
|
||||
QPointF parentPt(cX,cY);
|
||||
QPointF myPt = mapFromParent(parentPt);
|
||||
|
||||
QRectF br = boundingRect();
|
||||
double width = br.width();
|
||||
double height = br.height();
|
||||
double newX = width/2.0;
|
||||
double newY = height/2.0;
|
||||
QPointF off(myPt.x() - newX,myPt.y() - newY);
|
||||
setOffset(off);
|
||||
}
|
||||
|
||||
bool QGCustomImage::load(QString fileSpec)
|
||||
{
|
||||
bool success = true;
|
||||
QPixmap px(fileSpec);
|
||||
m_px = px;
|
||||
// if (m_px.isNull()) {
|
||||
// Base::Console().Message("TRACE - QGCustomImage::load - pixmap no good\n");
|
||||
// }
|
||||
prepareGeometryChange();
|
||||
setPixmap(m_px);
|
||||
return(success);
|
||||
}
|
||||
|
||||
void QGCustomImage::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
QGraphicsPixmapItem::paint (painter, &myOption, widget);
|
||||
}
|
63
src/Mod/TechDraw/Gui/QGCustomImage.h
Normal file
63
src/Mod/TechDraw/Gui/QGCustomImage.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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 DRAWINGGUI_QGCUSTOMIMAGE_H
|
||||
#define DRAWINGGUI_QGCUSTOMIMAGE_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QPointF>
|
||||
#include <QByteArray>
|
||||
#include <QPixmap>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
class QStyleOptionGraphicsItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
class TechDrawGuiExport QGCustomImage : public QGraphicsPixmapItem
|
||||
{
|
||||
public:
|
||||
explicit QGCustomImage(void);
|
||||
~QGCustomImage();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 201};
|
||||
int type() const override { return Type;}
|
||||
|
||||
virtual void paint( QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr ) override;
|
||||
virtual void centerAt(QPointF centerPos);
|
||||
virtual void centerAt(double cX, double cY);
|
||||
virtual bool load(QString fileSpec);
|
||||
|
||||
protected:
|
||||
QPixmap m_px;
|
||||
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
#endif // DRAWINGGUI_QGCUSTOMIMAGE_H
|
|
@ -35,6 +35,8 @@ QGISectionLine: 172
|
|||
QGIDecoration: 173
|
||||
QGICenterLine: 174
|
||||
QGICaption: 180
|
||||
QGIViewImage: 200
|
||||
QGCustomImage: 201
|
||||
*/
|
||||
|
||||
/*
|
||||
|
|
|
@ -403,6 +403,8 @@ void QGIView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
|||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
//painter->drawRect(boundingRect());
|
||||
|
||||
QGraphicsItemGroup::paint(painter, &myOption, widget);
|
||||
}
|
||||
|
||||
|
|
144
src/Mod/TechDraw/Gui/QGIViewImage.cpp
Normal file
144
src/Mod/TechDraw/Gui/QGIViewImage.cpp
Normal file
|
@ -0,0 +1,144 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneHoverEvent>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QString>
|
||||
#include <sstream>
|
||||
#include <QRectF>
|
||||
#endif
|
||||
|
||||
//#include <qmath.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
#include "QGCustomImage.h"
|
||||
#include "QGCustomClip.h"
|
||||
#include "QGIViewImage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGIViewImage::QGIViewImage()
|
||||
{
|
||||
setHandlesChildEvents(false);
|
||||
setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setAcceptHoverEvents(true);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
|
||||
m_cliparea = new QGCustomClip();
|
||||
addToGroup(m_cliparea);
|
||||
m_cliparea->setPos(0.,0.);
|
||||
m_cliparea->setRect(0.,0.,5.,5.);
|
||||
|
||||
m_imageItem = new QGCustomImage();
|
||||
m_cliparea->addToGroup(m_imageItem);
|
||||
m_imageItem->setPos(0.,0.);
|
||||
}
|
||||
|
||||
QGIViewImage::~QGIViewImage()
|
||||
{
|
||||
// m_imageItem belongs to this group and will be deleted by Qt
|
||||
}
|
||||
|
||||
QVariant QGIViewImage::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGIViewImage::setViewImageFeature(TechDraw::DrawViewImage *obj)
|
||||
{
|
||||
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
|
||||
}
|
||||
|
||||
void QGIViewImage::updateView(bool update)
|
||||
{
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage *>(getViewObject()) );
|
||||
if( viewImage == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (update ||
|
||||
viewImage->isTouched() ||
|
||||
viewImage->Width.isTouched() ||
|
||||
viewImage->Height.isTouched() ||
|
||||
viewImage->ImageFile.isTouched()) {
|
||||
draw();
|
||||
}
|
||||
|
||||
if (viewImage->Scale.isTouched()) {
|
||||
draw();
|
||||
}
|
||||
|
||||
QGIView::updateView(update);
|
||||
}
|
||||
|
||||
void QGIViewImage::draw()
|
||||
{
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage*>(getViewObject()) );
|
||||
QRectF newRect(0.0,0.0,viewImage->Width.getValue(),viewImage->Height.getValue());
|
||||
m_cliparea->setRect(newRect.adjusted(-1,-1,1,1));
|
||||
|
||||
drawImage();
|
||||
if (borderVisible) {
|
||||
drawBorder();
|
||||
}
|
||||
}
|
||||
|
||||
void QGIViewImage::drawImage()
|
||||
{
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage *>(getViewObject()) );
|
||||
if( viewImage == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewImage->ImageFile.isEmpty()) {
|
||||
QString fileSpec = QString::fromUtf8(viewImage->ImageFile.getValue(),strlen(viewImage->ImageFile.getValue()));
|
||||
m_imageItem->load(fileSpec);
|
||||
m_imageItem->setScale(viewImage->Scale.getValue());
|
||||
QRectF br = m_cliparea->rect();
|
||||
double midX = br.width()/2.0;
|
||||
double midY = br.height()/2.0;
|
||||
m_imageItem->centerAt(midX,midY);
|
||||
m_imageItem->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
64
src/Mod/TechDraw/Gui/QGIViewImage.h
Normal file
64
src/Mod/TechDraw/Gui/QGIViewImage.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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 DRAWINGGUI_QGRAPHICSITEMVIEWIMAGE_H
|
||||
#define DRAWINGGUI_QGRAPHICSITEMVIEWIMAGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
#include <QString>
|
||||
|
||||
#include "QGIView.h"
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawViewImage;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGCustomImage;
|
||||
class QGCustomClip;
|
||||
|
||||
class TechDrawGuiExport QGIViewImage : public QGIView
|
||||
{
|
||||
public:
|
||||
QGIViewImage();
|
||||
~QGIViewImage();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 200};
|
||||
int type() const override { return Type;}
|
||||
|
||||
virtual void updateView(bool update = false) override;
|
||||
void setViewImageFeature(TechDraw::DrawViewImage *obj);
|
||||
|
||||
virtual void draw() override;
|
||||
|
||||
protected:
|
||||
virtual void drawImage();
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
|
||||
QGCustomImage* m_imageItem;
|
||||
QGCustomClip* m_cliparea;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
#endif // DRAWINGGUI_QGRAPHICSITEMVIEWIMAGE_H
|
|
@ -58,6 +58,7 @@
|
|||
#include <Mod/TechDraw/App/DrawViewClip.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
|
||||
#include "QGIDrawingTemplate.h"
|
||||
|
@ -73,6 +74,7 @@
|
|||
#include "QGIViewSymbol.h"
|
||||
#include "QGIViewClip.h"
|
||||
#include "QGIViewSpreadsheet.h"
|
||||
#include "QGIViewImage.h"
|
||||
#include "QGIFace.h"
|
||||
|
||||
#include "ZVALUE.h"
|
||||
|
@ -287,6 +289,17 @@ QGIView * QGVPage::addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view)
|
|||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGVPage::addDrawViewImage(TechDraw::DrawViewImage *view)
|
||||
{
|
||||
QPoint qp(view->X.getValue(),view->Y.getValue());
|
||||
auto qview( new QGIViewImage );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
|
||||
addView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGVPage::addViewDimension(TechDraw::DrawViewDimension *dim)
|
||||
{
|
||||
auto dimGroup( new QGIViewDimension );
|
||||
|
|
|
@ -37,6 +37,7 @@ class DrawViewSymbol;
|
|||
class DrawViewClip;
|
||||
class DrawViewCollection;
|
||||
class DrawViewSpreadsheet;
|
||||
class DrawViewImage;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
|
@ -69,6 +70,8 @@ public:
|
|||
QGIView * addDrawViewSymbol(TechDraw::DrawViewSymbol *view);
|
||||
QGIView * addDrawViewClip(TechDraw::DrawViewClip *view);
|
||||
QGIView * addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view);
|
||||
QGIView * addDrawViewImage(TechDraw::DrawViewImage *view);
|
||||
|
||||
|
||||
QGIView * findView(App::DocumentObject *obj) const;
|
||||
QGIView * findParent(QGIView *) const;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<file>icons/actions/techdraw-toggleframe.svg</file>
|
||||
<file>icons/actions/techdraw-projgroup.svg</file>
|
||||
<file>icons/actions/techdraw-spreadsheet.svg</file>
|
||||
<file>icons/actions/techdraw-image.svg</file>
|
||||
<file>icons/actions/section-up.svg</file>
|
||||
<file>icons/actions/section-down.svg</file>
|
||||
<file>icons/actions/section-left.svg</file>
|
||||
|
|
481
src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-image.svg
Normal file
481
src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-image.svg
Normal file
|
@ -0,0 +1,481 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
id="svg249"
|
||||
height="48"
|
||||
width="48"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="techdraw-image.svg">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="693"
|
||||
id="namedview3431"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1"
|
||||
inkscape:cx="11.977316"
|
||||
inkscape:cy="24"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg249" />
|
||||
<defs
|
||||
id="defs3">
|
||||
<radialGradient
|
||||
gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient5060"
|
||||
id="radialGradient5031"
|
||||
fy="486.64789"
|
||||
fx="605.71429"
|
||||
r="117.14286"
|
||||
cy="486.64789"
|
||||
cx="605.71429" />
|
||||
<linearGradient
|
||||
id="linearGradient5060">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
id="stop5062" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
id="stop5064" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient5060"
|
||||
id="radialGradient5029"
|
||||
fy="486.64789"
|
||||
fx="605.71429"
|
||||
r="117.14286"
|
||||
cy="486.64789"
|
||||
cx="605.71429" />
|
||||
<linearGradient
|
||||
id="linearGradient5048">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
id="stop5050" />
|
||||
<stop
|
||||
offset="0.5"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
id="stop5056" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
id="stop5052" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient5048"
|
||||
id="linearGradient5027"
|
||||
y2="609.50507"
|
||||
x2="302.85715"
|
||||
y1="366.64789"
|
||||
x1="302.85715" />
|
||||
<linearGradient
|
||||
id="linearGradient4542">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
id="stop4544" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
id="stop4546" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
gradientTransform="matrix(1,0,0,0.284916,0,30.08928)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient4542"
|
||||
id="radialGradient4548"
|
||||
fy="42.07798"
|
||||
fx="24.306795"
|
||||
r="15.821514"
|
||||
cy="42.07798"
|
||||
cx="24.306795" />
|
||||
<linearGradient
|
||||
id="linearGradient15662">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:1"
|
||||
id="stop15664" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#f8f8f8;stop-opacity:1"
|
||||
id="stop15666" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="aigrd3"
|
||||
fy="64.567902"
|
||||
fx="20.892099"
|
||||
r="5.257"
|
||||
cy="64.567902"
|
||||
cx="20.892099">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#f0f0f0;stop-opacity:1"
|
||||
id="stop15573" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#9a9a9a;stop-opacity:1"
|
||||
id="stop15575" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="aigrd2"
|
||||
fy="114.5684"
|
||||
fx="20.892099"
|
||||
r="5.256"
|
||||
cy="114.5684"
|
||||
cx="20.892099">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#f0f0f0;stop-opacity:1"
|
||||
id="stop15566" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#9a9a9a;stop-opacity:1"
|
||||
id="stop15568" />
|
||||
</radialGradient>
|
||||
<linearGradient
|
||||
id="linearGradient269">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#a3a3a3;stop-opacity:1"
|
||||
id="stop270" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#4c4c4c;stop-opacity:1"
|
||||
id="stop271" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient259">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#fafafa;stop-opacity:1"
|
||||
id="stop260" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#bbbbbb;stop-opacity:1"
|
||||
id="stop261" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient12512">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:1"
|
||||
id="stop12513" />
|
||||
<stop
|
||||
offset="0.5"
|
||||
style="stop-color:#fff520;stop-opacity:0.89108908"
|
||||
id="stop12517" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#fff300;stop-opacity:0"
|
||||
id="stop12514" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
gradientTransform="matrix(0.96827297,0,0,1.032767,2.9576405,-47.586563)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient269"
|
||||
id="radialGradient15656"
|
||||
fy="3.7561285"
|
||||
fx="8.824419"
|
||||
r="37.751713"
|
||||
cy="3.7561285"
|
||||
cx="8.824419" />
|
||||
<radialGradient
|
||||
gradientTransform="matrix(0.96049297,0,0,1.041132,-0.39591234,-48.23301)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient259"
|
||||
id="radialGradient15658"
|
||||
fy="35.736916"
|
||||
fx="33.966679"
|
||||
r="86.70845"
|
||||
cy="35.736916"
|
||||
cx="33.966679" />
|
||||
<radialGradient
|
||||
gradientTransform="matrix(0.96827297,0,0,1.032767,2.9576405,-47.586563)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient15662"
|
||||
id="radialGradient15668"
|
||||
fy="7.2678967"
|
||||
fx="8.1435566"
|
||||
r="38.158695"
|
||||
cy="7.2678967"
|
||||
cx="8.1435566" />
|
||||
<radialGradient
|
||||
gradientTransform="matrix(0.229703,0,0,0.229703,4.613529,3.979808)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#aigrd2"
|
||||
id="radialGradient2283"
|
||||
fy="114.5684"
|
||||
fx="20.892099"
|
||||
r="5.256"
|
||||
cy="114.5684"
|
||||
cx="20.892099" />
|
||||
<radialGradient
|
||||
gradientTransform="matrix(0.229703,0,0,0.229703,4.613529,3.979808)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#aigrd3"
|
||||
id="radialGradient2285"
|
||||
fy="64.567902"
|
||||
fx="20.892099"
|
||||
r="5.257"
|
||||
cy="64.567902"
|
||||
cx="20.892099" />
|
||||
<linearGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient3377-76"
|
||||
id="linearGradient4343"
|
||||
y2="41.792759"
|
||||
x2="44.524982"
|
||||
y1="14.452502"
|
||||
x1="18.971846" />
|
||||
<linearGradient
|
||||
id="linearGradient3377-76">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#faff2b;stop-opacity:1"
|
||||
id="stop3379-5" />
|
||||
<stop
|
||||
offset="0.5"
|
||||
style="stop-color:#fcb915;stop-opacity:1"
|
||||
id="stop4345" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#c68708;stop-opacity:1"
|
||||
id="stop3381-7" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient3377-76"
|
||||
id="linearGradient4349"
|
||||
y2="108.75008"
|
||||
x2="175.6825"
|
||||
y1="79.160103"
|
||||
x1="145.64697" />
|
||||
<linearGradient
|
||||
id="linearGradient4482">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#faff2b;stop-opacity:1"
|
||||
id="stop4484" />
|
||||
<stop
|
||||
offset="0.5"
|
||||
style="stop-color:#fcb915;stop-opacity:1"
|
||||
id="stop4486" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#c68708;stop-opacity:1"
|
||||
id="stop4488" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient3377"
|
||||
id="radialGradient4351"
|
||||
fy="97.369568"
|
||||
fx="135.38333"
|
||||
r="19.467436"
|
||||
cy="97.369568"
|
||||
cx="135.38333" />
|
||||
<linearGradient
|
||||
id="linearGradient3377">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#faff2b;stop-opacity:1"
|
||||
id="stop3379" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#ffaa00;stop-opacity:1"
|
||||
id="stop3381" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#linearGradient3377"
|
||||
id="radialGradient4353"
|
||||
fy="28.869568"
|
||||
fx="45.883327"
|
||||
r="19.467436"
|
||||
cy="28.869568"
|
||||
cx="45.883327" />
|
||||
<linearGradient
|
||||
id="linearGradient4495">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#faff2b;stop-opacity:1"
|
||||
id="stop4497" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#ffaa00;stop-opacity:1"
|
||||
id="stop4499" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata4">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Jakub Steiner</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:source>http://jimmac.musichall.cz</dc:source>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/Attribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/ShareAlike" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
style="display:inline"
|
||||
id="layer4" />
|
||||
<path
|
||||
d="M 43.217026,12.087907 5.1993156,12.102142"
|
||||
id="path15674"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.20467828" />
|
||||
<g
|
||||
id="g3433"
|
||||
transform="matrix(1.65,0,0,1.65,-15.6,-18.472941)">
|
||||
<ellipse
|
||||
style="fill:#cc0000;fill-rule:evenodd;stroke:#ef2929;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path3603"
|
||||
cx="24.04706"
|
||||
cy="25.905884"
|
||||
rx="2.9176471"
|
||||
ry="2.8235295" />
|
||||
<g
|
||||
id="g3609"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
transform="translate(0.42352847,1.3411761)">
|
||||
<ellipse
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)"
|
||||
ry="1.6996821"
|
||||
rx="3.2055645"
|
||||
cy="12.689981"
|
||||
cx="24.183033"
|
||||
id="path3605"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
<ellipse
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="ellipse3607"
|
||||
cx="38.709206"
|
||||
cy="13.771251"
|
||||
rx="3.2055645"
|
||||
ry="1.6996821"
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)" />
|
||||
</g>
|
||||
<g
|
||||
id="g3613"
|
||||
transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,24.765339,-8.1075045)"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none">
|
||||
<ellipse
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="ellipse3615"
|
||||
cx="24.183033"
|
||||
cy="12.689981"
|
||||
rx="3.2055645"
|
||||
ry="1.6996821"
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)" />
|
||||
<ellipse
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)"
|
||||
ry="1.6996821"
|
||||
rx="3.2055645"
|
||||
cy="13.771251"
|
||||
cx="38.709206"
|
||||
id="ellipse3617"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
</g>
|
||||
<g
|
||||
id="g3619"
|
||||
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,-10.107505,25.234661)"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none">
|
||||
<ellipse
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)"
|
||||
ry="1.6996821"
|
||||
rx="3.2055645"
|
||||
cy="12.689981"
|
||||
cx="24.183033"
|
||||
id="ellipse3621"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
<ellipse
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="ellipse3623"
|
||||
cx="38.709206"
|
||||
cy="13.771251"
|
||||
rx="3.2055645"
|
||||
ry="1.6996821"
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0,-1,1,0,-0.65882393,49.576471)"
|
||||
id="g3625"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none">
|
||||
<ellipse
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="ellipse3627"
|
||||
cx="24.183033"
|
||||
cy="12.689981"
|
||||
rx="3.2055645"
|
||||
ry="1.6996821"
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)" />
|
||||
<ellipse
|
||||
transform="matrix(0.91728927,0.39822153,-0.39822153,0.91728927,0,0)"
|
||||
ry="1.6996821"
|
||||
rx="3.2055645"
|
||||
cy="13.771251"
|
||||
cx="38.709206"
|
||||
id="ellipse3629"
|
||||
style="fill:#fce94f;stroke:#c4a000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
</g>
|
||||
<rect
|
||||
style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-miterlimit:4;stroke-dasharray:1.6, 0.8;stroke-dashoffset:0"
|
||||
id="rect4446"
|
||||
width="25.694118"
|
||||
height="25.317648"
|
||||
x="11.152941"
|
||||
y="13.082353"
|
||||
rx="0.5"
|
||||
ry="0.5" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 15 KiB |
87
src/Mod/TechDraw/Gui/ViewProviderImage.cpp
Normal file
87
src/Mod/TechDraw/Gui/ViewProviderImage.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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_
|
||||
#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/SoFCSelection.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include "ViewProviderImage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderImage, TechDrawGui::ViewProviderDrawingView)
|
||||
|
||||
//**************************************************************************
|
||||
// Construction/Destruction
|
||||
|
||||
ViewProviderImage::ViewProviderImage()
|
||||
{
|
||||
sPixmap = "actions/techdraw-image";
|
||||
}
|
||||
|
||||
ViewProviderImage::~ViewProviderImage()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderImage::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
// call parent attach method
|
||||
ViewProviderDrawingView::attach(pcFeat);
|
||||
}
|
||||
|
||||
void ViewProviderImage::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
ViewProviderDrawingView::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderImage::getDisplayModes(void) const
|
||||
{
|
||||
// get the modes of the father
|
||||
std::vector<std::string> StrList = ViewProviderDrawingView::getDisplayModes();
|
||||
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderImage::updateData(const App::Property* prop)
|
||||
{
|
||||
ViewProviderDrawingView::updateData(prop);
|
||||
}
|
||||
|
||||
TechDraw::DrawViewImage* ViewProviderImage::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewImage*>(pcObject);
|
||||
}
|
||||
|
||||
|
59
src/Mod/TechDraw/Gui/ViewProviderImage.h
Normal file
59
src/Mod/TechDraw/Gui/ViewProviderImage.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 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 DRAWINGGUI_VIEWPROVIDERIMAGE_H
|
||||
#define DRAWINGGUI_VIEWPROVIDERIMAGE_H
|
||||
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
#include "ViewProviderDrawingView.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
|
||||
class TechDrawGuiExport ViewProviderImage : public ViewProviderDrawingView
|
||||
{
|
||||
PROPERTY_HEADER(TechDrawGui::ViewProviderImage);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderImage();
|
||||
/// destructor
|
||||
virtual ~ViewProviderImage();
|
||||
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
virtual bool useNewSelectionModel(void) const {return false;}
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual void updateData(const App::Property*);
|
||||
|
||||
virtual TechDraw::DrawViewImage* getViewObject() const;
|
||||
};
|
||||
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
|
||||
#endif // DRAWINGGUI_VIEWPROVIDERIMAGE_H
|
|
@ -76,6 +76,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
*draw << "TechDraw_DraftView";
|
||||
*draw << "TechDraw_ArchView";
|
||||
*draw << "TechDraw_ExportPage";
|
||||
*draw << "TechDraw_Image";
|
||||
//*draw << "TechDraw_Open";
|
||||
//*part << "TechDraw_NewA3Landscape";
|
||||
//*part << "TechDraw_OpenBrowserView";
|
||||
|
@ -130,6 +131,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
Gui::ToolBarItem *decor = new Gui::ToolBarItem(root);
|
||||
decor->setCommand("TechDraw Decoration");
|
||||
*decor << "TechDraw_NewHatch";
|
||||
*decor << "TechDraw_Image";
|
||||
*decor << "TechDraw_ToggleFrame";
|
||||
return root;
|
||||
}
|
||||
|
@ -177,6 +179,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
|||
Gui::ToolBarItem *decor = new Gui::ToolBarItem(root);
|
||||
decor->setCommand("TechDraw Decoration");
|
||||
*decor << "TechDraw_NewHatch";
|
||||
*decor << "TechDraw_Image";
|
||||
*decor << "TechDraw_ToggleFrame";
|
||||
|
||||
return root;
|
||||
|
|
Loading…
Reference in New Issue
Block a user