📄 rs_filterdxf1.cpp
字号:
/****************************************************************************** $Id: rs_filterdxf1.cpp 2371 2005-04-29 11:44:39Z andrew $**** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.**** This file is part of the qcadlib Library project.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** Licensees holding valid qcadlib Professional Edition licenses may use ** this file in accordance with the qcadlib Commercial License** Agreement provided with the Software.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.ribbonsoft.com for further details.**** Contact info@ribbonsoft.com if any conditions of this licensing are** not clear to you.************************************************************************/#include "rs_filterdxf.h"#include "rs_filterdxf1.h"#include <iostream>#include "rs_file.h"#include "rs_regexp.h"#include "rs_font.h"#include "rs_information.h"#include "rs_utility.h"#include "rs_system.h"#include "rs_dimlinear.h"#include "rs_dimaligned.h"#include "rs_dimangular.h"#include "rs_dimdiametric.h"#include "rs_dimradial.h"/** * Default constructor. */RS_FilterDXF1::RS_FilterDXF1() :RS_FilterInterface() { RS_DEBUG->print("Setting up DXF 1 filter..."); graphic = NULL; addImportFormat(RS2::FormatDXF1);}/** * Implementation of the method used for RS_Import to communicate * with this filter. * * @param graphic The graphic in which the entities from the file * will be created or the graphics from which the entities are * taken to be stored in a file. */bool RS_FilterDXF1::fileImport(RS_Graphic& g, const RS_String& file, RS2::FormatType /*type*/) { RS_DEBUG->print("DXF1 Filter: importing file '%s'...", file.latin1()); this->graphic = &g; fPointer=0; fBuf=0; fBufP=0; fSize=0; dosFile=false; name = file; if(readFileInBuffer()) { separateBuf(); return readFromBuffer(); } return false;}/** * Reads a dxf1 file from buffer. */bool RS_FilterDXF1::readFromBuffer() { RS_DEBUG->print( "\nDXF: Read from buffer" ); bool ret; // returned value RS_String dxfLine; // A line in the dxf file RS_String dxfCode; // A Code in the dxf file as string int code=-1; // Dxf-code as number double vx1=0.0, vy1=0.0; // Start point double vx2=0.0, vy2=0.0; // End point double vcx=0.0, vcy=0.0; // Centre double vcr=0.0; // Radius double va1=0.0, va2=0.0; // Start / End Angle //double vab=0.0, // Bulge // vpx=0.0, vpy=0.0; // First Polyline point //double ax=0.0, ay=0.0; // Current coordinate //bool plClose=false; // Polyline closed-flag RS_String lastLayer; // Last used layer name (test adding only // if the new layer!=lastLayer) //int currentLayerNum=0; // Current layer number RS_Layer* currentLayer=0; // Pointer to current layer //QList<RGraphic> blockList; // List of blocks //blockList.setAutoDelete( true ); //bool oldColorNumbers=false; // use old color numbers (qcad<1.5.3) RS_Pen pen; ///if(!add) graphic->clearLayers(); //graphic->addLayer(DEF_DEFAULTLAYER); //RS_DEBUG->print( "\nDefault layer added" ); // Loaded graphics without unit information: load as unit less: //graphic->setUnit( None ); RS_DEBUG->print( "\nUnit set" ); resetBufP(); if(fBuf) { RS_DEBUG->print( "\nBuffer OK" ); RS_DEBUG->print( "\nBuffer: " ); RS_DEBUG->print( fBuf ); do { dxfLine=getBufLine(); pen = RS_Pen(RS_Color(RS2::FlagByLayer), RS2::WidthByLayer, RS2::LineByLayer); RS_DEBUG->print( "\ndxfLine: " ); RS_DEBUG->print( dxfLine ); // $-Setting in the header of DXF found // if( dxfLine && dxfLine[0]=='$' ) { // Units: // if( dxfLine=="$INSUNITS" ) { if(dxfCode=getBufLine()) { if( dxfCode.toInt()==70 ) { if( dxfLine=getBufLine() ) { graphic->addVariable("$INSUNITS", dxfLine, 70); /* switch( dxfLine.toInt() ) { case 0: graphic->setUnit( RS2::None ); break; case 1: graphic->setUnit( RS2::Inch ); break; case 2: graphic->setUnit( RS2::Foot ); break; case 3: graphic->setUnit( RS2::Mile ); break; case 4: graphic->setUnit( RS2::Millimeter ); break; case 5: graphic->setUnit( RS2::Centimeter ); break; case 6: graphic->setUnit( RS2::Meter ); break; case 7: graphic->setUnit( RS2::Kilometer ); break; case 8: graphic->setUnit( RS2::Microinch ); break; case 9: graphic->setUnit( RS2::Mil ); break; case 10: graphic->setUnit( RS2::Yard ); break; case 11: graphic->setUnit( RS2::Angstrom ); break; case 12: graphic->setUnit( RS2::Nanometer ); break; case 13: graphic->setUnit( RS2::Micron ); break; case 14: graphic->setUnit( RS2::Decimeter ); break; case 15: graphic->setUnit( RS2::Decameter ); break; case 16: graphic->setUnit( RS2::Hectometer ); break; case 17: graphic->setUnit( RS2::Gigameter ); break; case 18: graphic->setUnit( RS2::Astro ); break; case 19: graphic->setUnit( RS2::Lightyear ); break; case 20: graphic->setUnit( RS2::Parsec ); break; } graphic->setDimensionUnit( graphic->getUnit() ); //graphic->setGridUnit( graphic->getUnit() ); */ } } } } // Dimenison Units: // else if( dxfLine=="$DIMALT" ) { if(dxfCode=getBufLine()) { if( dxfCode.toInt()==70 ) { if( dxfLine=getBufLine() ) { graphic->addVariable("$DIMALT", dxfLine, 70); /* switch( dxfLine.toInt() ) { case 0: graphic->setDimensionUnit( RS2::None ); break; case 1: graphic->setDimensionUnit( RS2::Inch ); break; case 2: graphic->setDimensionUnit( RS2::Foot ); break; case 3: graphic->setDimensionUnit( RS2::Mile ); break; case 4: graphic->setDimensionUnit( RS2::Millimeter ); break; case 5: graphic->setDimensionUnit( RS2::Centimeter ); break; case 6: graphic->setDimensionUnit( RS2::Meter ); break; case 7: graphic->setDimensionUnit( RS2::Kilometer ); break; case 8: graphic->setDimensionUnit( RS2::Microinch ); break; case 9: graphic->setDimensionUnit( RS2::Mil ); break; case 10: graphic->setDimensionUnit( RS2::Yard ); break; case 11: graphic->setDimensionUnit( RS2::Angstrom ); break; case 12: graphic->setDimensionUnit( RS2::Nanometer ); break; case 13: graphic->setDimensionUnit( RS2::Micron ); break; case 14: graphic->setDimensionUnit( RS2::Decimeter ); break; case 15: graphic->setDimensionUnit( RS2::Decameter ); break; case 16: graphic->setDimensionUnit( RS2::Hectometer ); break; case 17: graphic->setDimensionUnit( RS2::Gigameter ); break; case 18: graphic->setDimensionUnit( RS2::Astro ); break; case 19: graphic->setDimensionUnit( RS2::Lightyear ); break; case 20: graphic->setDimensionUnit( RS2::Parsec ); break; } */ } } } } // Dimension Format: // /*else if( dxfLine=="$DIMLUNIT" ) { if(dxfCode=getBufLine()) { if( dxfCode.toInt()==70 ) { if( dxfLine=getBufLine() ) { switch( dxfLine.toInt() ) { case 1: graphic->setDimensionFormat( Scientific ); break; case 2: case 3: graphic->setDimensionFormat( Decimal ); break; case 4: case 5: graphic->setDimensionFormat( Fractional ); break; default: break; } } } } }*/ // Dimension Arrow Size: // else if( dxfLine=="$DIMASZ" ) { if(dxfCode=getBufLine()) { if( dxfCode.toInt()==40 ) { if( dxfLine=getBufLine() ) { graphic->addVariable("$DIMASZ", dxfLine, 40); //graphic->setDimensionArrowSize( dxfLine.toDouble() ); } } } } // Dimension Scale: // /* else if( dxfLine=="$DIMSCALE" ) { if(dxfCode=getBufLine()) { if( dxfCode.toInt()==40 ) { if( dxfLine=getBufLine() ) { graphic->setDimensionScale( dxfLine.toDouble() ); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -