Compare commits

...

3 Commits

Author SHA1 Message Date
90cf3a06db Merge branch 'main' of http://192.168.2.198:3000/huahaiyan/PlotterHMI
# Conflicts:
#	datafile/view/drawdata.h
#	mainwindow.cpp
2024-03-26 08:58:06 +08:00
42e10f6b15 20240326
1、增加马克间距;
2、完善dxf解析;
2024-03-26 08:54:57 +08:00
80684daf9b 20240322
1、完善dxf解析
2024-03-22 15:58:53 +08:00
27 changed files with 872 additions and 586 deletions

5
.gitignore vendored
View File

@ -2,3 +2,8 @@
*.user.* *.user.*
boost/ boost/
spline_library/ spline_library/
*.stash
*.sdf
*.vcxproj
*.filters
rccs/

View File

@ -179,7 +179,7 @@
<context> <context>
<name>ImportHPGL</name> <name>ImportHPGL</name>
<message> <message>
<location filename="datafile/hpgl/importhpgl.cpp" line="1816"/> <location filename="datafile/hpgl/importhpgl.cpp" line="1965"/>
<source>Encrypted file parsing error!</source> <source>Encrypted file parsing error!</source>
<translation></translation> <translation></translation>
</message> </message>
@ -269,21 +269,19 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="350"/>
<location filename="mainwindow.ui" line="465"/> <location filename="mainwindow.ui" line="465"/>
<source>Start</source> <source>Start</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="355"/>
<location filename="mainwindow.ui" line="477"/> <location filename="mainwindow.ui" line="477"/>
<source>Pause</source> <source>Pause</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="360"/> <location filename="mainwindow.ui" line="360"/>
<location filename="mainwindow.cpp" line="823"/> <location filename="mainwindow.cpp" line="764"/>
<location filename="mainwindow.cpp" line="853"/> <location filename="mainwindow.cpp" line="794"/>
<source>Delete</source> <source>Delete</source>
<translation></translation> <translation></translation>
</message> </message>
@ -390,6 +388,7 @@
<message> <message>
<location filename="mainwindow.ui" line="489"/> <location filename="mainwindow.ui" line="489"/>
<source>DrawingSetting</source> <source>DrawingSetting</source>
<extracomment></extracomment>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
@ -408,233 +407,255 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="149"/> <location filename="mainwindow.cpp" line="71"/>
<location filename="mainwindow.cpp" line="923"/> <location filename="mainwindow.cpp" line="162"/>
<location filename="mainwindow.cpp" line="931"/> <location filename="mainwindow.cpp" line="873"/>
<location filename="mainwindow.cpp" line="956"/> <location filename="mainwindow.cpp" line="880"/>
<location filename="mainwindow.cpp" line="1369"/> <location filename="mainwindow.cpp" line="903"/>
<location filename="mainwindow.cpp" line="1378"/> <location filename="mainwindow.cpp" line="1280"/>
<location filename="mainwindow.cpp" line="1501"/> <location filename="mainwindow.cpp" line="1289"/>
<location filename="mainwindow.cpp" line="1510"/> <location filename="mainwindow.cpp" line="1420"/>
<location filename="mainwindow.cpp" line="1561"/> <location filename="mainwindow.cpp" line="1429"/>
<location filename="mainwindow.cpp" line="1649"/> <location filename="mainwindow.cpp" line="1481"/>
<location filename="mainwindow.cpp" line="1518"/>
<location filename="mainwindow.cpp" line="1604"/>
<source>Prompt</source> <source>Prompt</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="150"/> <location filename="mainwindow.cpp" line="163"/>
<source>Printing this file, it cannot be moved!</source> <source>Printing this file, it cannot be moved!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="393"/> <location filename="mainwindow.cpp" line="362"/>
<location filename="mainwindow.cpp" line="455"/> <location filename="mainwindow.cpp" line="424"/>
<source>Connnecting...</source> <source>Connnecting...</source>
<translation>...</translation> <translation>...</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="397"/> <location filename="mainwindow.cpp" line="366"/>
<location filename="mainwindow.cpp" line="459"/> <location filename="mainwindow.cpp" line="428"/>
<source>Connected</source> <source>Connected</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="401"/> <location filename="mainwindow.cpp" line="370"/>
<location filename="mainwindow.cpp" line="422"/> <location filename="mainwindow.cpp" line="391"/>
<location filename="mainwindow.cpp" line="452"/> <location filename="mainwindow.cpp" line="421"/>
<source>NotConnected</source> <source>NotConnected</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="428"/> <location filename="mainwindow.cpp" line="311"/>
<location filename="mainwindow.cpp" line="466"/> <location filename="mainwindow.cpp" line="397"/>
<location filename="mainwindow.cpp" line="435"/>
<location filename="mainwindow.cpp" line="1108"/>
<source>Idle</source> <source>Idle</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="432"/> <location filename="mainwindow.cpp" line="72"/>
<location filename="mainwindow.cpp" line="470"/> <source>Do you want to exit the program?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="319"/>
<location filename="mainwindow.cpp" line="1156"/>
<source>Pause print</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="401"/>
<location filename="mainwindow.cpp" line="439"/>
<location filename="mainwindow.cpp" line="1112"/>
<source>Working</source> <source>Working</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="539"/> <location filename="mainwindow.cpp" line="512"/>
<location filename="mainwindow.cpp" line="712"/> <location filename="mainwindow.cpp" line="698"/>
<location filename="mainwindow.cpp" line="1057"/> <location filename="mainwindow.cpp" line="961"/>
<location filename="mainwindow.cpp" line="1148"/>
<source>Waitting</source> <source>Waitting</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="543"/> <location filename="mainwindow.cpp" line="516"/>
<location filename="mainwindow.cpp" line="716"/> <location filename="mainwindow.cpp" line="702"/>
<location filename="mainwindow.cpp" line="1196"/> <location filename="mainwindow.cpp" line="1152"/>
<source>Printting</source> <source>Printting</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="622"/> <location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="1331"/> <location filename="mainwindow.cpp" line="1238"/>
<source>FileName</source> <source>FileName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="622"/> <location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="1331"/> <location filename="mainwindow.cpp" line="1238"/>
<source>Length</source> <source>Length</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="622"/> <location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="1331"/> <location filename="mainwindow.cpp" line="1238"/>
<source>Width</source> <source>Width</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>Printed</source> <source>Printed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>Progress</source> <source>Progress</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>Numbers</source> <source>Numbers</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>State</source> <source>State</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>FilePath</source> <source>FilePath</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>StartPoint</source> <source>StartPoint</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McName</source> <source>McName</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McIp</source> <source>McIp</source>
<translation>IP</translation> <translation>IP</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McConState</source> <source>McConState</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McState</source> <source>McState</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McProgress</source> <source>McProgress</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="819"/> <location filename="mainwindow.cpp" line="760"/>
<source>Print preview</source> <source>Print preview</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="820"/> <location filename="mainwindow.cpp" line="761"/>
<source>Number of modified print</source> <source>Number of modified print</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="821"/> <location filename="mainwindow.cpp" line="762"/>
<source>Modify the starting print point</source> <source>Modify the starting print point</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="822"/> <location filename="mainwindow.cpp" line="763"/>
<source>View print information</source> <source>View print information</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="924"/> <location filename="mainwindow.cpp" line="881"/>
<source>Do you want to delete this drawing?</source> <source>Do you want to delete this drawing?</source>
<translation>?</translation> <translation>?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="932"/> <location filename="mainwindow.cpp" line="874"/>
<source>Printing this file, it cannot be deleted!</source> <source>Printing this file, it cannot be deleted!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="957"/> <location filename="mainwindow.cpp" line="904"/>
<source>After deletion, the machine cannot be controlled. Do you want to delete this machine?</source> <source>After deletion, the machine cannot be controlled. Do you want to delete this machine?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1192"/> <location filename="mainwindow.cpp" line="1160"/>
<source>Complete</source> <source>Complete</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1370"/> <location filename="mainwindow.cpp" line="1281"/>
<location filename="mainwindow.cpp" line="1502"/> <location filename="mainwindow.cpp" line="1421"/>
<source>Please select a machine!</source> <source>Please select a machine!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1379"/> <location filename="mainwindow.cpp" line="1290"/>
<location filename="mainwindow.cpp" line="1511"/> <location filename="mainwindow.cpp" line="1430"/>
<source>Loading file, please wait!</source> <source>Loading file, please wait!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1392"/> <location filename="mainwindow.cpp" line="1300"/>
<location filename="mainwindow.cpp" line="1524"/> <location filename="mainwindow.cpp" line="1440"/>
<source>Open File Dialog</source> <source>Open File Dialog</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1394"/> <location filename="mainwindow.cpp" line="1302"/>
<source>File(*.plt *.dxf)</source> <source>File(*.plt *.dxf)</source>
<translation>(*.plt *.dxf)</translation> <translation>(*.plt *.dxf)</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1526"/> <location filename="mainwindow.cpp" line="1442"/>
<source>Image File(*.png *.bmp *.jpg)</source> <source>Image File(*.png *.bmp *.jpg)</source>
<translation>(*.png *.bmp *.jpg)</translation> <translation>(*.png *.bmp *.jpg)</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1562"/> <location filename="mainwindow.cpp" line="1482"/>
<source>Please select the machine you want to set the directory!</source> <source>Please select the machine you want to set the directory!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1574"/> <location filename="mainwindow.cpp" line="1494"/>
<source>Select Folder</source> <source>Select Folder</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1650"/> <location filename="mainwindow.cpp" line="1519"/>
<source>Do you want to start printing on all machines?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1605"/>
<source>The maximum number of connections has been reached and cannot be added again!</source> <source>The maximum number of connections has been reached and cannot be added again!</source>
<translation></translation> <translation></translation>
</message> </message>
@ -934,7 +955,7 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="printinfodialog.cpp" line="78"/> <location filename="printinfodialog.cpp" line="80"/>
<source>piece</source> <source>piece</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1033,12 +1054,12 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="printviewwindow.cpp" line="106"/> <location filename="printviewwindow.cpp" line="111"/>
<source>Prompt</source> <source>Prompt</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="printviewwindow.cpp" line="107"/> <location filename="printviewwindow.cpp" line="112"/>
<source>Unreasonable value input!</source> <source>Unreasonable value input!</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@ -88,6 +88,10 @@ QList<QVector3D> DxfHelper::expandPolygon(QList<QVector3D> polygon, float expand
bool DxfHelper::generateDxf(const QString &fileName) bool DxfHelper::generateDxf(const QString &fileName)
{ {
//获取引用块集合
QList<std::string> blockNameList;
//getDxfReferenceBlocks(fileName,blockNameList);
// currentPos = QPointF(QRandomGenerator::global()->bounded(9999.99), QRandomGenerator::global()->bounded(9999.99)); // currentPos = QPointF(QRandomGenerator::global()->bounded(9999.99), QRandomGenerator::global()->bounded(9999.99));
currentPos = QPointF(9999.99, 9999.99); currentPos = QPointF(9999.99, 9999.99);
vertexIndex = 0; vertexIndex = 0;
@ -95,60 +99,64 @@ bool DxfHelper::generateDxf(const QString &fileName)
dxfPaths.clear(); dxfPaths.clear();
DxfReader dxfReader(fileName); DxfReader dxfReader(fileName);
for(auto d: dxfReader.dxfText) { QList<BlockDatas> blockDataList = dxfReader.getBlockDatas();
//qDebug() << "text data:" << d.text.c_str() << d.angle << d.style.c_str() << d.height; BlockDatas blockData;
//扫描判断哪个块的数据最多,其他块的数据全部不显示,只显示数据最多的块
for (int i = 0; i < blockDataList.size(); i++)
{
if(blockNameList.size() == 0)
{
blockData.dxfLines.append(blockDataList[i].dxfLines);
//blockData.dxfText.append(blockDataList[i].dxfText);
blockData.dxfArcs.append(blockDataList[i].dxfArcs);
blockData.dxfCircles.append(blockDataList[i].dxfCircles);
blockData.dxfEllipses.append(blockDataList[i].dxfEllipses);
blockData.dxfPolylines.append(blockDataList[i].dxfPolylines);
blockData.dxfPoints.append(blockDataList[i].dxfPoints);
blockData.dxfSplines.append(blockDataList[i].dxfSplines);
blockData.dxfVertexs.append(blockDataList[i].dxfVertexs);
}
else
{
if(blockNameList.contains(blockDataList[i].blockName) == true)
{
blockData.dxfLines.append(blockDataList[i].dxfLines);
//blockData.dxfText.append(blockDataList[i].dxfText);
blockData.dxfArcs.append(blockDataList[i].dxfArcs);
blockData.dxfCircles.append(blockDataList[i].dxfCircles);
blockData.dxfEllipses.append(blockDataList[i].dxfEllipses);
blockData.dxfPolylines.append(blockDataList[i].dxfPolylines);
blockData.dxfPoints.append(blockDataList[i].dxfPoints);
blockData.dxfSplines.append(blockDataList[i].dxfSplines);
blockData.dxfVertexs.append(blockDataList[i].dxfVertexs);
}
}
} }
for(auto d: dxfReader.dxfLinetypes) { for(auto d: blockData.dxfText)
//qDebug() << "linetypes data:" << d.name.c_str() << d.flags << d.pattern << d.description.c_str() << d.patternLength << d.numberOfDashes; {
qDebug() << "text data:" << d.text.c_str() << d.angle << d.style.c_str() << d.height;
}
for(auto d: dxfReader.dxfLinetypes)
{
qDebug() << "linetypes data:" << d.name.c_str() << d.flags << d.pattern << d.description.c_str() << d.patternLength << d.numberOfDashes;
} }
QVector<QPointF> linepath; QVector<QPointF> linepath;
for(auto d: dxfReader.dxfLines) { for(auto d: blockData.dxfLines)
{
//qDebug() << "line data:" << d.x1 << d.y1 << d.z1 << "," << d.x2 << d.y2 << d.z2; //qDebug() << "line data:" << d.x1 << d.y1 << d.z1 << "," << d.x2 << d.y2 << d.z2;
if(currentPos!=QPointF(d.x1, d.y1)) { linepath.append(QPointF(d.x1, d.y1));
if(!linepath.isEmpty()) { linepath.append(QPointF(d.x2, d.y2));
QList<QVector3D> linelist;
foreach(auto point, linepath) linelist.append(QVector3D(point));
linepath.clear();
linelist = expandPolygon(linelist, expandOffset);
foreach(QVector3D point, linelist) {
double x = point.x();
double y = point.y();
linepath.append(QPointF(x, y));
currentPos = QPointF(x, y);
}
dxfPaths.append(linepath);
linepath.clear();
}
linepath.append(QPointF(d.x1, d.y1));
linepath.append(QPointF(d.x2, d.y2));
currentPos = QPointF(d.x2, d.y2);
} else {
linepath.append(QPointF(d.x2, d.y2));
currentPos = QPointF(d.x2, d.y2);
}
}
if(!linepath.isEmpty()) {
QList<QVector3D> linelist;
foreach(auto point, linepath) linelist.append(QVector3D(point));
linepath.clear();
linelist = expandPolygon(linelist, expandOffset);
foreach(QVector3D point, linelist) {
double x = point.x();
double y = point.y();
linepath.append(QPointF(x, y));
currentPos = QPointF(x, y);
}
dxfPaths.append(linepath); dxfPaths.append(linepath);
linepath.clear(); linepath.clear();
} }
for(auto d: blockData.dxfArcs)
for(auto d: dxfReader.dxfArcs) { {
//qDebug() << "arcs data:" << d.cx << d.cy << d.cz << d.angle1 << d.angle2 << d.radius; //qDebug() << "arcs data:" << d.cx << d.cy << d.cz << d.angle1 << d.angle2 << d.radius;
double cx = d.cx; double cx = d.cx;
double cy = d.cy; double cy = d.cy;
// double cz = d.cz; // double cz = d.cz;
@ -158,7 +166,6 @@ bool DxfHelper::generateDxf(const QString &fileName)
radius = radius + expandOffset; radius = radius + expandOffset;
QPainterPath path; QPainterPath path;
double startXPos = cx + cos(abs(angle1)*M_PI/180)*radius; double startXPos = cx + cos(abs(angle1)*M_PI/180)*radius;
double startYPos = cy + sin(abs(angle1)*M_PI/180)*radius; double startYPos = cy + sin(abs(angle1)*M_PI/180)*radius;
@ -187,10 +194,10 @@ bool DxfHelper::generateDxf(const QString &fileName)
// dxfPathList.append(path); // dxfPathList.append(path);
} }
for(auto d: dxfReader.dxfCircles) { for(auto d: blockData.dxfCircles)
{
//qDebug() << "circle data:" << d.cx << d.cy << d.cz << d.radius; //qDebug() << "circle data:" << d.cx << d.cy << d.cz << d.radius;
double cx = d.cx; double cx = d.cx;
double cy = d.cy; double cy = d.cy;
// double cz = d.cz; // double cz = d.cz;
@ -198,7 +205,6 @@ bool DxfHelper::generateDxf(const QString &fileName)
radius = radius + expandOffset; radius = radius + expandOffset;
QPainterPath path; QPainterPath path;
path.moveTo(cx+radius, cy); path.moveTo(cx+radius, cy);
path.arcTo(cx-radius, cy-radius, 2*radius, 2*radius, 0, 360); path.arcTo(cx-radius, cy-radius, 2*radius, 2*radius, 0, 360);
@ -212,10 +218,11 @@ bool DxfHelper::generateDxf(const QString &fileName)
currentPos=QPointF(x, y); currentPos=QPointF(x, y);
} }
dxfPaths.append(circlepath); dxfPaths.append(circlepath);
// dxfPathList.append(path);
} }
for(auto d: dxfReader.dxfEllipses) { // 起点角度要×ratio for(auto d: blockData.dxfEllipses)
{
// 起点角度要×ratio
//qDebug() << "ellipses data:" << d.cx << d.cy << d.cz << d.mx << d.my << d.mz << d.ratio << d.angle1 << d.angle2; //qDebug() << "ellipses data:" << d.cx << d.cy << d.cz << d.mx << d.my << d.mz << d.ratio << d.angle1 << d.angle2;
double cx = d.cx; double cx = d.cx;
@ -228,7 +235,6 @@ bool DxfHelper::generateDxf(const QString &fileName)
double angle1 = d.angle1; double angle1 = d.angle1;
double angle2 = d.angle2; double angle2 = d.angle2;
double rab = sqrt((cx- mx)*(cx - mx) +(cy - my)*(cy - my)); double rab = sqrt((cx- mx)*(cx - mx) +(cy - my)*(cy - my));
double resy = (expandOffset*(my-cy))/rab + my; double resy = (expandOffset*(my-cy))/rab + my;
double resx = (expandOffset*(mx-cx))/rab + mx; double resx = (expandOffset*(mx-cx))/rab + mx;
@ -236,7 +242,6 @@ bool DxfHelper::generateDxf(const QString &fileName)
mx = resx; mx = resx;
my = resy; my = resy;
QPainterPath path; QPainterPath path;
double angle_1 = angle1; double angle_1 = angle1;
double angle_2 = angle2; double angle_2 = angle2;
@ -285,7 +290,8 @@ bool DxfHelper::generateDxf(const QString &fileName)
path.arcTo(c_x-rx, c_y-ry, 2*rx, 2*ry, angleStart, anglePassed); path.arcTo(c_x-rx, c_y-ry, 2*rx, 2*ry, angleStart, anglePassed);
QVector<QPointF> ellipsepath; QVector<QPointF> ellipsepath;
for(double i = 0; i <= 1; i += 0.003) { // TODO: 步长随图片大小调整 for(double i = 0; i <= 1; i += 0.003)
{ // TODO: 步长随图片大小调整
QPointF point = path.pointAtPercent(i); QPointF point = path.pointAtPercent(i);
double x = point.x(); double x = point.x();
double y = point.y(); double y = point.y();
@ -293,18 +299,18 @@ bool DxfHelper::generateDxf(const QString &fileName)
currentPos=QPointF(x, y); currentPos=QPointF(x, y);
} }
dxfPaths.append(ellipsepath); dxfPaths.append(ellipsepath);
// dxfPathList.append(path);
} }
for(auto d: dxfReader.dxfPolylines) { for(auto d: blockData.dxfPolylines)
{
//qDebug() << "polylines data:" << d.m << d.n << d.flags << d.number << d.elevation; //qDebug() << "polylines data:" << d.m << d.n << d.flags << d.number << d.elevation;
QList<QVector3D> pointlist; QList<QVector3D> pointlist;
QVector<QPointF> path; QVector<QPointF> path;
for(unsigned int i = 0; i < d.number; i++) { for(unsigned int i = 0; i < d.number; i++) {
double x = dxfReader.dxfVertexs.at(vertexIndex).x; double x = blockData.dxfVertexs.at(vertexIndex).x;
double y = dxfReader.dxfVertexs.at(vertexIndex).y; double y = blockData.dxfVertexs.at(vertexIndex).y;
double z = dxfReader.dxfVertexs.at(vertexIndex).z; double z = blockData.dxfVertexs.at(vertexIndex).z;
pointlist.append(QVector3D(x, y, z)); pointlist.append(QVector3D(x, y, z));
vertexIndex++; vertexIndex++;
} }
@ -317,7 +323,7 @@ bool DxfHelper::generateDxf(const QString &fileName)
currentPos = QPointF(x, y); currentPos = QPointF(x, y);
} }
if(d.flags) { if(d.flags && pointlist.size() > 0) {
double x = pointlist.first().x(); double x = pointlist.first().x();
double y = pointlist.first().y(); double y = pointlist.first().y();
path.append(QPointF(x, y)); path.append(QPointF(x, y));
@ -326,11 +332,50 @@ bool DxfHelper::generateDxf(const QString &fileName)
dxfPaths.append(path); dxfPaths.append(path);
} }
// for(auto d: dxfReader.dxfVertexs) { QVector<QPointF> path;
// qDebug() << "vertexs data:" << d.x << d.y << d.z << d.bulge; for(int i = 0; i < blockData.dxfVertexs.size(); i++)
{
QPointF point;
//qDebug() << "vertexs data:" << d.x << d.y << d.z << d.bulge;
point.setX(blockData.dxfVertexs.at(i).x);
point.setY(blockData.dxfVertexs.at(i).y);
path.append(point);
if(path.size() == 2)
{
// if(i+1 < blockData.dxfVertexs.size())
// {
// QPointF point1;
// //qDebug() << "vertexs data:" << d.x << d.y << d.z << d.bulge;
// point1.setX(blockData.dxfVertexs.at(i+1).x);
// point1.setY(blockData.dxfVertexs.at(i+1).y);
// if(point1 != point)
// {
// path.append(point1);
// }
// }
dxfPaths.append(path);
path.clear();
}
}
// for(auto d: blockData.dxfVertexs)
// {
// QPointF point;
// //qDebug() << "vertexs data:" << d.x << d.y << d.z << d.bulge;
// point.setX(d.x);
// point.setY(d.y);
// path.append(point);
// if(path.size() == 2)
// {
// dxfPaths.append(path);
// path.clear();
// }
// } // }
for(auto d: dxfReader.dxfPoints) { for(auto d: blockData.dxfPoints)
{
//qDebug() << "points data:" << d.x << d.y << d.z; //qDebug() << "points data:" << d.x << d.y << d.z;
QVector<QPointF> path; QVector<QPointF> path;
path.append(QPointF(d.x, d.y)); path.append(QPointF(d.x, d.y));
@ -338,32 +383,34 @@ bool DxfHelper::generateDxf(const QString &fileName)
currentPos = QPointF(d.x, d.y); currentPos = QPointF(d.x, d.y);
} }
for(auto d: dxfReader.dxfSplines) { // for(auto d: blockData.dxfSplines)
// {
//qDebug() << "splines data:" << d.nFit << d.flags << d.degree << d.nKnots << d.nControl << d.tangentEndX << d.tangentEndY << d.tangentEndZ << d.tangentStartX << d.tangentStartY << d.tangentStartZ; //qDebug() << "splines data:" << d.nFit << d.flags << d.degree << d.nKnots << d.nControl << d.tangentEndX << d.tangentEndY << d.tangentEndZ << d.tangentStartX << d.tangentStartY << d.tangentStartZ;
std::vector<QVector2D> pointList; // std::vector<QVector2D> pointList;
for(unsigned int i = 0; i < d.nControl; i++) { // for(unsigned int i = 0; i < d.nControl; i++)
int x = dxfReader.dxfControlPoints.at(controlIndex).x; // {
int y = dxfReader.dxfControlPoints.at(controlIndex).y; // int x = blockData.dxfControlPoints.at(controlIndex).x;
pointList.push_back(QVector2D(x, y)); // int y = blockData.dxfControlPoints.at(controlIndex).y;
currentPos = QPointF(x, y); // pointList.push_back(QVector2D(x, y));
controlIndex++; // currentPos = QPointF(x, y);
} // controlIndex++;
// }
QList<QVector3D> templist; // QList<QVector3D> templist;
foreach(auto point, pointList) templist.append(point); // foreach(auto point, pointList) templist.append(point);
templist = expandPolygon(templist, expandOffset); // templist = expandPolygon(templist, expandOffset);
QVector<QVector2D> inputList; // QVector<QVector2D> inputList;
foreach(auto point, templist) inputList.append(point.toVector2D()); // foreach(auto point, templist) inputList.append(point.toVector2D());
inputList.push_front(inputList.first()); // inputList.push_front(inputList.first());
inputList.push_back(inputList.back()); // inputList.push_back(inputList.back());
// std::vector<QVector2D> finalList(inputList.begin(), inputList.end()); // std::vector<QVector2D> finalList(inputList.begin(), inputList.end());
// SplineHelper splineHelper(finalList, TypeCubicBSpline); // SplineHelper splineHelper(finalList, TypeCubicBSpline);
// auto splinePath = splineHelper.getSplinePath(); // auto splinePath = splineHelper.getSplinePath();
// dxfPaths.append(splinePath); // dxfPaths.append(splinePath);
} // }
// for(auto d: dxfReader.dxfControlPoints) { // for(auto d: dxfReader.dxfControlPoints) {
// qDebug() << "control points data:" << d.w << d.x << d.y << d.z; // qDebug() << "control points data:" << d.w << d.x << d.y << d.z;
@ -425,6 +472,23 @@ void DxfHelper::matchDXFSize()
QImage DxfHelper::generateDXFImage() QImage DxfHelper::generateDXFImage()
{ {
// //放大数据
// QVector<QVector<QPointF>> dxfPathscp;
// foreach (QVector<QPointF> path, dxfPaths)
// {
// QVector<QPointF> pathcp;
// for(int i = 0; i < path.length(); i++)
// {
// QPointF point = path.at(i);
// double x = point.x()*10;
// double y = point.y()*10;
// pathcp.append(QPointF(x,y));
// }
// dxfPathscp.append(pathcp);
// }
// dxfPaths.clear();
// dxfPaths = dxfPathscp;
matchDXFSize(); matchDXFSize();
double minx = dxfBorderList.at(0); double minx = dxfBorderList.at(0);
double miny = dxfBorderList.at(1); double miny = dxfBorderList.at(1);
@ -464,6 +528,82 @@ QList<double> DxfHelper::getDxfBorderList() const
return dxfBorderList; return dxfBorderList;
} }
bool DxfHelper::getDxfReferenceBlocks(const QString &fileName, QList<std::string> &blockNameList)
{
blockNameList.clear();
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Failed to open file:" << fileName;
return false;
}
int addFlag = 0;
int blockFlag = 0;
int getFlag = 0;
int endFlag = 0;
QTextStream in(&file);
while (!in.atEnd())
{
std::string line = in.readLine().remove(QRegExp("\\s")).toStdString();
// 处理每一行数据
if(line == "AcDbBlockReference")//块被引用的标志
{
addFlag = 1;
continue;
}
if(addFlag == 1)
{
if(line == "AcDbBlockBegin")//块开始标志
{
blockFlag = 1;
endFlag = 0;
continue;
}
if(blockFlag == 1)
{
if(line == "2")//下一行为块名称
{
getFlag = 1;
continue;
}
if(getFlag == 1)//块名称
{
if(blockNameList.contains(line) == false)
//if(!line.empty() && line[0] != '*')
{
blockNameList.append(line);
}
getFlag = 0;
continue;
}
}
if(line == "AcDbBlockEnd")//块结束标志
{
blockFlag = 0;
endFlag = 1;
continue;
}
}
}
if(endFlag == 0 && addFlag == 1)
{
if(blockNameList.size() > 0)
{
blockNameList.removeLast();
}
}
file.close();
return true;
}
QSize DxfHelper::getImageSize() const QSize DxfHelper::getImageSize() const
{ {
return imageSize; return imageSize;

View File

@ -91,7 +91,10 @@ public:
QList<QPainterPath> getDxfPathList() const; QList<QPainterPath> getDxfPathList() const;
QSize getImageSize() const; QSize getImageSize() const;
QList<double> getDxfBorderList() const; QList<double> getDxfBorderList() const;
private: private:
bool getDxfReferenceBlocks(const QString &fileName,QList<std::string> &blockNameList);
QPointF currentPos; QPointF currentPos;
unsigned int vertexIndex = 0; unsigned int vertexIndex = 0;
unsigned int controlIndex = 0; unsigned int controlIndex = 0;

View File

@ -36,21 +36,11 @@
#pragma once #pragma once
#endif // _MSC_VER > 1000 #endif // _MSC_VER > 1000
//#if defined(__OS2__)||defined(__EMX__) #if defined(__OS2__)||defined(__EMX__)
//#define strcasecmp(s,t) stricmp(s,t) #define strcasecmp(s,t) stricmp(s,t)
//#endif
//#if defined(_WIN32)
//#define strcasecmp(s,t) _stricmp(s,t)
//#endif
#ifdef _WIN32
#undef M_PI
#define M_PI 3.14159265358979323846
//#pragma warning(disable : 4800)
#endif #endif
#ifndef M_PI #ifndef M_PI
#define M_PI 3.1415926535897932384626433832795 #define M_PI 3.1415926535897932384626433832795
#endif #endif
@ -501,7 +491,7 @@ const double dxfColors[][3] = {
// Flags // Flags
#define DL_OPEN_PLINE 0x00 #define DL_OPEN_PLINE 0x00
#define DL_CLOSED_PLINE 0x01 #define DL_CLOSED_PLINE 0x01
#define DL_POLYLINE3D 0x80 #define DL_POLYLINE3D 0x08
#define DL_PFACE_MESH 0x40 #define DL_PFACE_MESH 0x40
#define DL_PGON_MESH 0x10 #define DL_PGON_MESH 0x10
// Vertices follow entity, required in POLYLINES // Vertices follow entity, required in POLYLINES

View File

@ -82,7 +82,7 @@ public:
virtual void addDimDiametric(const DL_DimensionData&, virtual void addDimDiametric(const DL_DimensionData&,
const DL_DimDiametricData&) {} const DL_DimDiametricData&) {}
virtual void addDimAngular(const DL_DimensionData&, virtual void addDimAngular(const DL_DimensionData&,
const DL_DimAngularData&) {} const DL_DimAngular2LData&) {}
virtual void addDimAngular3P(const DL_DimensionData&, virtual void addDimAngular3P(const DL_DimensionData&,
const DL_DimAngular3PData&) {} const DL_DimAngular3PData&) {}
virtual void addDimOrdinate(const DL_DimensionData&, virtual void addDimOrdinate(const DL_DimensionData&,

View File

@ -191,7 +191,7 @@ public:
* Called for every angular dimension (2 lines version) entity. * Called for every angular dimension (2 lines version) entity.
*/ */
virtual void addDimAngular(const DL_DimensionData& data, virtual void addDimAngular(const DL_DimensionData& data,
const DL_DimAngularData& edata) = 0; const DL_DimAngular2LData& edata) = 0;
/** /**
* Called for every angular dimension (3 points version) entity. * Called for every angular dimension (3 points version) entity.

View File

@ -129,14 +129,14 @@ bool DL_Dxf::in(const std::string& file, DL_CreationInterface* creationInterface
/** /**
* Reads a DXF file from an existing stream. * Reads a DXF file from an existing stream.
* *
* @param stream The string stream. * @param stream The input stream.
* @param creationInterface * @param creationInterface
* Pointer to the class which takes care of the entities in the file. * Pointer to the class which takes care of the entities in the file.
* *
* @retval true If \p file could be opened. * @retval true If \p file could be opened.
* @retval false If \p file could not be opened. * @retval false If \p file could not be opened.
*/ */
bool DL_Dxf::in(std::stringstream& stream, bool DL_Dxf::in(std::istream& stream,
DL_CreationInterface* creationInterface) { DL_CreationInterface* creationInterface) {
if (stream.good()) { if (stream.good()) {
@ -193,9 +193,9 @@ bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface) {
/** /**
* Same as above but for stringstreams. * Same as above but for input streams.
*/ */
bool DL_Dxf::readDxfGroups(std::stringstream& stream, bool DL_Dxf::readDxfGroups(std::istream& stream,
DL_CreationInterface* creationInterface) { DL_CreationInterface* creationInterface) {
static int line = 1; static int line = 1;
@ -263,10 +263,10 @@ bool DL_Dxf::getStrippedLine(std::string& s, unsigned int size, FILE *fp, bool s
/** /**
* Same as above but for stringstreams. * Same as above but for input streams.
*/ */
bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size, bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size,
std::stringstream& stream, bool stripSpace) { std::istream& stream, bool stripSpace) {
if (!stream.eof()) { if (!stream.eof()) {
// Only the useful part of the line // Only the useful part of the line
@ -925,8 +925,6 @@ void DL_Dxf::endBlock(DL_CreationInterface* creationInterface) {
creationInterface->endBlock(); creationInterface->endBlock();
} }
void DL_Dxf::addTextStyle(DL_CreationInterface* creationInterface) { void DL_Dxf::addTextStyle(DL_CreationInterface* creationInterface) {
std::string name = getStringValue(2, ""); std::string name = getStringValue(2, "");
if (name.length()==0) { if (name.length()==0) {
@ -979,8 +977,7 @@ void DL_Dxf::addLine(DL_CreationInterface* creationInterface) {
getRealValue(11, 0.0), getRealValue(11, 0.0),
getRealValue(21, 0.0), getRealValue(21, 0.0),
getRealValue(31, 0.0)); getRealValue(31, 0.0));
creationInterface->addLine(d);
creationInterface->addLine(d);
} }
/** /**
@ -1448,10 +1445,10 @@ bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* /*creationInterface*/) {
} }
if (groupCode<=30) { if (groupCode<=30) {
if (vertexIndex>=0 && vertexIndex<maxVertices) { if (vertexIndex>=0 && vertexIndex<maxVertices && vertexIndex>=0) {
vertices[4*vertexIndex + (groupCode/10-1)] = toReal(groupValue); vertices[4*vertexIndex + (groupCode/10-1)] = toReal(groupValue);
} }
} else if (groupCode==42 && vertexIndex<maxVertices) { } else if (groupCode==42 && vertexIndex<maxVertices && vertexIndex>=0) {
vertices[4*vertexIndex + 3] = toReal(groupValue); vertices[4*vertexIndex + 3] = toReal(groupValue);
} }
return true; return true;
@ -1735,7 +1732,7 @@ void DL_Dxf::addAttribute(DL_CreationInterface* creationInterface) {
*/ */
DL_DimensionData DL_Dxf::getDimData() { DL_DimensionData DL_Dxf::getDimData() {
// generic dimension data: // generic dimension data:
return DL_DimensionData( DL_DimensionData ret(
// def point // def point
getRealValue(10, 0.0), getRealValue(10, 0.0),
getRealValue(20, 0.0), getRealValue(20, 0.0),
@ -1758,6 +1755,9 @@ DL_DimensionData DL_Dxf::getDimData() {
getStringValue(3, ""), getStringValue(3, ""),
// angle // angle
getRealValue(53, 0.0)); getRealValue(53, 0.0));
ret.arrow1Flipped = getIntValue(74, 0)==1;
ret.arrow2Flipped = getIntValue(75, 0)==1;
return ret;
} }
@ -1852,7 +1852,7 @@ void DL_Dxf::addDimAngular(DL_CreationInterface* creationInterface) {
DL_DimensionData d = getDimData(); DL_DimensionData d = getDimData();
// angular dimension: // angular dimension:
DL_DimAngularData da( DL_DimAngular2LData da(
// definition point 1 // definition point 1
getRealValue(13, 0.0), getRealValue(13, 0.0),
getRealValue(23, 0.0), getRealValue(23, 0.0),
@ -2505,7 +2505,6 @@ void DL_Dxf::writeVertex(DL_WriterA& dw,
if (version==DL_VERSION_2000) { if (version==DL_VERSION_2000) {
dw.dxfReal(10, data.x); dw.dxfReal(10, data.x);
dw.dxfReal(20, data.y); dw.dxfReal(20, data.y);
dw.dxfReal(30, data.z);
if (fabs(data.bulge)>1.0e-10) { if (fabs(data.bulge)>1.0e-10) {
dw.dxfReal(42, data.bulge); dw.dxfReal(42, data.bulge);
} }
@ -2964,10 +2963,18 @@ void DL_Dxf::writeDimStyleOverrides(DL_WriterA& dw,
dw.dxfString(1001, "ACAD"); dw.dxfString(1001, "ACAD");
dw.dxfString(1000, "DSTYLE"); dw.dxfString(1000, "DSTYLE");
dw.dxfString(1002, "{"); dw.dxfString(1002, "{");
if (data.type&128) {
// custom text position:
dw.dxfInt(1070, 279);
dw.dxfInt(1070, 2);
}
dw.dxfInt(1070, 144); dw.dxfInt(1070, 144);
dw.dxfReal(1040, data.linearFactor); dw.dxfReal(1040, data.linearFactor);
dw.dxfInt(1070,40); dw.dxfInt(1070,40);
dw.dxfReal(1040, data.dimScale); dw.dxfReal(1040, data.dimScale);
dw.dxfString(1002, "}"); dw.dxfString(1002, "}");
} }
} }
@ -3008,6 +3015,8 @@ void DL_Dxf::writeDimAligned(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
dw.dxfInt(74, data.arrow1Flipped);
dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3069,6 +3078,8 @@ void DL_Dxf::writeDimLinear(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
dw.dxfInt(74, data.arrow1Flipped);
dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3136,6 +3147,8 @@ void DL_Dxf::writeDimRadial(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
dw.dxfInt(74, data.arrow1Flipped);
//dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3195,6 +3208,8 @@ void DL_Dxf::writeDimDiametric(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
dw.dxfInt(74, data.arrow1Flipped);
dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3227,9 +3242,9 @@ void DL_Dxf::writeDimDiametric(DL_WriterA& dw,
* @param data Specific angular dimension data from the file * @param data Specific angular dimension data from the file
* @param attrib Attributes * @param attrib Attributes
*/ */
void DL_Dxf::writeDimAngular(DL_WriterA& dw, void DL_Dxf::writeDimAngular2L(DL_WriterA& dw,
const DL_DimensionData& data, const DL_DimensionData& data,
const DL_DimAngularData& edata, const DL_DimAngular2LData& edata,
const DL_Attributes& attrib) { const DL_Attributes& attrib) {
dw.entity("DIMENSION"); dw.entity("DIMENSION");
@ -3254,6 +3269,8 @@ void DL_Dxf::writeDimAngular(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
dw.dxfInt(74, data.arrow1Flipped);
dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3321,6 +3338,8 @@ void DL_Dxf::writeDimAngular3P(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
dw.dxfInt(74, data.arrow1Flipped);
dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3390,6 +3409,8 @@ void DL_Dxf::writeDimOrdinate(DL_WriterA& dw,
if (version>DL_VERSION_R12) { if (version>DL_VERSION_R12) {
dw.dxfInt(71, data.attachmentPoint); dw.dxfInt(71, data.attachmentPoint);
dw.dxfInt(72, data.lineSpacingStyle); // opt dw.dxfInt(72, data.lineSpacingStyle); // opt
//dw.dxfInt(74, data.arrow1Flipped);
//dw.dxfInt(75, data.arrow2Flipped);
dw.dxfReal(41, data.lineSpacingFactor); // opt dw.dxfReal(41, data.lineSpacingFactor); // opt
} }
@ -3460,6 +3481,18 @@ void DL_Dxf::writeLeaderVertex(DL_WriterA& dw,
} }
} }
void DL_Dxf::writeLeaderEnd(DL_WriterA& dw,
const DL_LeaderData& data) {
if (version==DL_VERSION_2000) {
dw.dxfString(1001, "ACAD");
dw.dxfString(1000, "DSTYLE");
dw.dxfString(1002, "{");
dw.dxfInt(1070,40);
dw.dxfReal(1040, data.dimScale);
dw.dxfString(1002, "}");
}
}
/** /**
@ -3664,7 +3697,7 @@ void DL_Dxf::writeHatchEdge(DL_WriterA& dw,
* *
* @return IMAGEDEF handle. Needed for the IMAGEDEF counterpart. * @return IMAGEDEF handle. Needed for the IMAGEDEF counterpart.
*/ */
int DL_Dxf::writeImage(DL_WriterA& dw, unsigned long DL_Dxf::writeImage(DL_WriterA& dw,
const DL_ImageData& data, const DL_ImageData& data,
const DL_Attributes& attrib) { const DL_Attributes& attrib) {
@ -3704,8 +3737,7 @@ int DL_Dxf::writeImage(DL_WriterA& dw,
dw.dxfReal(23, data.height); dw.dxfReal(23, data.height);
// handle of IMAGEDEF object // handle of IMAGEDEF object
int handle = dw.incHandle(); unsigned long handle = dw.handle(340);
dw.dxfHex(340, handle);
// flags // flags
dw.dxfInt(70, 15); dw.dxfInt(70, 15);
@ -4162,7 +4194,7 @@ void DL_Dxf::writeUcs(DL_WriterA& dw) {
*/ */
void DL_Dxf::writeDimStyle(DL_WriterA& dw, void DL_Dxf::writeDimStyle(DL_WriterA& dw,
double dimasz, double dimexe, double dimexo, double dimasz, double dimexe, double dimexo,
double dimgap, double dimtxt) { double dimgap, double dimtxt, int dimtad, bool dimtih) {
dw.dxfString( 0, "TABLE"); dw.dxfString( 0, "TABLE");
dw.dxfString( 2, "DIMSTYLE"); dw.dxfString( 2, "DIMSTYLE");
@ -4212,13 +4244,15 @@ void DL_Dxf::writeDimStyle(DL_WriterA& dw,
dw.dxfInt( 71, 0); dw.dxfInt( 71, 0);
dw.dxfInt( 72, 0); dw.dxfInt( 72, 0);
} }
dw.dxfInt( 73, 0); // DIMTIH:
dw.dxfInt( 73, (int)dimtih);
dw.dxfInt( 74, 0); dw.dxfInt( 74, 0);
if (version==DL_VERSION_R12) { if (version==DL_VERSION_R12) {
dw.dxfInt( 75, 0); dw.dxfInt( 75, 0);
dw.dxfInt( 76, 0); dw.dxfInt( 76, 0);
} }
dw.dxfInt( 77, 1); // DIMTAD:
dw.dxfInt( 77, dimtad);
dw.dxfInt( 78, 8); dw.dxfInt( 78, 8);
dw.dxfReal(140, dimtxt); dw.dxfReal(140, dimtxt);
dw.dxfReal(141, 2.5); dw.dxfReal(141, 2.5);
@ -4353,7 +4387,6 @@ void DL_Dxf::writeObjects(DL_WriterA& dw, const std::string& appDictionaryName)
dw.dxfString( 0, "SECTION"); dw.dxfString( 0, "SECTION");
dw.dxfString( 2, "OBJECTS"); dw.dxfString( 2, "OBJECTS");
dw.dxfString( 0, "DICTIONARY"); dw.dxfString( 0, "DICTIONARY");
dw.dxfHex(5, 0xC); dw.dxfHex(5, 0xC);
dw.dxfString(100, "AcDbDictionary"); dw.dxfString(100, "AcDbDictionary");
@ -4703,12 +4736,9 @@ void DL_Dxf::writeAppDictionary(DL_WriterA& dw) {
dw.dxfInt(281, 1); dw.dxfInt(281, 1);
} }
int DL_Dxf::writeDictionaryEntry(DL_WriterA& dw, const std::string& name) { unsigned long DL_Dxf::writeDictionaryEntry(DL_WriterA& dw, const std::string& name) {
dw.dxfString( 3, name); dw.dxfString( 3, name);
int handle = dw.getNextHandle(); return dw.handle(350);
dw.dxfHex(350, handle);
dw.incHandle();
return handle;
} }
void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, int value) { void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, int value) {
@ -4774,427 +4804,427 @@ bool DL_Dxf::checkVariable(const char* var, DL_Codes::version version) {
return true; return true;
} else if (version==DL_VERSION_R12) { } else if (version==DL_VERSION_R12) {
// these are all the variables recognized by dxf r12: // these are all the variables recognized by dxf r12:
if (!strcmp(var, "$ACADVER")) { if (!strcmp(var, "ACADVER")) {
return true; return true;
} }
if (!strcmp(var, "$ACADVER")) { if (!strcmp(var, "ACADVER")) {
return true; return true;
} }
if (!strcmp(var, "$ANGBASE")) { if (!strcmp(var, "ANGBASE")) {
return true; return true;
} }
if (!strcmp(var, "$ANGDIR")) { if (!strcmp(var, "ANGDIR")) {
return true; return true;
} }
if (!strcmp(var, "$ATTDIA")) { if (!strcmp(var, "ATTDIA")) {
return true; return true;
} }
if (!strcmp(var, "$ATTMODE")) { if (!strcmp(var, "ATTMODE")) {
return true; return true;
} }
if (!strcmp(var, "$ATTREQ")) { if (!strcmp(var, "ATTREQ")) {
return true; return true;
} }
if (!strcmp(var, "$AUNITS")) { if (!strcmp(var, "AUNITS")) {
return true; return true;
} }
if (!strcmp(var, "$AUPREC")) { if (!strcmp(var, "AUPREC")) {
return true; return true;
} }
if (!strcmp(var, "$AXISMODE")) { if (!strcmp(var, "AXISMODE")) {
return true; return true;
} }
if (!strcmp(var, "$AXISUNIT")) { if (!strcmp(var, "AXISUNIT")) {
return true; return true;
} }
if (!strcmp(var, "$BLIPMODE")) { if (!strcmp(var, "BLIPMODE")) {
return true; return true;
} }
if (!strcmp(var, "$CECOLOR")) { if (!strcmp(var, "CECOLOR")) {
return true; return true;
} }
if (!strcmp(var, "$CELTYPE")) { if (!strcmp(var, "CELTYPE")) {
return true; return true;
} }
if (!strcmp(var, "$CHAMFERA")) { if (!strcmp(var, "CHAMFERA")) {
return true; return true;
} }
if (!strcmp(var, "$CHAMFERB")) { if (!strcmp(var, "CHAMFERB")) {
return true; return true;
} }
if (!strcmp(var, "$CLAYER")) { if (!strcmp(var, "CLAYER")) {
return true; return true;
} }
if (!strcmp(var, "$COORDS")) { if (!strcmp(var, "COORDS")) {
return true; return true;
} }
if (!strcmp(var, "$DIMALT")) { if (!strcmp(var, "DIMALT")) {
return true; return true;
} }
if (!strcmp(var, "$DIMALTD")) { if (!strcmp(var, "DIMALTD")) {
return true; return true;
} }
if (!strcmp(var, "$DIMALTF")) { if (!strcmp(var, "DIMALTF")) {
return true; return true;
} }
if (!strcmp(var, "$DIMAPOST")) { if (!strcmp(var, "DIMAPOST")) {
return true; return true;
} }
if (!strcmp(var, "$DIMASO")) { if (!strcmp(var, "DIMASO")) {
return true; return true;
} }
if (!strcmp(var, "$DIMASZ")) { if (!strcmp(var, "DIMASZ")) {
return true; return true;
} }
if (!strcmp(var, "$DIMBLK")) { if (!strcmp(var, "DIMBLK")) {
return true; return true;
} }
if (!strcmp(var, "$DIMBLK1")) { if (!strcmp(var, "DIMBLK1")) {
return true; return true;
} }
if (!strcmp(var, "$DIMBLK2")) { if (!strcmp(var, "DIMBLK2")) {
return true; return true;
} }
if (!strcmp(var, "$DIMCEN")) { if (!strcmp(var, "DIMCEN")) {
return true; return true;
} }
if (!strcmp(var, "$DIMCLRD")) { if (!strcmp(var, "DIMCLRD")) {
return true; return true;
} }
if (!strcmp(var, "$DIMCLRE")) { if (!strcmp(var, "DIMCLRE")) {
return true; return true;
} }
if (!strcmp(var, "$DIMCLRT")) { if (!strcmp(var, "DIMCLRT")) {
return true; return true;
} }
if (!strcmp(var, "$DIMDLE")) { if (!strcmp(var, "DIMDLE")) {
return true; return true;
} }
if (!strcmp(var, "$DIMDLI")) { if (!strcmp(var, "DIMDLI")) {
return true; return true;
} }
if (!strcmp(var, "$DIMEXE")) { if (!strcmp(var, "DIMEXE")) {
return true; return true;
} }
if (!strcmp(var, "$DIMEXO")) { if (!strcmp(var, "DIMEXO")) {
return true; return true;
} }
if (!strcmp(var, "$DIMGAP")) { if (!strcmp(var, "DIMGAP")) {
return true; return true;
} }
if (!strcmp(var, "$DIMLFAC")) { if (!strcmp(var, "DIMLFAC")) {
return true; return true;
} }
if (!strcmp(var, "$DIMLIM")) { if (!strcmp(var, "DIMLIM")) {
return true; return true;
} }
if (!strcmp(var, "$DIMPOST")) { if (!strcmp(var, "DIMPOST")) {
return true; return true;
} }
if (!strcmp(var, "$DIMRND")) { if (!strcmp(var, "DIMRND")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSAH")) { if (!strcmp(var, "DIMSAH")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSCALE")) { if (!strcmp(var, "DIMSCALE")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSE1")) { if (!strcmp(var, "DIMSE1")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSE2")) { if (!strcmp(var, "DIMSE2")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSHO")) { if (!strcmp(var, "DIMSHO")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSOXD")) { if (!strcmp(var, "DIMSOXD")) {
return true; return true;
} }
if (!strcmp(var, "$DIMSTYLE")) { if (!strcmp(var, "DIMSTYLE")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTAD")) { if (!strcmp(var, "DIMTAD")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTFAC")) { if (!strcmp(var, "DIMTFAC")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTIH")) { if (!strcmp(var, "DIMTIH")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTIX")) { if (!strcmp(var, "DIMTIX")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTM")) { if (!strcmp(var, "DIMTM")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTOFL")) { if (!strcmp(var, "DIMTOFL")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTOH")) { if (!strcmp(var, "DIMTOH")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTOL")) { if (!strcmp(var, "DIMTOL")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTP")) { if (!strcmp(var, "DIMTP")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTSZ")) { if (!strcmp(var, "DIMTSZ")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTVP")) { if (!strcmp(var, "DIMTVP")) {
return true; return true;
} }
if (!strcmp(var, "$DIMTXT")) { if (!strcmp(var, "DIMTXT")) {
return true; return true;
} }
if (!strcmp(var, "$DIMZIN")) { if (!strcmp(var, "DIMZIN")) {
return true; return true;
} }
if (!strcmp(var, "$DWGCODEPAGE")) { if (!strcmp(var, "DWGCODEPAGE")) {
return true; return true;
} }
if (!strcmp(var, "$DRAGMODE")) { if (!strcmp(var, "DRAGMODE")) {
return true; return true;
} }
if (!strcmp(var, "$ELEVATION")) { if (!strcmp(var, "ELEVATION")) {
return true; return true;
} }
if (!strcmp(var, "$EXTMAX")) { if (!strcmp(var, "EXTMAX")) {
return true; return true;
} }
if (!strcmp(var, "$EXTMIN")) { if (!strcmp(var, "EXTMIN")) {
return true; return true;
} }
if (!strcmp(var, "$FILLETRAD")) { if (!strcmp(var, "FILLETRAD")) {
return true; return true;
} }
if (!strcmp(var, "$FILLMODE")) { if (!strcmp(var, "FILLMODE")) {
return true; return true;
} }
if (!strcmp(var, "$HANDLING")) { if (!strcmp(var, "HANDLING")) {
return true; return true;
} }
if (!strcmp(var, "$HANDSEED")) { if (!strcmp(var, "HANDSEED")) {
return true; return true;
} }
if (!strcmp(var, "$INSBASE")) { if (!strcmp(var, "INSBASE")) {
return true; return true;
} }
if (!strcmp(var, "$LIMCHECK")) { if (!strcmp(var, "LIMCHECK")) {
return true; return true;
} }
if (!strcmp(var, "$LIMMAX")) { if (!strcmp(var, "LIMMAX")) {
return true; return true;
} }
if (!strcmp(var, "$LIMMIN")) { if (!strcmp(var, "LIMMIN")) {
return true; return true;
} }
if (!strcmp(var, "$LTSCALE")) { if (!strcmp(var, "LTSCALE")) {
return true; return true;
} }
if (!strcmp(var, "$LUNITS")) { if (!strcmp(var, "LUNITS")) {
return true; return true;
} }
if (!strcmp(var, "$LUPREC")) { if (!strcmp(var, "LUPREC")) {
return true; return true;
} }
if (!strcmp(var, "$MAXACTVP")) { if (!strcmp(var, "MAXACTVP")) {
return true; return true;
} }
if (!strcmp(var, "$MENU")) { if (!strcmp(var, "MENU")) {
return true; return true;
} }
if (!strcmp(var, "$MIRRTEXT")) { if (!strcmp(var, "MIRRTEXT")) {
return true; return true;
} }
if (!strcmp(var, "$ORTHOMODE")) { if (!strcmp(var, "ORTHOMODE")) {
return true; return true;
} }
if (!strcmp(var, "$OSMODE")) { if (!strcmp(var, "OSMODE")) {
return true; return true;
} }
if (!strcmp(var, "$PDMODE")) { if (!strcmp(var, "PDMODE")) {
return true; return true;
} }
if (!strcmp(var, "$PDSIZE")) { if (!strcmp(var, "PDSIZE")) {
return true; return true;
} }
if (!strcmp(var, "$PELEVATION")) { if (!strcmp(var, "PELEVATION")) {
return true; return true;
} }
if (!strcmp(var, "$PEXTMAX")) { if (!strcmp(var, "PEXTMAX")) {
return true; return true;
} }
if (!strcmp(var, "$PEXTMIN")) { if (!strcmp(var, "PEXTMIN")) {
return true; return true;
} }
if (!strcmp(var, "$PLIMCHECK")) { if (!strcmp(var, "PLIMCHECK")) {
return true; return true;
} }
if (!strcmp(var, "$PLIMMAX")) { if (!strcmp(var, "PLIMMAX")) {
return true; return true;
} }
if (!strcmp(var, "$PLIMMIN")) { if (!strcmp(var, "PLIMMIN")) {
return true; return true;
} }
if (!strcmp(var, "$PLINEGEN")) { if (!strcmp(var, "PLINEGEN")) {
return true; return true;
} }
if (!strcmp(var, "$PLINEWID")) { if (!strcmp(var, "PLINEWID")) {
return true; return true;
} }
if (!strcmp(var, "$PSLTSCALE")) { if (!strcmp(var, "PSLTSCALE")) {
return true; return true;
} }
if (!strcmp(var, "$PUCSNAME")) { if (!strcmp(var, "PUCSNAME")) {
return true; return true;
} }
if (!strcmp(var, "$PUCSORG")) { if (!strcmp(var, "PUCSORG")) {
return true; return true;
} }
if (!strcmp(var, "$PUCSXDIR")) { if (!strcmp(var, "PUCSXDIR")) {
return true; return true;
} }
if (!strcmp(var, "$PUCSYDIR")) { if (!strcmp(var, "PUCSYDIR")) {
return true; return true;
} }
if (!strcmp(var, "$QTEXTMODE")) { if (!strcmp(var, "QTEXTMODE")) {
return true; return true;
} }
if (!strcmp(var, "$REGENMODE")) { if (!strcmp(var, "REGENMODE")) {
return true; return true;
} }
if (!strcmp(var, "$SHADEDGE")) { if (!strcmp(var, "SHADEDGE")) {
return true; return true;
} }
if (!strcmp(var, "$SHADEDIF")) { if (!strcmp(var, "SHADEDIF")) {
return true; return true;
} }
if (!strcmp(var, "$SKETCHINC")) { if (!strcmp(var, "SKETCHINC")) {
return true; return true;
} }
if (!strcmp(var, "$SKPOLY")) { if (!strcmp(var, "SKPOLY")) {
return true; return true;
} }
if (!strcmp(var, "$SPLFRAME")) { if (!strcmp(var, "SPLFRAME")) {
return true; return true;
} }
if (!strcmp(var, "$SPLINESEGS")) { if (!strcmp(var, "SPLINESEGS")) {
return true; return true;
} }
if (!strcmp(var, "$SPLINETYPE")) { if (!strcmp(var, "SPLINETYPE")) {
return true; return true;
} }
if (!strcmp(var, "$SURFTAB1")) { if (!strcmp(var, "SURFTAB1")) {
return true; return true;
} }
if (!strcmp(var, "$SURFTAB2")) { if (!strcmp(var, "SURFTAB2")) {
return true; return true;
} }
if (!strcmp(var, "$SURFTYPE")) { if (!strcmp(var, "SURFTYPE")) {
return true; return true;
} }
if (!strcmp(var, "$SURFU")) { if (!strcmp(var, "SURFU")) {
return true; return true;
} }
if (!strcmp(var, "$SURFV")) { if (!strcmp(var, "SURFV")) {
return true; return true;
} }
if (!strcmp(var, "$TDCREATE")) { if (!strcmp(var, "TDCREATE")) {
return true; return true;
} }
if (!strcmp(var, "$TDINDWG")) { if (!strcmp(var, "TDINDWG")) {
return true; return true;
} }
if (!strcmp(var, "$TDUPDATE")) { if (!strcmp(var, "TDUPDATE")) {
return true; return true;
} }
if (!strcmp(var, "$TDUSRTIMER")) { if (!strcmp(var, "TDUSRTIMER")) {
return true; return true;
} }
if (!strcmp(var, "$TEXTSIZE")) { if (!strcmp(var, "TEXTSIZE")) {
return true; return true;
} }
if (!strcmp(var, "$TEXTSTYLE")) { if (!strcmp(var, "TEXTSTYLE")) {
return true; return true;
} }
if (!strcmp(var, "$THICKNESS")) { if (!strcmp(var, "THICKNESS")) {
return true; return true;
} }
if (!strcmp(var, "$TILEMODE")) { if (!strcmp(var, "TILEMODE")) {
return true; return true;
} }
if (!strcmp(var, "$TRACEWID")) { if (!strcmp(var, "TRACEWID")) {
return true; return true;
} }
if (!strcmp(var, "$UCSNAME")) { if (!strcmp(var, "UCSNAME")) {
return true; return true;
} }
if (!strcmp(var, "$UCSORG")) { if (!strcmp(var, "UCSORG")) {
return true; return true;
} }
if (!strcmp(var, "$UCSXDIR")) { if (!strcmp(var, "UCSXDIR")) {
return true; return true;
} }
if (!strcmp(var, "$UCSYDIR")) { if (!strcmp(var, "UCSYDIR")) {
return true; return true;
} }
if (!strcmp(var, "$UNITMODE")) { if (!strcmp(var, "UNITMODE")) {
return true; return true;
} }
if (!strcmp(var, "$USERI1")) { if (!strcmp(var, "USERI1")) {
return true; return true;
} }
if (!strcmp(var, "$USERR1")) { if (!strcmp(var, "USERR1")) {
return true; return true;
} }
if (!strcmp(var, "$USRTIMER")) { if (!strcmp(var, "USRTIMER")) {
return true; return true;
} }
if (!strcmp(var, "$VISRETAIN")) { if (!strcmp(var, "VISRETAIN")) {
return true; return true;
} }
if (!strcmp(var, "$WORLDVIEW")) { if (!strcmp(var, "WORLDVIEW")) {
return true; return true;
} }
if (!strcmp(var, "$FASTZOOM")) { if (!strcmp(var, "FASTZOOM")) {
return true; return true;
} }
if (!strcmp(var, "$GRIDMODE")) { if (!strcmp(var, "GRIDMODE")) {
return true; return true;
} }
if (!strcmp(var, "$GRIDUNIT")) { if (!strcmp(var, "GRIDUNIT")) {
return true; return true;
} }
if (!strcmp(var, "$SNAPANG")) { if (!strcmp(var, "SNAPANG")) {
return true; return true;
} }
if (!strcmp(var, "$SNAPBASE")) { if (!strcmp(var, "SNAPBASE")) {
return true; return true;
} }
if (!strcmp(var, "$SNAPISOPAIR")) { if (!strcmp(var, "SNAPISOPAIR")) {
return true; return true;
} }
if (!strcmp(var, "$SNAPMODE")) { if (!strcmp(var, "SNAPMODE")) {
return true; return true;
} }
if (!strcmp(var, "$SNAPSTYLE")) { if (!strcmp(var, "SNAPSTYLE")) {
return true; return true;
} }
if (!strcmp(var, "$SNAPUNIT")) { if (!strcmp(var, "SNAPUNIT")) {
return true; return true;
} }
if (!strcmp(var, "$VIEWCTR")) { if (!strcmp(var, "VIEWCTR")) {
return true; return true;
} }
if (!strcmp(var, "$VIEWDIR")) { if (!strcmp(var, "VIEWDIR")) {
return true; return true;
} }
if (!strcmp(var, "$VIEWSIZE")) { if (!strcmp(var, "VIEWSIZE")) {
return true; return true;
} }
return false; return false;

View File

@ -57,11 +57,11 @@ class DL_CreationInterface;
class DL_WriterA; class DL_WriterA;
#define DL_VERSION "3.17.0.0" #define DL_VERSION "3.26.4.0"
#define DL_VERSION_MAJOR 3 #define DL_VERSION_MAJOR 3
#define DL_VERSION_MINOR 17 #define DL_VERSION_MINOR 26
#define DL_VERSION_REV 0 #define DL_VERSION_REV 4
#define DL_VERSION_BUILD 0 #define DL_VERSION_BUILD 0
#define DL_UNKNOWN 0 #define DL_UNKNOWN 0
@ -131,12 +131,12 @@ public:
static bool getStrippedLine(std::string& s, unsigned int size, static bool getStrippedLine(std::string& s, unsigned int size,
FILE* stream, bool stripSpace = true); FILE* stream, bool stripSpace = true);
bool readDxfGroups(std::stringstream& stream, bool readDxfGroups(std::istream& stream,
DL_CreationInterface* creationInterface); DL_CreationInterface* creationInterface);
bool in(std::stringstream &stream, bool in(std::istream &stream,
DL_CreationInterface* creationInterface); DL_CreationInterface* creationInterface);
static bool getStrippedLine(std::string& s, unsigned int size, static bool getStrippedLine(std::string& s, unsigned int size,
std::stringstream& stream, bool stripSpace = true); std::istream& stream, bool stripSpace = true);
static bool stripWhiteSpace(char** s, bool stripSpaces = true); static bool stripWhiteSpace(char** s, bool stripSpaces = true);
@ -294,9 +294,9 @@ public:
const DL_DimensionData& data, const DL_DimensionData& data,
const DL_DimDiametricData& edata, const DL_DimDiametricData& edata,
const DL_Attributes& attrib); const DL_Attributes& attrib);
void writeDimAngular(DL_WriterA& dw, void writeDimAngular2L(DL_WriterA& dw,
const DL_DimensionData& data, const DL_DimensionData& data,
const DL_DimAngularData& edata, const DL_DimAngular2LData& edata,
const DL_Attributes& attrib); const DL_Attributes& attrib);
void writeDimAngular3P(DL_WriterA& dw, void writeDimAngular3P(DL_WriterA& dw,
const DL_DimensionData& data, const DL_DimensionData& data,
@ -311,6 +311,8 @@ public:
const DL_Attributes& attrib); const DL_Attributes& attrib);
void writeLeaderVertex(DL_WriterA& dw, void writeLeaderVertex(DL_WriterA& dw,
const DL_LeaderVertexData& data); const DL_LeaderVertexData& data);
void writeLeaderEnd(DL_WriterA& dw,
const DL_LeaderData& data);
void writeHatch1(DL_WriterA& dw, void writeHatch1(DL_WriterA& dw,
const DL_HatchData& data, const DL_HatchData& data,
const DL_Attributes& attrib); const DL_Attributes& attrib);
@ -324,7 +326,7 @@ public:
void writeHatchEdge(DL_WriterA& dw, void writeHatchEdge(DL_WriterA& dw,
const DL_HatchEdgeData& data); const DL_HatchEdgeData& data);
int writeImage(DL_WriterA& dw, unsigned long writeImage(DL_WriterA& dw,
const DL_ImageData& data, const DL_ImageData& data,
const DL_Attributes& attrib); const DL_Attributes& attrib);
@ -348,14 +350,15 @@ public:
void writeStyle(DL_WriterA& dw, const DL_StyleData& style); void writeStyle(DL_WriterA& dw, const DL_StyleData& style);
void writeView(DL_WriterA& dw); void writeView(DL_WriterA& dw);
void writeUcs(DL_WriterA& dw); void writeUcs(DL_WriterA& dw);
void writeDimStyle(DL_WriterA& dw, void writeDimStyle(DL_WriterA& dw,
double dimasz, double dimexe, double dimexo, double dimasz, double dimexe, double dimexo,
double dimgap, double dimtxt); double dimgap, double dimtxt,
int dimtad = 1, bool dimtih = false);
void writeBlockRecord(DL_WriterA& dw); void writeBlockRecord(DL_WriterA& dw);
void writeBlockRecord(DL_WriterA& dw, const std::string& name); void writeBlockRecord(DL_WriterA& dw, const std::string& name);
void writeObjects(DL_WriterA& dw, const std::string& appDictionaryName = ""); void writeObjects(DL_WriterA& dw, const std::string& appDictionaryName = "");
void writeAppDictionary(DL_WriterA& dw); void writeAppDictionary(DL_WriterA& dw);
int writeDictionaryEntry(DL_WriterA& dw, const std::string& name); unsigned long writeDictionaryEntry(DL_WriterA& dw, const std::string& name);
void writeXRecord(DL_WriterA& dw, int handle, int value); void writeXRecord(DL_WriterA& dw, int handle, int value);
void writeXRecord(DL_WriterA& dw, int handle, double value); void writeXRecord(DL_WriterA& dw, int handle, double value);
void writeXRecord(DL_WriterA& dw, int handle, bool value); void writeXRecord(DL_WriterA& dw, int handle, bool value);

View File

@ -156,7 +156,7 @@ struct DXFLIB_EXPORT DL_StyleData {
italic(false) { italic(false) {
} }
bool operator==(const DL_StyleData& other) { bool operator==(const DL_StyleData& other) const {
// ignore lastHeightUsed: // ignore lastHeightUsed:
return (name==other.name && return (name==other.name &&
flags==other.flags && flags==other.flags &&
@ -1090,6 +1090,8 @@ struct DXFLIB_EXPORT DL_DimensionData {
* Dimension scale (dimscale) style override. * Dimension scale (dimscale) style override.
*/ */
double dimScale; double dimScale;
bool arrow1Flipped;
bool arrow2Flipped;
}; };
@ -1238,12 +1240,12 @@ struct DXFLIB_EXPORT DL_DimDiametricData {
/** /**
* Angular Dimension Data. * Angular Dimension Data.
*/ */
struct DXFLIB_EXPORT DL_DimAngularData { struct DXFLIB_EXPORT DL_DimAngular2LData {
/** /**
* Constructor. * Constructor.
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_DimAngularData(double ddpx1, double ddpy1, double ddpz1, DL_DimAngular2LData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2, double ddpx2, double ddpy2, double ddpz2,
double ddpx3, double ddpy3, double ddpz3, double ddpx3, double ddpy3, double ddpz3,
double ddpx4, double ddpy4, double ddpz4) { double ddpx4, double ddpy4, double ddpz4) {
@ -1320,21 +1322,21 @@ struct DXFLIB_EXPORT DL_DimAngular3PData {
dpz3 = ddpz3; dpz3 = ddpz3;
} }
/*! X Coordinate of definition point 1. */ /*! X Coordinate of definition point 1 (extension line 1 end). */
double dpx1; double dpx1;
/*! Y Coordinate of definition point 1. */ /*! Y Coordinate of definition point 1. */
double dpy1; double dpy1;
/*! Z Coordinate of definition point 1. */ /*! Z Coordinate of definition point 1. */
double dpz1; double dpz1;
/*! X Coordinate of definition point 2. */ /*! X Coordinate of definition point 2 (extension line 2 end). */
double dpx2; double dpx2;
/*! Y Coordinate of definition point 2. */ /*! Y Coordinate of definition point 2. */
double dpy2; double dpy2;
/*! Z Coordinate of definition point 2. */ /*! Z Coordinate of definition point 2. */
double dpz2; double dpz2;
/*! X Coordinate of definition point 3. */ /*! X Coordinate of definition point 3 (center). */
double dpx3; double dpx3;
/*! Y Coordinate of definition point 3. */ /*! Y Coordinate of definition point 3. */
double dpy3; double dpy3;
@ -1395,23 +1397,25 @@ struct DXFLIB_EXPORT DL_LeaderData {
* Constructor. * Constructor.
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_LeaderData(int lArrowHeadFlag, DL_LeaderData(int arrowHeadFlag,
int lLeaderPathType, int leaderPathType,
int lLeaderCreationFlag, int leaderCreationFlag,
int lHooklineDirectionFlag, int hooklineDirectionFlag,
int lHooklineFlag, int hooklineFlag,
double lTextAnnotationHeight, double textAnnotationHeight,
double lTextAnnotationWidth, double textAnnotationWidth,
int lNumber) { int number,
double dimScale = 1.0) :
arrowHeadFlag(arrowHeadFlag),
leaderPathType(leaderPathType),
leaderCreationFlag(leaderCreationFlag),
hooklineDirectionFlag(hooklineDirectionFlag),
hooklineFlag(hooklineFlag),
textAnnotationHeight(textAnnotationHeight),
textAnnotationWidth(textAnnotationWidth),
number(number),
dimScale(dimScale) {
arrowHeadFlag = lArrowHeadFlag;
leaderPathType = lLeaderPathType;
leaderCreationFlag = lLeaderCreationFlag;
hooklineDirectionFlag = lHooklineDirectionFlag;
hooklineFlag = lHooklineFlag;
textAnnotationHeight = lTextAnnotationHeight;
textAnnotationWidth = lTextAnnotationWidth;
number = lNumber;
} }
/*! Arrow head flag (71). */ /*! Arrow head flag (71). */
@ -1430,6 +1434,8 @@ struct DXFLIB_EXPORT DL_LeaderData {
double textAnnotationWidth; double textAnnotationWidth;
/*! Number of vertices in leader (76). */ /*! Number of vertices in leader (76). */
int number; int number;
/*! Dimension scale (dimscale) style override. */
double dimScale;
}; };

View File

@ -36,6 +36,7 @@
#pragma once #pragma once
#endif // _MSC_VER > 1000 #endif // _MSC_VER > 1000
#include <cstring>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
@ -539,49 +540,6 @@ public:
return m_handle; return m_handle;
} }
/**
* Increases handle, so that the handle returned remains available.
*/
unsigned long incHandle() const {
return m_handle++;
}
/**
* Sets the handle of the model space. Entities refer to
* this handle.
*/
void setModelSpaceHandle(unsigned long h) {
modelSpaceHandle = h;
}
unsigned long getModelSpaceHandle() {
return modelSpaceHandle;
}
/**
* Sets the handle of the paper space. Some special blocks refer to
* this handle.
*/
void setPaperSpaceHandle(unsigned long h) {
paperSpaceHandle = h;
}
unsigned long getPaperSpaceHandle() {
return paperSpaceHandle;
}
/**
* Sets the handle of the paper space 0. Some special blocks refer to
* this handle.
*/
void setPaperSpace0Handle(unsigned long h) {
paperSpace0Handle = h;
}
unsigned long getPaperSpace0Handle() {
return paperSpace0Handle;
}
/** /**
* Must be overwritten by the implementing class to write a * Must be overwritten by the implementing class to write a
* real value to the file. * real value to the file.

View File

@ -1,79 +1,98 @@
#include "dxfreader.h" #include "dxfreader.h"
#include <QDebug> #include <QDebug>
DxfReader::DxfReader(const QString &fileName, QObject *parent) DxfReader::DxfReader(const QString &m_fileName, QObject *parent)
: QObject(parent) : QObject(parent)
, fileName(fileName) ,m_fileName(m_fileName)
{ {
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); //QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
m_blockDataList.clear();
m_blockData.blockId = 0;
initBlockDatas();
// 读取 dxf 文件 // 读取 dxf 文件
DL_Dxf *dxf = new DL_Dxf; DL_Dxf *dxf = new DL_Dxf;
if (!dxf->in(std::string(fileName.toLocal8Bit()), this)) { // if file open failed if (!dxf->in(std::string(m_fileName.toLocal8Bit()), this))
std::cerr << std::string(fileName.toLocal8Bit()) << " could not be opened.\n"; {
// if file open failed
std::cerr << std::string(m_fileName.toLocal8Bit()) << " could not be opened.\n";
return; return;
} }
delete dxf; else
dxf = nullptr; {
m_blockData.blockId++;
m_blockDataList.append(m_blockData);
initBlockDatas();
}
if(dxf != NULL)
{
delete dxf;
}
}
DxfReader::~DxfReader()
{
} }
void DxfReader::addText(const DL_TextData &data) void DxfReader::addText(const DL_TextData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfText << data; m_blockData.dxfText << data;
} }
void DxfReader::addLine(const DL_LineData &data) void DxfReader::addLine(const DL_LineData &data)
{ {
//qDebug() << Q_FUNC_INFO; m_blockData.dxfLines << data;
dxfLines << data;
} }
void DxfReader::addArc(const DL_ArcData &data) void DxfReader::addArc(const DL_ArcData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfArcs << data; m_blockData.dxfArcs << data;
} }
void DxfReader::addCircle(const DL_CircleData &data) void DxfReader::addCircle(const DL_CircleData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfCircles << data; m_blockData.dxfCircles << data;
} }
void DxfReader::addEllipse(const DL_EllipseData &data) void DxfReader::addEllipse(const DL_EllipseData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfEllipses << data; m_blockData.dxfEllipses << data;
} }
void DxfReader::addPolyline(const DL_PolylineData &data) void DxfReader::addPolyline(const DL_PolylineData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfPolylines << data; m_blockData.dxfPolylines << data;
} }
void DxfReader::addPoint(const DL_PointData &data) void DxfReader::addPoint(const DL_PointData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfPoints << data; m_blockData.dxfPoints << data;
} }
void DxfReader::addSpline(const DL_SplineData &data) void DxfReader::addSpline(const DL_SplineData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfSplines << data; m_blockData.dxfSplines << data;
} }
void DxfReader::addBlock(const DL_BlockData &data) void DxfReader::addBlock(const DL_BlockData &data)
{ {
//qDebug() << Q_FUNC_INFO;
dxfBlocks << data; dxfBlocks << data;
m_blockData.blockName = data.name;
m_blockData.blockId++;
} }
void DxfReader::endBlock() void DxfReader::endBlock()
{ {
m_blockDataList.append(m_blockData);
initBlockDatas();
} }
void DxfReader::addLayer(const DL_LayerData &data) void DxfReader::addLayer(const DL_LayerData &data)
@ -96,31 +115,31 @@ void DxfReader::addLinetypeDash(double length)
void DxfReader::addXLine(const DL_XLineData &data) void DxfReader::addXLine(const DL_XLineData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfXLines << data; m_blockData.dxfXLines << data;
} }
void DxfReader::addRay(const DL_RayData &data) void DxfReader::addRay(const DL_RayData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfRays << data; m_blockData.dxfRays << data;
} }
void DxfReader::addVertex(const DL_VertexData &data) void DxfReader::addVertex(const DL_VertexData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfVertexs << data; m_blockData.dxfVertexs << data;
} }
void DxfReader::addControlPoint(const DL_ControlPointData &data) void DxfReader::addControlPoint(const DL_ControlPointData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfControlPoints << data; m_blockData.dxfControlPoints << data;
} }
void DxfReader::addFitPoint(const DL_FitPointData &data) void DxfReader::addFitPoint(const DL_FitPointData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfFitPoints << data; m_blockData.dxfFitPoints << data;
} }
void DxfReader::addKnot(const DL_KnotData &data) void DxfReader::addKnot(const DL_KnotData &data)
@ -205,12 +224,12 @@ void DxfReader::addDimDiametric(const DL_DimensionData &data, const DL_DimDiamet
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
} }
void DxfReader::addDimAngular(const DL_DimensionData &data, const DL_DimAngularData &edata) //void DxfReader::addDimAngular(const DL_DimensionData &data, const DL_DimAngularData &edata)
{ //{
if(data.angle == 0){} // if(data.angle == 0){}
if(edata.dpx1 == 0){} // if(edata.dpx1 == 0){}
//qDebug() << Q_FUNC_INFO; // //qDebug() << Q_FUNC_INFO;
} //}
void DxfReader::addDimAngular3P(const DL_DimensionData &data, const DL_DimAngular3PData &edata) void DxfReader::addDimAngular3P(const DL_DimensionData &data, const DL_DimAngular3PData &edata)
{ {
@ -241,19 +260,19 @@ void DxfReader::addLeaderVertex(const DL_LeaderVertexData &data)
void DxfReader::addHatch(const DL_HatchData &data) void DxfReader::addHatch(const DL_HatchData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfHatchs << data; m_blockData.dxfHatchs << data;
} }
void DxfReader::addHatchLoop(const DL_HatchLoopData &data) void DxfReader::addHatchLoop(const DL_HatchLoopData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfHatchLoops << data; m_blockData.dxfHatchLoops << data;
} }
void DxfReader::addHatchEdge(const DL_HatchEdgeData &data) void DxfReader::addHatchEdge(const DL_HatchEdgeData &data)
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
dxfHatchEdges << data; m_blockData.dxfHatchEdges << data;
} }
void DxfReader::addImage(const DL_ImageData &data) void DxfReader::addImage(const DL_ImageData &data)
@ -377,3 +396,29 @@ void DxfReader::endSequence()
{ {
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
} }
QList<BlockDatas> DxfReader::getBlockDatas()
{
return m_blockDataList;
}
void DxfReader::initBlockDatas()
{
m_blockData.dxfArcs.clear();
m_blockData.dxfLines.clear();
m_blockData.dxfText.clear();
m_blockData.dxfArcs.clear();
m_blockData.dxfCircles.clear();
m_blockData.dxfEllipses.clear();
m_blockData.dxfPolylines.clear();
m_blockData.dxfPoints.clear();
m_blockData.dxfSplines.clear();
m_blockData.dxfVertexs.clear();
m_blockData.dxfXLines.clear();
m_blockData.dxfRays.clear();
m_blockData.dxfControlPoints.clear();
m_blockData.dxfFitPoints.clear();
m_blockData.dxfHatchs.clear();
m_blockData.dxfHatchLoops.clear();
m_blockData.dxfHatchEdges.clear();
}

View File

@ -8,6 +8,28 @@
#include <QMetaType> #include <QMetaType>
#include <QtCore/QList> #include <QtCore/QList>
typedef struct
{
int blockId;//块索引
std::string blockName;//块名称
QList<DL_LineData> dxfLines;
QList<DL_TextData> dxfText;
QList<DL_ArcData> dxfArcs;
QList<DL_CircleData> dxfCircles;
QList<DL_EllipseData> dxfEllipses;
QList<DL_PolylineData> dxfPolylines;
QList<DL_PointData> dxfPoints;
QList<DL_SplineData> dxfSplines;
QList<DL_VertexData> dxfVertexs;
QList<DL_XLineData> dxfXLines;
QList<DL_RayData> dxfRays;
QList<DL_ControlPointData> dxfControlPoints;
QList<DL_FitPointData> dxfFitPoints;
QList<DL_HatchData> dxfHatchs;
QList<DL_HatchLoopData> dxfHatchLoops;
QList<DL_HatchEdgeData> dxfHatchEdges;
} BlockDatas;
class DxfReader : public QObject, public DL_CreationAdapter class DxfReader : public QObject, public DL_CreationAdapter
{ {
Q_OBJECT Q_OBJECT
@ -16,6 +38,7 @@ public:
QString Text; QString Text;
}; };
explicit DxfReader(const QString &fileName, QObject *parent = nullptr); explicit DxfReader(const QString &fileName, QObject *parent = nullptr);
~DxfReader();
virtual void addText(const DL_TextData& data) override; virtual void addText(const DL_TextData& data) override;
virtual void addLine(const DL_LineData& data) override; virtual void addLine(const DL_LineData& data) override;
@ -49,7 +72,7 @@ public:
virtual void addDimLinear(const DL_DimensionData& data, const DL_DimLinearData& edata) override; virtual void addDimLinear(const DL_DimensionData& data, const DL_DimLinearData& edata) override;
virtual void addDimRadial(const DL_DimensionData& data, const DL_DimRadialData& edata) override; virtual void addDimRadial(const DL_DimensionData& data, const DL_DimRadialData& edata) override;
virtual void addDimDiametric(const DL_DimensionData& data, const DL_DimDiametricData& edata) override; virtual void addDimDiametric(const DL_DimensionData& data, const DL_DimDiametricData& edata) override;
virtual void addDimAngular(const DL_DimensionData& data, const DL_DimAngularData& edata) override; //virtual void addDimAngular(const DL_DimensionData& data, const DL_DimAngularData& edata) override;
virtual void addDimAngular3P(const DL_DimensionData& data, const DL_DimAngular3PData& edata) override; virtual void addDimAngular3P(const DL_DimensionData& data, const DL_DimAngular3PData& edata) override;
virtual void addDimOrdinate(const DL_DimensionData& data, const DL_DimOrdinateData& edata) override; virtual void addDimOrdinate(const DL_DimensionData& data, const DL_DimOrdinateData& edata) override;
virtual void addLeader(const DL_LeaderData &data) override; virtual void addLeader(const DL_LeaderData &data) override;
@ -82,29 +105,19 @@ public:
virtual void add3dFace(const DL_3dFaceData &data) override; virtual void add3dFace(const DL_3dFaceData &data) override;
virtual void addComment(const std::string &comment) override; virtual void addComment(const std::string &comment) override;
virtual void endSequence() override; virtual void endSequence() override;
QList<BlockDatas> getBlockDatas();
QList<DL_LineData> dxfLines;
QList<DL_TextData> dxfText;
QList<DL_ArcData> dxfArcs;
QList<DL_CircleData> dxfCircles;
QList<DL_EllipseData> dxfEllipses;
QList<DL_PolylineData> dxfPolylines;
QList<DL_PointData> dxfPoints;
QList<DL_SplineData> dxfSplines;
QList<DL_BlockData> dxfBlocks;
QList<DL_VertexData> dxfVertexs;
QList<DL_LayerData> dxfLayers; QList<DL_LayerData> dxfLayers;
QList<DL_LinetypeData> dxfLinetypes; QList<DL_LinetypeData> dxfLinetypes;
QList<DL_XLineData> dxfXLines; QList<DL_BlockData> dxfBlocks;
QList<DL_RayData> dxfRays;
QList<DL_ControlPointData> dxfControlPoints;
QList<DL_FitPointData> dxfFitPoints;
QList<DL_HatchData> dxfHatchs;
QList<DL_HatchLoopData> dxfHatchLoops;
QList<DL_HatchEdgeData> dxfHatchEdges;
private: private:
QString fileName; void initBlockDatas();
private:
QString m_fileName;
QList<BlockDatas> m_blockDataList;
BlockDatas m_blockData;
}; };

View File

@ -637,7 +637,7 @@ void ImportHPGL::AddPolylineToMarker()
//长度<0.2mm为钻孔 //长度<0.2mm为钻孔
CRPPolyline RPPolyline1; CRPPolyline RPPolyline1;
QPoint pt1,pt2; QPointF pt1,pt2;
CDrill drill; CDrill drill;
bool bIsdirll = false; bool bIsdirll = false;
@ -2401,7 +2401,7 @@ bool ImportHPGL::Write(QString strPathName,Marker *pMarker)
for (j = 0; j < iPointCount; j++) for (j = 0; j < iPointCount; j++)
{ {
QPoint pt = polyLine.m_listPoint.at(j); QPointF pt = polyLine.m_listPoint.at(j);
if (j == 0) if (j == 0)
{ {

View File

@ -213,7 +213,7 @@ protected:
QPen m_cutPen;//切割画笔 QPen m_cutPen;//切割画笔
QPen m_halfCutPen;//半透切割画笔 QPen m_halfCutPen;//半透切割画笔
QList <QPoint> m_listXY; //还没有确定抬落刀的坐标 QList <QPointF> m_listXY; //还没有确定抬落刀的坐标
//QPainterPath m_polylinePainterPath;//绘图路径-线段 //QPainterPath m_polylinePainterPath;//绘图路径-线段
unsigned char m_chTerminator;//标志终结符,除了NULL LF ESC及;十进制分别为0,5,27,59;外的所有字符默认为ETX 十进制3 unsigned char m_chTerminator;//标志终结符,除了NULL LF ESC及;十进制分别为0,5,27,59;外的所有字符默认为ETX 十进制3

View File

@ -47,9 +47,9 @@ void Marker::Initialize()
m_strProductCode = ""; m_strProductCode = "";
} }
QRect Marker::GetRect() QRectF Marker::GetRect()
{ {
QRect rect; QRectF rect;
CRPPolyline RPPolyline; CRPPolyline RPPolyline;
rect.setRect(0,0,0,0); rect.setRect(0,0,0,0);
@ -63,22 +63,22 @@ QRect Marker::GetRect()
} }
else if (RPPolyline.m_nDrawingType == 3) else if (RPPolyline.m_nDrawingType == 3)
{ {
rect |= QRect(RPPolyline.m_text.m_ptPostLU,RPPolyline.m_text.m_ptPostRD); rect |= QRectF(RPPolyline.m_text.m_ptPostLU,RPPolyline.m_text.m_ptPostRD);
} }
else if (RPPolyline.m_nDrawingType == 1) else if (RPPolyline.m_nDrawingType == 1)
{ {
rect |= QRect(RPPolyline.m_bitmapInfo.m_ptAbPostLU,RPPolyline.m_bitmapInfo.m_ptAbPostRD); rect |= QRectF(RPPolyline.m_bitmapInfo.m_ptAbPostLU,RPPolyline.m_bitmapInfo.m_ptAbPostRD);
} }
} }
return rect; return rect;
} }
QRect Marker::RectofPolyline(const QList<QPoint> &listPoint) QRectF Marker::RectofPolyline(const QList<QPointF> &listPoint)
{ {
if(listPoint.empty()) if(listPoint.empty())
{ {
return QRect(0,0,0,0); return QRectF(0,0,0,0);
} }
int iXMin = INT_MAX; int iXMin = INT_MAX;
int iXMax = INT_MIN; int iXMax = INT_MIN;
@ -115,7 +115,7 @@ QRect Marker::RectofPolyline(const QList<QPoint> &listPoint)
} }
} }
return QRect(QPoint(iXMin,iYMin),QPoint(iXMax,iYMax)); return QRectF(QPointF(iXMin,iYMin),QPointF(iXMax,iYMax));
} }

View File

@ -293,7 +293,7 @@ public:
class CDrill class CDrill
{ {
public: public:
QPoint m_pt;//冲孔的位置 QPointF m_pt;//冲孔的位置
int m_nDrillType;//冲孔类型 int m_nDrillType;//冲孔类型
int m_nAngle;//冲孔的角度(逆时针方向为正),单位0.01度 int m_nAngle;//冲孔的角度(逆时针方向为正),单位0.01度
@ -337,7 +337,7 @@ public:
CNotch m_notch; CNotch m_notch;
LineType m_lineType; LineType m_lineType;
QList<QPoint> m_listPoint; QList<QPointF> m_listPoint;
CRPPolyline() CRPPolyline()
{ {
@ -401,8 +401,8 @@ public:
Marker(const Marker &a); Marker(const Marker &a);
Marker operator=(const Marker &a); Marker operator=(const Marker &a);
void Initialize(); void Initialize();
QRect GetRect(); QRectF GetRect();
QRect RectofPolyline(const QList <QPoint> &listPoint); QRectF RectofPolyline(const QList <QPointF> &listPoint);
double m_iDPMM; //长度数据单位:m_iDPMM(每毫米点) double m_iDPMM; //长度数据单位:m_iDPMM(每毫米点)
QList <CRPPolyline> m_listPolyline; //切割的点链,单位:1/m_iDPMM mm, X向右为正Y向上为正 QList <CRPPolyline> m_listPolyline; //切割的点链,单位:1/m_iDPMM mm, X向右为正Y向上为正

View File

@ -4,7 +4,7 @@ CreatPictureStr creatPictureByData(Marker marker,int paperWidth,int butSpace,int
{ {
QPainterPath painterPath; QPainterPath painterPath;
CBitmapInfo bitmapInfo; CBitmapInfo bitmapInfo;
QRect rect = marker.GetRect(); QRectF rect = marker.GetRect();
int minX = rect.left(); int minX = rect.left();
int maxY = rect.bottom(); int maxY = rect.bottom();
int rectSize = 20;//20毫米-对接符矩形框大小 int rectSize = 20;//20毫米-对接符矩形框大小
@ -313,12 +313,26 @@ void creatMarkerDat(McFilesInfo &curFilesInfo, QString printDir, QString filePat
if(fileInfo.suffix().toUpper() == "DXF") if(fileInfo.suffix().toUpper() == "DXF")
{ {
curFilesInfo.m_fileType = TYPE_FILE;
DxfHelper dxfHelper; DxfHelper dxfHelper;
if(dxfHelper.generateDxf(filePath)) if(dxfHelper.generateDxf(filePath))
{ {
dxfHelper.getDxfPaths(); // 获取转换出来的dxf所有类型图形的点集 QList <CRPPolyline> polylineList;
QImage img = dxfHelper.generateDXFImage(); // 获取预览图像 CRPPolyline polyline;
img.save("D:\\1.png"); QVector<QVector<QPointF>> dxfPaths = dxfHelper.getDxfPaths(); // 获取转换出来的dxf所有类型图形的点集
//创建mark数据
for (int j = 0; j < dxfPaths.size(); j++)
{
polyline.m_listPoint.clear();
for(int i = 0; i < dxfPaths[j].length(); i++)
{
QPointF point = dxfPaths[j].at(i);
polyline.m_listPoint.append(point);
}
polylineList.append(polyline);
}
curFilesInfo.m_marker.m_listPolyline = polylineList;
curFilesInfo.m_fileRect = curFilesInfo.m_marker.GetRect();
} }
} }
else if(fileInfo.suffix().toUpper() == "PLT") else if(fileInfo.suffix().toUpper() == "PLT")

View File

@ -16,6 +16,10 @@ typedef struct
QPicture sendPic;//用于发送的picture画笔为所设置像素 QPicture sendPic;//用于发送的picture画笔为所设置像素
} CreatPictureStr; } CreatPictureStr;
<<<<<<< HEAD
=======
>>>>>>> 9f74511e69bc847a1a226ae630185c956827429c
//marker数据绘制路径纸宽对接符间距是否对接标志右边距笔宽 //marker数据绘制路径纸宽对接符间距是否对接标志右边距笔宽
CreatPictureStr creatPictureByData(Marker marker,int paperWidth,int butSpace,int rightSpace,int penWidth = 1); CreatPictureStr creatPictureByData(Marker marker,int paperWidth,int butSpace,int rightSpace,int penWidth = 1);
CreatPictureStr creatPictureByBmp(QPixmap pixmap,int paperWidth,int butSpace,int rightSpace,int penWidth = 1); CreatPictureStr creatPictureByBmp(QPixmap pixmap,int paperWidth,int butSpace,int rightSpace,int penWidth = 1);

View File

@ -179,7 +179,7 @@
<context> <context>
<name>ImportHPGL</name> <name>ImportHPGL</name>
<message> <message>
<location filename="datafile/hpgl/importhpgl.cpp" line="1816"/> <location filename="datafile/hpgl/importhpgl.cpp" line="1965"/>
<source>Encrypted file parsing error!</source> <source>Encrypted file parsing error!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -269,21 +269,19 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="350"/>
<location filename="mainwindow.ui" line="465"/> <location filename="mainwindow.ui" line="465"/>
<source>Start</source> <source>Start</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="355"/>
<location filename="mainwindow.ui" line="477"/> <location filename="mainwindow.ui" line="477"/>
<source>Pause</source> <source>Pause</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="360"/> <location filename="mainwindow.ui" line="360"/>
<location filename="mainwindow.cpp" line="823"/> <location filename="mainwindow.cpp" line="764"/>
<location filename="mainwindow.cpp" line="853"/> <location filename="mainwindow.cpp" line="794"/>
<source>Delete</source> <source>Delete</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -390,6 +388,7 @@
<message> <message>
<location filename="mainwindow.ui" line="489"/> <location filename="mainwindow.ui" line="489"/>
<source>DrawingSetting</source> <source>DrawingSetting</source>
<extracomment></extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -408,233 +407,255 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="149"/> <location filename="mainwindow.cpp" line="71"/>
<location filename="mainwindow.cpp" line="923"/> <location filename="mainwindow.cpp" line="162"/>
<location filename="mainwindow.cpp" line="931"/> <location filename="mainwindow.cpp" line="873"/>
<location filename="mainwindow.cpp" line="956"/> <location filename="mainwindow.cpp" line="880"/>
<location filename="mainwindow.cpp" line="1369"/> <location filename="mainwindow.cpp" line="903"/>
<location filename="mainwindow.cpp" line="1378"/> <location filename="mainwindow.cpp" line="1280"/>
<location filename="mainwindow.cpp" line="1501"/> <location filename="mainwindow.cpp" line="1289"/>
<location filename="mainwindow.cpp" line="1510"/> <location filename="mainwindow.cpp" line="1420"/>
<location filename="mainwindow.cpp" line="1561"/> <location filename="mainwindow.cpp" line="1429"/>
<location filename="mainwindow.cpp" line="1649"/> <location filename="mainwindow.cpp" line="1481"/>
<location filename="mainwindow.cpp" line="1518"/>
<location filename="mainwindow.cpp" line="1604"/>
<source>Prompt</source> <source>Prompt</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="150"/> <location filename="mainwindow.cpp" line="163"/>
<source>Printing this file, it cannot be moved!</source> <source>Printing this file, it cannot be moved!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="393"/> <location filename="mainwindow.cpp" line="362"/>
<location filename="mainwindow.cpp" line="455"/> <location filename="mainwindow.cpp" line="424"/>
<source>Connnecting...</source> <source>Connnecting...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="397"/> <location filename="mainwindow.cpp" line="366"/>
<location filename="mainwindow.cpp" line="459"/> <location filename="mainwindow.cpp" line="428"/>
<source>Connected</source> <source>Connected</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="401"/> <location filename="mainwindow.cpp" line="370"/>
<location filename="mainwindow.cpp" line="422"/> <location filename="mainwindow.cpp" line="391"/>
<location filename="mainwindow.cpp" line="452"/> <location filename="mainwindow.cpp" line="421"/>
<source>NotConnected</source> <source>NotConnected</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="428"/> <location filename="mainwindow.cpp" line="311"/>
<location filename="mainwindow.cpp" line="466"/> <location filename="mainwindow.cpp" line="397"/>
<location filename="mainwindow.cpp" line="435"/>
<location filename="mainwindow.cpp" line="1108"/>
<source>Idle</source> <source>Idle</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="432"/> <location filename="mainwindow.cpp" line="72"/>
<location filename="mainwindow.cpp" line="470"/> <source>Do you want to exit the program?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="319"/>
<location filename="mainwindow.cpp" line="1156"/>
<source>Pause print</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="401"/>
<location filename="mainwindow.cpp" line="439"/>
<location filename="mainwindow.cpp" line="1112"/>
<source>Working</source> <source>Working</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="539"/> <location filename="mainwindow.cpp" line="512"/>
<location filename="mainwindow.cpp" line="712"/> <location filename="mainwindow.cpp" line="698"/>
<location filename="mainwindow.cpp" line="1057"/> <location filename="mainwindow.cpp" line="961"/>
<location filename="mainwindow.cpp" line="1148"/>
<source>Waitting</source> <source>Waitting</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="543"/> <location filename="mainwindow.cpp" line="516"/>
<location filename="mainwindow.cpp" line="716"/> <location filename="mainwindow.cpp" line="702"/>
<location filename="mainwindow.cpp" line="1196"/> <location filename="mainwindow.cpp" line="1152"/>
<source>Printting</source> <source>Printting</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="622"/> <location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="1331"/> <location filename="mainwindow.cpp" line="1238"/>
<source>FileName</source> <source>FileName</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="622"/> <location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="1331"/> <location filename="mainwindow.cpp" line="1238"/>
<source>Length</source> <source>Length</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="622"/> <location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="1331"/> <location filename="mainwindow.cpp" line="1238"/>
<source>Width</source> <source>Width</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>Printed</source> <source>Printed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>Progress</source> <source>Progress</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>Numbers</source> <source>Numbers</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>State</source> <source>State</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>FilePath</source> <source>FilePath</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="623"/> <location filename="mainwindow.cpp" line="605"/>
<location filename="mainwindow.cpp" line="1332"/> <location filename="mainwindow.cpp" line="1239"/>
<source>StartPoint</source> <source>StartPoint</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McName</source> <source>McName</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McIp</source> <source>McIp</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McConState</source> <source>McConState</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McState</source> <source>McState</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="644"/> <location filename="mainwindow.cpp" line="626"/>
<location filename="mainwindow.cpp" line="1336"/> <location filename="mainwindow.cpp" line="1243"/>
<source>McProgress</source> <source>McProgress</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="819"/> <location filename="mainwindow.cpp" line="760"/>
<source>Print preview</source> <source>Print preview</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="820"/> <location filename="mainwindow.cpp" line="761"/>
<source>Number of modified print</source> <source>Number of modified print</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="821"/> <location filename="mainwindow.cpp" line="762"/>
<source>Modify the starting print point</source> <source>Modify the starting print point</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="822"/> <location filename="mainwindow.cpp" line="763"/>
<source>View print information</source> <source>View print information</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="924"/> <location filename="mainwindow.cpp" line="881"/>
<source>Do you want to delete this drawing?</source> <source>Do you want to delete this drawing?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="932"/> <location filename="mainwindow.cpp" line="874"/>
<source>Printing this file, it cannot be deleted!</source> <source>Printing this file, it cannot be deleted!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="957"/> <location filename="mainwindow.cpp" line="904"/>
<source>After deletion, the machine cannot be controlled. Do you want to delete this machine?</source> <source>After deletion, the machine cannot be controlled. Do you want to delete this machine?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1192"/> <location filename="mainwindow.cpp" line="1160"/>
<source>Complete</source> <source>Complete</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1370"/> <location filename="mainwindow.cpp" line="1281"/>
<location filename="mainwindow.cpp" line="1502"/> <location filename="mainwindow.cpp" line="1421"/>
<source>Please select a machine!</source> <source>Please select a machine!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1379"/> <location filename="mainwindow.cpp" line="1290"/>
<location filename="mainwindow.cpp" line="1511"/> <location filename="mainwindow.cpp" line="1430"/>
<source>Loading file, please wait!</source> <source>Loading file, please wait!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1392"/> <location filename="mainwindow.cpp" line="1300"/>
<location filename="mainwindow.cpp" line="1524"/> <location filename="mainwindow.cpp" line="1440"/>
<source>Open File Dialog</source> <source>Open File Dialog</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1394"/> <location filename="mainwindow.cpp" line="1302"/>
<source>File(*.plt *.dxf)</source> <source>File(*.plt *.dxf)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1526"/> <location filename="mainwindow.cpp" line="1442"/>
<source>Image File(*.png *.bmp *.jpg)</source> <source>Image File(*.png *.bmp *.jpg)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1562"/> <location filename="mainwindow.cpp" line="1482"/>
<source>Please select the machine you want to set the directory!</source> <source>Please select the machine you want to set the directory!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1574"/> <location filename="mainwindow.cpp" line="1494"/>
<source>Select Folder</source> <source>Select Folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1650"/> <location filename="mainwindow.cpp" line="1519"/>
<source>Do you want to start printing on all machines?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1605"/>
<source>The maximum number of connections has been reached and cannot be added again!</source> <source>The maximum number of connections has been reached and cannot be added again!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -934,7 +955,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="printinfodialog.cpp" line="78"/> <location filename="printinfodialog.cpp" line="80"/>
<source>piece</source> <source>piece</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1033,12 +1054,12 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="printviewwindow.cpp" line="106"/> <location filename="printviewwindow.cpp" line="111"/>
<source>Prompt</source> <source>Prompt</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="printviewwindow.cpp" line="107"/> <location filename="printviewwindow.cpp" line="112"/>
<source>Unreasonable value input!</source> <source>Unreasonable value input!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -15,6 +15,7 @@ CreatPrintBmp::CreatPrintBmp(QObject *parent) : QObject(parent)
m_moveFileIdx = -1;//上下移动打印文件索引 m_moveFileIdx = -1;//上下移动打印文件索引
m_moveDir = 0;//-1,上移 1下移 m_moveDir = 0;//-1,上移 1下移
m_rotateAngle = 0; m_rotateAngle = 0;
m_markSpace = 0;
m_autoDirFilesList.clear(); m_autoDirFilesList.clear();
} }
@ -169,6 +170,19 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int fileidx, int idx)
num += 1; num += 1;
} }
//计算每块位图的走纸距离
u32 paperDis = 0;
int moveOft = abs(offset)+PIXMAPWIDTH;
if(moveOft <= pic.width())
{
paperDis = ((double)PIXMAPWIDTH / MMPIXELY)*100;
}
else
{
u32 cLength = moveOft - (pic.width() - oft);
paperDis = ((double)(PIXMAPWIDTH-cLength) / MMPIXELY)*100 + m_markSpace*100;
}
QBitmap *pixmap = new QBitmap(PIXMAPWIDTH,height); QBitmap *pixmap = new QBitmap(PIXMAPWIDTH,height);
QPainter *pixPainter = new QPainter(); QPainter *pixPainter = new QPainter();
pixPainter->begin(pixmap); pixPainter->begin(pixmap);
@ -218,6 +232,11 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int fileidx, int idx)
return -1; return -1;
} }
QByteArray dat = bwBmp.getPrBmpDat(); QByteArray dat = bwBmp.getPrBmpDat();
//写入每块位图走纸距离
CompBmpHead *bmphead = new CompBmpHead;
memcpy((u8*)bmphead,(u8*)dat.data(),sizeof(CompBmpHead));
bmphead->segBitPaperDis = paperDis;
emit siSendDatToMc(dat); emit siSendDatToMc(dat);
m_mcPrintInfo->m_filesList[fileidx].m_curPrintBlock = cidx + 1; m_mcPrintInfo->m_filesList[fileidx].m_curPrintBlock = cidx + 1;
m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum = cidx; m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum = cidx;
@ -460,8 +479,9 @@ QString CreatPrintBmp::getSavePath()
return m_savePath; return m_savePath;
} }
void CreatPrintBmp::setMcPrintInfo(int fileIdx, McPrintInfo *printInfo) void CreatPrintBmp::setMcPrintInfo(int fileIdx,u32 markSpace,McPrintInfo *printInfo)
{ {
m_markSpace = markSpace;
m_mcPrintInfo = printInfo; m_mcPrintInfo = printInfo;
if(fileIdx < 0) if(fileIdx < 0)

View File

@ -45,6 +45,7 @@ private:
int m_moveFileIdx;//上下移动打印文件索引 int m_moveFileIdx;//上下移动打印文件索引
s16 m_moveDir;//-1,上移 1下移 s16 m_moveDir;//-1,上移 1下移
double m_rotateAngle; double m_rotateAngle;
u32 m_markSpace;//马克间距
QFileInfoList m_autoDirFilesList;//自动绘图目录中文件列表 QFileInfoList m_autoDirFilesList;//自动绘图目录中文件列表
@ -58,7 +59,7 @@ public:
void setPicture(QBitmap bitmap); void setPicture(QBitmap bitmap);
void setSavePath(QString path); void setSavePath(QString path);
QString getSavePath(); QString getSavePath();
void setMcPrintInfo(int fileIdx,McPrintInfo *printInfo);//设置机器信息 void setMcPrintInfo(int fileIdx,u32 markSpace,McPrintInfo *printInfo);//设置机器信息
void stopCreatPrintDat();//停止生成打印数据 void stopCreatPrintDat();//停止生成打印数据
void setDeleteFile(McPrintInfo *printInfo, int fileIdx);//删除文件 void setDeleteFile(McPrintInfo *printInfo, int fileIdx);//删除文件
void setMoveFile(McPrintInfo *printInfo, int fileIdx, int dir = -1);//上下移动文件 void setMoveFile(McPrintInfo *printInfo, int fileIdx, int dir = -1);//上下移动文件

View File

@ -122,9 +122,11 @@ typedef struct
u8 compType[4]; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩(分段压缩); u8 compType[4]; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩(分段压缩);
u32 compSegOffset[4]; // 分段数据起始位置 u32 compSegOffset[4]; // 分段数据起始位置
#if (1)
// 60 // 60
u8 rev[128-2-60]; // 保留 u32 segBitPaperDis; // 每段位图走纸距离0.01mm
#if (1)
//64
u8 rev[128-2-64]; // 保留
#else #else
// 保存原图中BMP头文件(算法测试用) // 保存原图中BMP头文件(算法测试用)
// 60 // 60

View File

@ -411,11 +411,11 @@ void Machine::invalidateWorkFile(int idx)
setMcStatus(MC_INVALID_FILE, idx); setMcStatus(MC_INVALID_FILE, idx);
} }
void Machine::creatPrintDat(int fileIdx,int setFlag) void Machine::creatPrintDat(int fileIdx,u32 markSpace,int setFlag)
{ {
if(setFlag == 1) if(setFlag == 1)
{ {
m_pCreatPrintDat->setMcPrintInfo(fileIdx,&m_mcPrintInfo); m_pCreatPrintDat->setMcPrintInfo(fileIdx,markSpace,&m_mcPrintInfo);
} }
emit siCreatData(); emit siCreatData();
} }

View File

@ -104,7 +104,7 @@ public:
// 机器工作命令 // 机器工作命令
void mcWorkCmd(int workcode, int para1 = 0 , int para2 = 0); void mcWorkCmd(int workcode, int para1 = 0 , int para2 = 0);
void creatPrintDat(int fileIdx,int setFlag = 1); //生成打印数据 void creatPrintDat(int fileIdx,u32 markSpace,int setFlag = 1); //生成打印数据
void stopPrint(); //停止打印 void stopPrint(); //停止打印
void deleteFilePrintDat(int fileIdx);//删除文件打印数据 void deleteFilePrintDat(int fileIdx);//删除文件打印数据

View File

@ -41,7 +41,7 @@ public:
QString m_fileName;//文件名称 QString m_fileName;//文件名称
QString m_filePath;//文件路径 QString m_filePath;//文件路径
s16 m_fileType;//文件类型 s16 m_fileType;//文件类型
QRect m_fileRect;//图形被包络的矩形区域 QRectF m_fileRect;//图形被包络的矩形区域
s16 m_printNum;//打印份数 s16 m_printNum;//打印份数
s16 m_startPoint;//打印起始点 s16 m_startPoint;//打印起始点
s16 m_printState;//打印状态 s16 m_printState;//打印状态

View File

@ -222,6 +222,7 @@ void MainWindow::startCreatBmpAndSend(int mcIdx)
{ {
int mcBegIdx, mcEndIdx; int mcBegIdx, mcEndIdx;
mcBegIdx = mcEndIdx = 0; mcBegIdx = mcEndIdx = 0;
u32 markSpace = m_pSettings->value("DrawSet/markmargin").toUInt();//马克间距
//自动打印时mcIdx为-1 //自动打印时mcIdx为-1
//mcIdx = -1; //mcIdx = -1;
@ -257,7 +258,7 @@ void MainWindow::startCreatBmpAndSend(int mcIdx)
{ {
mcDir.mkdir(mcFile); mcDir.mkdir(mcFile);
} }
g_machineList[i]->creatPrintDat(m_curFileRow); g_machineList[i]->creatPrintDat(m_curFileRow,markSpace);
if(m_curFileRow > 0) if(m_curFileRow > 0)
{ {
@ -482,7 +483,7 @@ int MainWindow::refreshMcFileListShow(int idx)
m_tabelViewModelFile->insertRow(i);//在最后一行的后面插入一行 m_tabelViewModelFile->insertRow(i);//在最后一行的后面插入一行
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_FILENAME),filesList[i].m_fileName); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_FILENAME),filesList[i].m_fileName);
QRect rect = filesList[i].m_fileRect; QRectF rect = filesList[i].m_fileRect;
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm"; QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_LENGTH),length); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_LENGTH),length);
@ -668,7 +669,7 @@ void MainWindow::slotAddNewFileToList(int newFlag)
m_tabelViewModelFile->insertRow(row);//在最后一行的后面插入一行 m_tabelViewModelFile->insertRow(row);//在最后一行的后面插入一行
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_FILENAME),m_curFilesInfo.m_fileName); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_FILENAME),m_curFilesInfo.m_fileName);
QRect rect = m_curFilesInfo.m_fileRect; QRectF rect = m_curFilesInfo.m_fileRect;
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm"; QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_LENGTH),length); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_LENGTH),length);
@ -989,7 +990,11 @@ void MainWindow::slotLoadAutoPrintFiles()
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_creatDataFlag == 1) if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_creatDataFlag == 1)
{ {
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILENAME),g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileName); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILENAME),g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileName);
<<<<<<< HEAD
QRectF rect = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileRect;
=======
QRect rect = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileRect; QRect rect = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileRect;
>>>>>>> 9f74511e69bc847a1a226ae630185c956827429c
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm"; QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_LENGTH),length); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_LENGTH),length);
QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm"; QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm";
@ -1009,7 +1014,11 @@ void MainWindow::slotLoadAutoPrintFiles()
creatMarkerDat(curFilesInfo,m_printPath,filePath,-1,m_rotateAngle); creatMarkerDat(curFilesInfo,m_printPath,filePath,-1,m_rotateAngle);
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILENAME),curFilesInfo.m_fileName); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILENAME),curFilesInfo.m_fileName);
<<<<<<< HEAD
QRectF rect = curFilesInfo.m_fileRect;
=======
QRect rect = curFilesInfo.m_fileRect; QRect rect = curFilesInfo.m_fileRect;
>>>>>>> 9f74511e69bc847a1a226ae630185c956827429c
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm"; QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_LENGTH),length); m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_LENGTH),length);
QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm"; QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm";
@ -1042,6 +1051,7 @@ void MainWindow::slotDeleteFileFromList(int mcNum, int fileIdx, int refreshFlag)
{ {
//是否自动打印 //是否自动打印
int autoPrint = 0; int autoPrint = 0;
u32 markSpace = m_pSettings->value("DrawSet/markmargin").toUInt();//马克间距
//刷新进度 //刷新进度
if(refreshFlag != 0) if(refreshFlag != 0)
@ -1091,7 +1101,7 @@ void MainWindow::slotDeleteFileFromList(int mcNum, int fileIdx, int refreshFlag)
if(m_curFileRow >= 0 && autoPrint == 1) if(m_curFileRow >= 0 && autoPrint == 1)
{ {
g_machineList[i]->creatPrintDat(m_curFileRow,0); g_machineList[i]->creatPrintDat(m_curFileRow,markSpace,0);
} }
} }
} }