Add dxf point import

Fix #9149
This commit is contained in:
Marek Roszko 2021-09-12 19:38:22 -04:00
parent 52f99e41e6
commit daca9d21f2
4 changed files with 34 additions and 3 deletions

View File

@ -1175,6 +1175,31 @@ void DXF_IMPORT_PLUGIN::addTextStyle( const DL_StyleData& aData )
}
void DXF_IMPORT_PLUGIN::addPoint( const DL_PointData& aData )
{
DXF_ARBITRARY_AXIS arbAxis = getArbitraryAxis( getExtrusion() );
VECTOR3D centerCoords = ocsToWcs( arbAxis, VECTOR3D( aData.x, aData.y, aData.z ) );
VECTOR2D center( mapX( centerCoords.x ), mapY( centerCoords.y ) );
// we emulate points with filled circles
// set the linewidth to something that even small circles look good with
// thickness is optional for dxf points
// note: we had to modify the dxf library to grab the attribute for thickness
double lineWidth = 0.0001;
double thickness = mapDim( std::max( aData.thickness, 0.01 ) );
GRAPHICS_IMPORTER_BUFFER* bufferToUse =
( m_currentBlock != nullptr ) ? &m_currentBlock->m_buffer : &m_internalImporter;
bufferToUse->AddCircle( center, thickness, lineWidth, true );
VECTOR2D radiusDelta( SCALE_FACTOR( thickness ), SCALE_FACTOR( thickness ) );
updateImageLimits( center + radiusDelta );
updateImageLimits( center - radiusDelta );
}
void DXF_IMPORT_PLUGIN::insertLine( const VECTOR2D& aSegStart,
const VECTOR2D& aSegEnd, int aWidth )
{

View File

@ -413,6 +413,8 @@ private:
*/
virtual void addBlock( const DL_BlockData& ) override;
virtual void endBlock() override;
virtual void addTextStyle( const DL_StyleData& aData ) override;
virtual void addPoint( const DL_PointData& aData ) override;
virtual void addCircle( const DL_CircleData& aData ) override;
virtual void addArc( const DL_ArcData& aData ) override;
@ -428,7 +430,6 @@ private:
*/
virtual void addVertex( const DL_VertexData& aData ) override;
virtual void addMText( const DL_MTextData& aData) override;
virtual void addTextStyle( const DL_StyleData& aData ) override;
virtual void endEntity() override;

View File

@ -1151,7 +1151,8 @@ void DL_Dxf::addPoint( DL_CreationInterface* creationInterface )
{
DL_PointData d( getRealValue( 10, 0.0 ),
getRealValue( 20, 0.0 ),
getRealValue( 30, 0.0 ) );
getRealValue( 30, 0.0 ),
getRealValue( 39, 0.0 ) );
creationInterface->addPoint( d );
}

View File

@ -223,11 +223,12 @@ struct DXFLIB_EXPORT DL_PointData
* Constructor.
* Parameters: see member variables.
*/
DL_PointData( double px = 0.0, double py = 0.0, double pz = 0.0 )
DL_PointData( double px = 0.0, double py = 0.0, double pz = 0.0, double pthickness = 0.0 )
{
x = px;
y = py;
z = pz;
thickness = pthickness;
}
/*! X Coordinate of the point. */
@ -238,6 +239,9 @@ struct DXFLIB_EXPORT DL_PointData
/*! Z Coordinate of the point. */
double z;
/*! Thickness of the point. */
double thickness;
};