Static library for export a layout to Wavefront OBJ file.
--HG-- branch : develop
This commit is contained in:
parent
0efbe1745c
commit
30d1fad26f
|
@ -354,6 +354,16 @@ DEPENDPATH += $$PWD/../libs/ifc
|
||||||
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/ifc/$${DESTDIR}/ifc.lib
|
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/ifc/$${DESTDIR}/ifc.lib
|
||||||
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/ifc/$${DESTDIR}/libifc.a
|
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/ifc/$${DESTDIR}/libifc.a
|
||||||
|
|
||||||
|
# VObj static library
|
||||||
|
unix|win32: LIBS += -L$$OUT_PWD/../libs/vobj/$${DESTDIR}/ -lvobj
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/../libs/vobj
|
||||||
|
DEPENDPATH += $$PWD/../libs/vobj
|
||||||
|
|
||||||
|
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/vobj.lib
|
||||||
|
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/libvobj.a
|
||||||
|
|
||||||
|
|
||||||
# Strip after you link all libaries.
|
# Strip after you link all libaries.
|
||||||
CONFIG(release, debug|release){
|
CONFIG(release, debug|release){
|
||||||
win32:!win32-msvc*{
|
win32:!win32-msvc*{
|
||||||
|
|
|
@ -1905,7 +1905,10 @@ void MainWindow::ActionLayout(bool checked)
|
||||||
listDetails.append(new VItem(path, listDetails.size()));
|
listDetails.append(new VItem(path, listDetails.size()));
|
||||||
}
|
}
|
||||||
QString description = doc->GetDescription();
|
QString description = doc->GetDescription();
|
||||||
emit ModelChosen(listDetails, curFile, description);
|
|
||||||
|
QString fileName;
|
||||||
|
curFile.isEmpty() ? fileName = "unnamed" : fileName = curFile;
|
||||||
|
emit ModelChosen(listDetails, fileName, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include "core/vapplication.h"
|
#include "core/vapplication.h"
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
|
#include "../../libs/vobj/vobjpaintdevice.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# define PDFTOPS "pdftops.exe"
|
# define PDFTOPS "pdftops.exe"
|
||||||
|
@ -229,6 +230,7 @@ void TableWindow::saveScene()
|
||||||
extByMessage[ tr("Svg files (*.svg)") ] = ".svg";
|
extByMessage[ tr("Svg files (*.svg)") ] = ".svg";
|
||||||
extByMessage[ tr("PDF files (*.pdf)") ] = ".pdf";
|
extByMessage[ tr("PDF files (*.pdf)") ] = ".pdf";
|
||||||
extByMessage[ tr("Images (*.png)") ] = ".png";
|
extByMessage[ tr("Images (*.png)") ] = ".png";
|
||||||
|
extByMessage[ tr("Wavefront OBJ (*.obj)") ] = ".obj";
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.start(PDFTOPS);
|
proc.start(PDFTOPS);
|
||||||
|
@ -280,7 +282,7 @@ void TableWindow::saveScene()
|
||||||
shadowPaper->setVisible(false);
|
shadowPaper->setVisible(false);
|
||||||
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
||||||
QFileInfo fi( name );
|
QFileInfo fi( name );
|
||||||
QStringList suffix = QStringList() << "svg" << "png" << "pdf" << "eps" << "ps";
|
QStringList suffix = QStringList() << "svg" << "png" << "pdf" << "eps" << "ps" << "obj";
|
||||||
switch (suffix.indexOf(fi.suffix()))
|
switch (suffix.indexOf(fi.suffix()))
|
||||||
{
|
{
|
||||||
case 0: //svg
|
case 0: //svg
|
||||||
|
@ -300,6 +302,11 @@ void TableWindow::saveScene()
|
||||||
case 4: //ps
|
case 4: //ps
|
||||||
PsFile(name);
|
PsFile(name);
|
||||||
break;
|
break;
|
||||||
|
case 5: //obj
|
||||||
|
paper->setVisible(false);
|
||||||
|
ObjFile(name);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "Can't recognize file suffix. File file "<<name<<Q_FUNC_INFO;
|
qDebug() << "Can't recognize file suffix. File file "<<name<<Q_FUNC_INFO;
|
||||||
break;
|
break;
|
||||||
|
@ -654,3 +661,16 @@ void TableWindow::PdfToPs(const QStringList ¶ms) const
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TableWindow::ObjFile(const QString &name) const
|
||||||
|
{
|
||||||
|
VObjPaintDevice generator;
|
||||||
|
generator.setFileName(name);
|
||||||
|
generator.setSize(paper->rect().size().toSize());
|
||||||
|
generator.setResolution(static_cast<int>(qApp->PrintDPI));
|
||||||
|
QPainter painter;
|
||||||
|
painter.begin(&generator);
|
||||||
|
tableScene->render(&painter);
|
||||||
|
painter.end();
|
||||||
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ private:
|
||||||
void EpsFile(const QString &name)const;
|
void EpsFile(const QString &name)const;
|
||||||
void PsFile(const QString &name)const;
|
void PsFile(const QString &name)const;
|
||||||
void PdfToPs(const QStringList ¶ms)const;
|
void PdfToPs(const QStringList ¶ms)const;
|
||||||
|
void ObjFile(const QString &name)const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TABLEWINDOW_H
|
#endif // TABLEWINDOW_H
|
||||||
|
|
|
@ -2,4 +2,5 @@ TEMPLATE = subdirs
|
||||||
CONFIG += ordered
|
CONFIG += ordered
|
||||||
SUBDIRS = qmuparser \
|
SUBDIRS = qmuparser \
|
||||||
vpropertyexplorer \
|
vpropertyexplorer \
|
||||||
ifc
|
ifc \
|
||||||
|
vobj
|
||||||
|
|
|
@ -13,7 +13,7 @@ QT -= gui
|
||||||
# Name of library
|
# Name of library
|
||||||
TARGET = qmuparser
|
TARGET = qmuparser
|
||||||
|
|
||||||
# We want create library
|
# We want create a library
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
|
||||||
# Use out-of-source builds (shadow builds)
|
# Use out-of-source builds (shadow builds)
|
||||||
|
|
1077
src/libs/vobj/delaunay.c
Normal file
1077
src/libs/vobj/delaunay.c
Normal file
File diff suppressed because it is too large
Load Diff
92
src/libs/vobj/delaunay.h
Normal file
92
src/libs/vobj/delaunay.h
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
#ifndef DELAUNAY_H
|
||||||
|
#define DELAUNAY_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
** delaunay.c : compute 2D delaunay triangulation in the plane.
|
||||||
|
** Copyright (C) 2005 Wael El Oraiby <wael.eloraiby@gmail.com>
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This program is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEL_CIRCLE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* define the floating point type, comment to use float - Be careful "float" type will assert more often */
|
||||||
|
#define USE_DOUBLE
|
||||||
|
|
||||||
|
#define FAST_PREDICATE 1 /* fast but floating point errors are more likely to occur */
|
||||||
|
#define LOOSE_PREDICATE 2 /* loose with epsilon defined in the delaunay file - errors will happen but less frequently */
|
||||||
|
#define EXACT_PREDICATE 3 /* use exact arithmetic - slower, but shouldn't produce any floating point error */
|
||||||
|
|
||||||
|
#define PREDICATE EXACT_PREDICATE
|
||||||
|
|
||||||
|
#if PREDICATE == EXACT_PREDICATE && !defined(USE_DOUBLE)
|
||||||
|
# define USE_DOUBLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DOUBLE
|
||||||
|
typedef double real;
|
||||||
|
#else
|
||||||
|
typedef float real;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
real x, y;
|
||||||
|
} del_point2d_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/** input points count */
|
||||||
|
unsigned int num_points;
|
||||||
|
|
||||||
|
/** the input points */
|
||||||
|
del_point2d_t* points;
|
||||||
|
|
||||||
|
/** number of returned faces */
|
||||||
|
unsigned int num_faces;
|
||||||
|
|
||||||
|
/** the triangles given as a sequence: num verts, verts indices, num verts, verts indices first face is the external face */
|
||||||
|
unsigned int* faces;
|
||||||
|
} delaunay2d_t;
|
||||||
|
|
||||||
|
typedef int (*incircle_predicate_t)(del_point2d_t* p0, del_point2d_t* p1, del_point2d_t* p2, del_point2d_t* p3);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* build the 2D Delaunay triangulation given a set of points of at least 3 points
|
||||||
|
*
|
||||||
|
* @points: point set given as a sequence of tuple x0, y0, x1, y1, ....
|
||||||
|
* @num_points: number of given point
|
||||||
|
* @preds: the incircle predicate
|
||||||
|
* @faces: the triangles given as a sequence: num verts, verts indices, num verts, verts indices
|
||||||
|
* first face is the external face
|
||||||
|
* @pred: incircle predicate
|
||||||
|
* @return: the number of created faces
|
||||||
|
*/
|
||||||
|
delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points, incircle_predicate_t pred);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* release a delaunay2d object
|
||||||
|
*/
|
||||||
|
void delaunay2d_release(delaunay2d_t* del);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // DELAUNAY_H
|
4261
src/libs/vobj/predicates.c
Normal file
4261
src/libs/vobj/predicates.c
Normal file
File diff suppressed because it is too large
Load Diff
30
src/libs/vobj/stable.cpp
Normal file
30
src/libs/vobj/stable.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file stable.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 10 12, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2013 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
// Build the precompiled headers.
|
||||||
|
#include "stable.h"
|
52
src/libs/vobj/stable.h
Normal file
52
src/libs/vobj/stable.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file stable.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 10 12, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2013 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef STABLE_H
|
||||||
|
#define STABLE_H
|
||||||
|
|
||||||
|
/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */
|
||||||
|
#ifndef __clang__
|
||||||
|
#pragma message("Compiling precompiled headers for VObj library.\n")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Add C includes here */
|
||||||
|
|
||||||
|
#if defined __cplusplus
|
||||||
|
/* Add C++ includes here */
|
||||||
|
|
||||||
|
#ifdef QT_CORE_LIB
|
||||||
|
#include <QtCore>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef QT_GUI_LIB
|
||||||
|
# include <QtGui>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif/*__cplusplus*/
|
||||||
|
|
||||||
|
#endif // STABLE_H
|
15
src/libs/vobj/vobj.pri
Normal file
15
src/libs/vobj/vobj.pri
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# ADD TO EACH PATH $$PWD VARIABLE!!!!!!
|
||||||
|
# This need for corect working file translations.pro
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/vobjengine.cpp \
|
||||||
|
$$PWD/delaunay.c \
|
||||||
|
$$PWD/predicates.c \
|
||||||
|
$$PWD/vobjpaintdevice.cpp \
|
||||||
|
$$PWD/stable.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/vobjengine.h \
|
||||||
|
$$PWD/delaunay.h \
|
||||||
|
$$PWD/vobjpaintdevice.h \
|
||||||
|
$$PWD/stable.h
|
78
src/libs/vobj/vobj.pro
Normal file
78
src/libs/vobj/vobj.pro
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2014-12-12T14:55:06
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
# File with common stuff for whole project
|
||||||
|
include(../../../Valentina.pri)
|
||||||
|
|
||||||
|
# Name of library
|
||||||
|
TARGET = vobj
|
||||||
|
|
||||||
|
# We want create a library
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
CONFIG += \
|
||||||
|
staticlib \# Making static library
|
||||||
|
c++11 # We use C++11 standard
|
||||||
|
|
||||||
|
# Use out-of-source builds (shadow builds)
|
||||||
|
CONFIG -= debug_and_release debug_and_release_target
|
||||||
|
|
||||||
|
include(vobj.pri)
|
||||||
|
|
||||||
|
# This is static library so no need in "make install"
|
||||||
|
|
||||||
|
# directory for executable file
|
||||||
|
DESTDIR = bin
|
||||||
|
|
||||||
|
# files created moc
|
||||||
|
MOC_DIR = moc
|
||||||
|
|
||||||
|
# objecs files
|
||||||
|
OBJECTS_DIR = obj
|
||||||
|
|
||||||
|
# Set using ccache. Function enable_ccache() defined in Valentina.pri.
|
||||||
|
$$enable_ccache()
|
||||||
|
|
||||||
|
# Set precompiled headers. Function set_PCH() defined in Valentina.pri.
|
||||||
|
$$set_PCH()
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release){
|
||||||
|
# Debug mode
|
||||||
|
unix {
|
||||||
|
#Turn on compilers warnings.
|
||||||
|
*-g++{
|
||||||
|
QMAKE_CXXFLAGS += \
|
||||||
|
# Key -isystem disable checking errors in system headers.
|
||||||
|
-isystem "$${OUT_PWD}/$${MOC_DIR}" \
|
||||||
|
$$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details.
|
||||||
|
}
|
||||||
|
clang*{
|
||||||
|
QMAKE_CXXFLAGS += \
|
||||||
|
# Key -isystem disable checking errors in system headers.
|
||||||
|
-isystem "$${OUT_PWD}/$${MOC_DIR}" \
|
||||||
|
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details.
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*-g++{
|
||||||
|
QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
# Release mode
|
||||||
|
|
||||||
|
!unix:*-g++{
|
||||||
|
QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll
|
||||||
|
}
|
||||||
|
|
||||||
|
!macx:!win32-msvc*{
|
||||||
|
# Turn on debug symbols in release mode on Unix systems.
|
||||||
|
# On Mac OS X temporarily disabled. TODO: find way how to strip binary file.
|
||||||
|
QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3
|
||||||
|
QMAKE_CFLAGS_RELEASE += -g -gdwarf-3
|
||||||
|
QMAKE_LFLAGS_RELEASE =
|
||||||
|
}
|
||||||
|
}
|
326
src/libs/vobj/vobjengine.cpp
Normal file
326
src/libs/vobj/vobjengine.cpp
Normal file
|
@ -0,0 +1,326 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vobjengine.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 12 12, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "vobjengine.h"
|
||||||
|
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
|
||||||
|
{
|
||||||
|
return QPaintEngine::PaintEngineFeatures(
|
||||||
|
QPaintEngine::AllFeatures
|
||||||
|
& ~QPaintEngine::PatternBrush
|
||||||
|
& ~QPaintEngine::PerspectiveTransform
|
||||||
|
& ~QPaintEngine::ConicalGradientFill
|
||||||
|
& ~QPaintEngine::PorterDuff);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VObjEngine::VObjEngine()
|
||||||
|
:QPaintEngine(svgEngineFeatures()), stream(nullptr), globalPointsCount(0), outputDevice(nullptr), planeCount(0),
|
||||||
|
size(), resolution(96), matrix()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VObjEngine::~VObjEngine()
|
||||||
|
{
|
||||||
|
outputDevice = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VObjEngine::begin(QPaintDevice *pdev)
|
||||||
|
{
|
||||||
|
Q_UNUSED(pdev)
|
||||||
|
if (outputDevice == nullptr)
|
||||||
|
{
|
||||||
|
qWarning("VObjEngine::begin(), no output device");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (outputDevice->isOpen() == false)
|
||||||
|
{
|
||||||
|
if (outputDevice->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate) == false)
|
||||||
|
{
|
||||||
|
qWarning("VObjEngine::begin(), could not open output device: '%s'",
|
||||||
|
qPrintable(outputDevice->errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (outputDevice->isWritable() == false)
|
||||||
|
{
|
||||||
|
qWarning("VObjEngine::begin(), could not write to read-only output device: '%s'",
|
||||||
|
qPrintable(outputDevice->errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size.isValid() == false)
|
||||||
|
{
|
||||||
|
qWarning()<<"VObjEngine::begin(), size is not valid";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream = new QTextStream(outputDevice);
|
||||||
|
*stream << "# Valentina OBJ File" << endl;
|
||||||
|
*stream << "# www.valentina-project.org/" << endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VObjEngine::end()
|
||||||
|
{
|
||||||
|
delete stream;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::updateState(const QPaintEngineState &state)
|
||||||
|
{
|
||||||
|
QPaintEngine::DirtyFlags flags = state.state();
|
||||||
|
|
||||||
|
// always stream full gstate, which is not required, but...
|
||||||
|
flags |= QPaintEngine::AllDirty;
|
||||||
|
|
||||||
|
|
||||||
|
if (flags & QPaintEngine::DirtyTransform)
|
||||||
|
{
|
||||||
|
matrix = state.matrix(); // Save new matrix for moving paths
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::drawPath(const QPainterPath &path)
|
||||||
|
{
|
||||||
|
QPolygonF polygon = path.toFillPolygon(matrix);
|
||||||
|
polygon = MakePointsUnique(polygon);// Points must be unique
|
||||||
|
if (polygon.size() < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 sq = Square(polygon);
|
||||||
|
|
||||||
|
++planeCount;
|
||||||
|
*stream << "o Plane." << QString("%1").arg(planeCount, 3, 10, QLatin1Char('0')) << endl;
|
||||||
|
|
||||||
|
unsigned int num_points = 0;
|
||||||
|
|
||||||
|
for(int i=0; i < polygon.count(); i++)
|
||||||
|
{
|
||||||
|
if( num_points < MAX_POINTS )
|
||||||
|
{
|
||||||
|
points[num_points].x = polygon.at(i).x();
|
||||||
|
points[num_points].y = polygon.at(i).y();
|
||||||
|
num_points++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
delaunay2d_t *res = delaunay2d_from(points, num_points, NULL);//Calculate faces
|
||||||
|
|
||||||
|
QPointF pf[MAX_POINTS];
|
||||||
|
bool skipFace=false;//Need skip first face
|
||||||
|
|
||||||
|
for(int i = 0; i < res->num_faces; i++ )
|
||||||
|
{
|
||||||
|
if (offset == 0)
|
||||||
|
{
|
||||||
|
skipFace=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skipFace=false;
|
||||||
|
}
|
||||||
|
int num_verts = res->faces[offset];
|
||||||
|
offset++;
|
||||||
|
for( int j = 0; j < num_verts; j++ )
|
||||||
|
{
|
||||||
|
int p0 = res->faces[offset + j];
|
||||||
|
pf[j] = QPointF(points[p0].x, points[p0].y);
|
||||||
|
}
|
||||||
|
if (skipFace == false )
|
||||||
|
{
|
||||||
|
QPolygonF face;
|
||||||
|
for( int i = 0; i < num_verts; i++ )
|
||||||
|
{
|
||||||
|
face << QPointF(pf[i]);
|
||||||
|
}
|
||||||
|
QPolygonF united = polygon.united(face);
|
||||||
|
qint64 sqUnited = Square(united);
|
||||||
|
if(sqUnited <= sq)
|
||||||
|
{// This face incide our base polygon.
|
||||||
|
drawPolygon(pf, num_verts, QPaintEngine::OddEvenMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offset += num_verts;
|
||||||
|
}
|
||||||
|
|
||||||
|
delaunay2d_release(res);//Don't forget release data
|
||||||
|
*stream << "s off" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
|
||||||
|
{
|
||||||
|
Q_UNUSED(mode)
|
||||||
|
|
||||||
|
drawPoints(points, pointCount);
|
||||||
|
*stream << "f";
|
||||||
|
|
||||||
|
for (int i = 0; i < pointCount; ++i)
|
||||||
|
{
|
||||||
|
*stream << QString(" %1").arg(globalPointsCount - pointCount + i + 1);
|
||||||
|
}
|
||||||
|
*stream << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPaintEngine::Type VObjEngine::type() const
|
||||||
|
{
|
||||||
|
return QPaintEngine::User;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::drawPoints(const QPointF *points, int pointCount)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < pointCount; ++i)
|
||||||
|
{
|
||||||
|
qreal x = ((points[i].x() - 0)/qFloor(size.width()/2.0)) - 1.0;
|
||||||
|
qreal y = (((points[i].y() - 0)/qFloor(size.width()/2.0)) - 1.0)*-1;
|
||||||
|
|
||||||
|
*stream << "v" << " " << QString::number(x, 'f', 6 ) << " " << QString::number(y, 'f', 6 ) << " "
|
||||||
|
<< "0.000000" << endl;
|
||||||
|
++globalPointsCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
|
||||||
|
{
|
||||||
|
Q_UNUSED(r)
|
||||||
|
Q_UNUSED(pm)
|
||||||
|
Q_UNUSED(sr)
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QSize VObjEngine::getSize() const
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::setSize(const QSize &value)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!isActive());
|
||||||
|
size = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QIODevice *VObjEngine::getOutputDevice() const
|
||||||
|
{
|
||||||
|
return outputDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::setOutputDevice(QIODevice *value)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!isActive());
|
||||||
|
outputDevice = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VObjEngine::getResolution() const
|
||||||
|
{
|
||||||
|
return resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjEngine::setResolution(int value)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!isActive());
|
||||||
|
resolution = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPolygonF VObjEngine::MakePointsUnique(const QPolygonF &polygon) const
|
||||||
|
{
|
||||||
|
QVector<QPointF> set;
|
||||||
|
QPolygonF uniquePolygon;
|
||||||
|
for(int i=0; i < polygon.count(); i++)
|
||||||
|
{
|
||||||
|
if (set.contains(polygon.at(i)) == false)
|
||||||
|
{
|
||||||
|
set.append(polygon.at(i));
|
||||||
|
uniquePolygon.append(polygon.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uniquePolygon;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qint64 VObjEngine::Square(const QPolygonF &poly) const
|
||||||
|
{
|
||||||
|
QVector<qreal> x;
|
||||||
|
QVector<qreal> y;
|
||||||
|
|
||||||
|
int n = poly.count();
|
||||||
|
qreal s, res = 0;
|
||||||
|
qint64 sq = 0;
|
||||||
|
|
||||||
|
for(int i=0; i < n; i++)
|
||||||
|
{
|
||||||
|
x.append(poly.at(i).x());
|
||||||
|
y.append(poly.at(i).y());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculation a polygon area through the sum of the areas of trapezoids
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
s = x.at(i)*(y.at(n-1) - y.at(i+1)); //if i == 0, then y[i-1] replace on y[n-1]
|
||||||
|
res += s;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i == n-1)
|
||||||
|
{
|
||||||
|
s = x.at(i)*(y.at(i-1) - y.at(0)); // if i == n-1, then y[i+1] replace on y[0]
|
||||||
|
res += s;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = x.at(i)*(y.at(i-1) - y.at(i+1));
|
||||||
|
res += s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sq = qFloor(qAbs(res/2.0));
|
||||||
|
return sq;
|
||||||
|
}
|
78
src/libs/vobj/vobjengine.h
Normal file
78
src/libs/vobj/vobjengine.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vobjengine.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 12 12, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VOBJENGINE_H
|
||||||
|
#define VOBJENGINE_H
|
||||||
|
|
||||||
|
#include <QPaintEngine>
|
||||||
|
#include "delaunay.h"
|
||||||
|
|
||||||
|
class QTextStream;
|
||||||
|
|
||||||
|
#define MAX_POINTS 512
|
||||||
|
|
||||||
|
class VObjEngine : public QPaintEngine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VObjEngine();
|
||||||
|
virtual ~VObjEngine();
|
||||||
|
|
||||||
|
virtual bool begin(QPaintDevice *pdev);
|
||||||
|
virtual bool end();
|
||||||
|
virtual void updateState(const QPaintEngineState &state);
|
||||||
|
virtual void drawPath(const QPainterPath &path);
|
||||||
|
virtual Type type() const;
|
||||||
|
virtual void drawPoints(const QPointF *points, int pointCount);
|
||||||
|
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
||||||
|
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
||||||
|
|
||||||
|
QSize getSize() const;
|
||||||
|
void setSize(const QSize &value);
|
||||||
|
|
||||||
|
QIODevice *getOutputDevice() const;
|
||||||
|
void setOutputDevice(QIODevice *value);
|
||||||
|
|
||||||
|
int getResolution() const;
|
||||||
|
void setResolution(int value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VObjEngine)
|
||||||
|
QTextStream *stream;
|
||||||
|
unsigned int globalPointsCount;
|
||||||
|
QIODevice *outputDevice;
|
||||||
|
del_point2d_t points[MAX_POINTS];
|
||||||
|
unsigned int planeCount;
|
||||||
|
QSize size;
|
||||||
|
int resolution;
|
||||||
|
QMatrix matrix;
|
||||||
|
|
||||||
|
QPolygonF MakePointsUnique(const QPolygonF &polygon)const;
|
||||||
|
qint64 Square(const QPolygonF &poly)const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VOBJENGINE_H
|
164
src/libs/vobj/vobjpaintdevice.cpp
Normal file
164
src/libs/vobj/vobjpaintdevice.cpp
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vobjpaintdevice.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 12, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "vobjpaintdevice.h"
|
||||||
|
#include "vobjengine.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VObjPaintDevice::VObjPaintDevice()
|
||||||
|
:QPaintDevice(), engine(new VObjEngine()), fileName(), owns_iodevice(1)
|
||||||
|
{
|
||||||
|
owns_iodevice = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VObjPaintDevice::~VObjPaintDevice()
|
||||||
|
{
|
||||||
|
if (owns_iodevice)
|
||||||
|
{
|
||||||
|
delete engine->getOutputDevice();
|
||||||
|
}
|
||||||
|
delete engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPaintEngine *VObjPaintDevice::paintEngine() const
|
||||||
|
{
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VObjPaintDevice::getFileName() const
|
||||||
|
{
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjPaintDevice::setFileName(const QString &value)
|
||||||
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VObjPaintDevice::setFileName(), cannot set file name while OBJ is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owns_iodevice)
|
||||||
|
{
|
||||||
|
delete engine->getOutputDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
owns_iodevice = true;
|
||||||
|
|
||||||
|
fileName = value;
|
||||||
|
QFile *file = new QFile(fileName);
|
||||||
|
engine->setOutputDevice(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QSize VObjPaintDevice::getSize()
|
||||||
|
{
|
||||||
|
return engine->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjPaintDevice::setSize(const QSize &size)
|
||||||
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VObjPaintDevice::setSize(), cannot set size while OBJ is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
engine->setSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QIODevice *VObjPaintDevice::getOutputDevice()
|
||||||
|
{
|
||||||
|
return engine->getOutputDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjPaintDevice::setOutputDevice(QIODevice *outputDevice)
|
||||||
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VObjPaintDevice::setOutputDevice(), cannot set output device while OBJ is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
owns_iodevice = false;
|
||||||
|
engine->setOutputDevice(outputDevice);
|
||||||
|
fileName = QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VObjPaintDevice::getResolution() const
|
||||||
|
{
|
||||||
|
return engine->getResolution();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VObjPaintDevice::setResolution(int dpi)
|
||||||
|
{
|
||||||
|
engine->setResolution(dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
|
||||||
|
{
|
||||||
|
switch (metric)
|
||||||
|
{
|
||||||
|
case QPaintDevice::PdmDepth:
|
||||||
|
return 32;
|
||||||
|
case QPaintDevice::PdmWidth:
|
||||||
|
return engine->getSize().width();
|
||||||
|
case QPaintDevice::PdmHeight:
|
||||||
|
return engine->getSize().height();
|
||||||
|
case QPaintDevice::PdmDpiX:
|
||||||
|
return engine->getResolution();
|
||||||
|
case QPaintDevice::PdmDpiY:
|
||||||
|
return engine->getResolution();
|
||||||
|
case QPaintDevice::PdmHeightMM:
|
||||||
|
return qRound(engine->getSize().height() * 25.4 / engine->getResolution());
|
||||||
|
case QPaintDevice::PdmWidthMM:
|
||||||
|
return qRound(engine->getSize().width() * 25.4 / engine->getResolution());
|
||||||
|
case QPaintDevice::PdmNumColors:
|
||||||
|
return 0xffffffff;
|
||||||
|
case QPaintDevice::PdmPhysicalDpiX:
|
||||||
|
return engine->getResolution();
|
||||||
|
case QPaintDevice::PdmPhysicalDpiY:
|
||||||
|
return engine->getResolution();
|
||||||
|
default:
|
||||||
|
qWarning("VObjPaintDevice::metric(), unhandled metric %d\n", metric);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
66
src/libs/vobj/vobjpaintdevice.h
Normal file
66
src/libs/vobj/vobjpaintdevice.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vobjpaintdevice.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 12, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina 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 General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VOBJPAINTDEVICE_H
|
||||||
|
#define VOBJPAINTDEVICE_H
|
||||||
|
|
||||||
|
#include <QPaintDevice>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class VObjEngine;
|
||||||
|
class QIODevice;
|
||||||
|
|
||||||
|
class VObjPaintDevice : public QPaintDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VObjPaintDevice();
|
||||||
|
virtual ~VObjPaintDevice();
|
||||||
|
virtual QPaintEngine *paintEngine() const;
|
||||||
|
|
||||||
|
QString getFileName() const;
|
||||||
|
void setFileName(const QString &value);
|
||||||
|
|
||||||
|
QSize getSize();
|
||||||
|
void setSize(const QSize &size);
|
||||||
|
|
||||||
|
QIODevice *getOutputDevice();
|
||||||
|
void setOutputDevice(QIODevice *outputDevice);
|
||||||
|
|
||||||
|
int getResolution() const;
|
||||||
|
void setResolution(int dpi);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int metric(PaintDeviceMetric metric) const;
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VObjPaintDevice)
|
||||||
|
VObjEngine *engine;
|
||||||
|
QString fileName;
|
||||||
|
uint owns_iodevice;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VOBJPAINTDEVICE_H
|
Loading…
Reference in New Issue
Block a user