DATAKIT API  V2025.4
PdfWrite.cpp File Reference

Functions

void ActivatePdfDump (Dtk_bool inDumpPDF)
 
Dtk_bool IsPdfDumpActivated ()
 
void PdfEndComponent ()
 
void PdfEndInstance (Dtk_ID pdfInstID, Dtk_ID childID)
 
void PdfEndNode ()
 
void PdfEndWrite (const Dtk_string &inInputFile)
 
Dtk_ID PdfInitComponent (Dtk_ComponentPtr inComponent)
 
Dtk_ID PdfInitInstance (Dtk_ComponentPtr inComponent)
 
Dtk_ID PdfInitNode (Dtk_NodePtr inNode)
 
Dtk_ErrorStatus PdfInitWrite (const Dtk_string &inInputFileName, const Dtk_string &inOutputFolder)
 
void PdfInstanceExistingPrototype (Dtk_ID ComponentIndex)
 
void PdfWriteDrawingNode (Dtk_NodePtr inNode)
 
void PdfWriteEntity (Dtk_EntityPtr inEntity)
 
void PdfWriteMetaData (Dtk_ComponentPtr inComponent)
 
void PdfWriteMetaData (Dtk_tab< Dtk_MetaDataPtr > &inTabMetadata)
 

Variables

Dtk_tab< Dtk_IDComponentProcessed
 
std::map< Dtk_Node::NodeDataTypeEnum, Dtk_Size_tmodelInventory
 
Dtk_tab< Dtk_IDPdfComponents
 
Dtk_bool toDumpPDF
 

Function Documentation

◆ ActivatePdfDump()

void ActivatePdfDump ( Dtk_bool  inDumpPDF)
26 {
27  toDumpPDF = inDumpPDF;
28 }

◆ IsPdfDumpActivated()

Dtk_bool IsPdfDumpActivated ( )
31 {
32  return toDumpPDF;
33 }

◆ PdfEndComponent()

void PdfEndComponent ( )
156 {
157  Pdfw::EndNode();
158 }

◆ PdfEndInstance()

void PdfEndInstance ( Dtk_ID  pdfInstID,
Dtk_ID  childID 
)
113 {
114  if ( ComponentProcessed.find(childID) < 0)
115  {
116  PdfComponents.push_back(pdfInstID);
117  }
118  Pdfw::EndNode();
119 }

◆ PdfEndNode()

void PdfEndNode ( )
173 {
174  Pdfw::EndNode();
175 }

◆ PdfEndWrite()

void PdfEndWrite ( const Dtk_string inInputFile)
85 {
86  Dtk_UInt32 artworkIndex = 0;
87  Pdfw::Layout::End3DArtwork(artworkIndex);
88  CreatePDFLayout(inInputFile, artworkIndex, modelInventory);
89  modelInventory.clear();
92 }

◆ PdfInitComponent()

Dtk_ID PdfInitComponent ( Dtk_ComponentPtr  inComponent)
148 {
149  Dtk_InfoPtr infos = inComponent->GetInfos();
150  Dtk_string name = inComponent->Name();
151  Dtk_ID pdfID;
152  Pdfw::InitNode(name, Dtk_transfo(), infos, pdfID);
153  return pdfID;
154 }

◆ PdfInitInstance()

Dtk_ID PdfInitInstance ( Dtk_ComponentPtr  inComponent)
95 {
96  Dtk_ID pdfInstID;
97  Dtk_string ComponentName;
98  ComponentName = inComponent->Name();//Component name
99 
100  Dtk_InfoPtr infos = inComponent->GetInfos();
101  Dtk_transfo instanceTransfo;
102 
103  if (inComponent->InstanceName().len() > 0)
104  ComponentName += " (" + inComponent->InstanceName() + ")";
105 
106  instanceTransfo = inComponent->TransformationMatrix();
107  Pdfw::InitNode(ComponentName, instanceTransfo, infos, pdfInstID);
108  Pdfw::StorePrototype(pdfInstID);
109  return pdfInstID;
110 }

◆ PdfInitNode()

Dtk_ID PdfInitNode ( Dtk_NodePtr  inNode)
161 {
162  Dtk_ID pdfID;
163  Dtk_string NodeName = inNode->Name();
164  Dtk_InfoPtr nodeInfo = inNode->GetInfos();
165  Dtk_bool nodeVisi = nodeInfo->GetBlankedStatus() ? DTK_FALSE : DTK_TRUE;
166  Pdfw::InitNode(NodeName, Dtk_transfo(), nodeVisi, pdfID);
167  if (nodeInfo.IsNotNULL())
169  return pdfID;
170 }

◆ PdfInitWrite()

Dtk_ErrorStatus PdfInitWrite ( const Dtk_string inInputFileName,
const Dtk_string inOutputFolder 
)
36 {// Initialize writing
37  Dtk_ErrorStatus stErrorPdf;
38  Dtk_string outputPDFFile;
39  Pdfw::WriteOptions options;
40 
41  // Pdf options :
42  // We choose between PRC or U3D 3D format
43  options.WritePRC = DTK_TRUE;
44  // We will generate our own layout
46 #ifndef Linux
47  // We choose the font to use
48  options.Layout.TTF_Font = "C:/Windows/Fonts/arial.ttf";
50 #endif
51  // We handle line thickness
53  // We set a transparent background
55 
56  outputPDFFile = inInputFileName + "_dtk.pdf";
57  if (inOutputFolder.len() > 0)
58  outputPDFFile = inOutputFolder + inInputFileName.filename() +inInputFileName.extension() + "_dtk.pdf";
59  // Initializing the writer
60  stErrorPdf = Pdfw::InitWrite(outputPDFFile, "", NULL, options);
61 
62  if (stErrorPdf == dtkNoError)
63  cout << "Creating Pdf file... " << outputPDFFile.c_str() << endl;
64  else
65  cout << "Warning : Pdf Write failed : " << dtkTypeError(stErrorPdf).c_str() << endl;
66 
67 
68 
69  //**************************************************************************************************************//
70  //layout
71  //**************************************************************************************************************//
72  // Page creation
74  // Size of Page
76 
77  // PDF 3D Artwork initialization
78  Pdfw::Layout::Init3DArtwork(inInputFileName.filename());
79 
80  modelInventory.clear();
81  return stErrorPdf;
82 }

◆ PdfInstanceExistingPrototype()

void PdfInstanceExistingPrototype ( Dtk_ID  ComponentIndex)
143 {
145 }

◆ PdfWriteDrawingNode()

void PdfWriteDrawingNode ( Dtk_NodePtr  inNode)
189 {
190  Dtk_DrawingPtr TmpDrawing = inNode->GetDtk_DrawingPtr();
191 
192  //Count Drawing
194 }

◆ PdfWriteEntity()

void PdfWriteEntity ( Dtk_EntityPtr  inEntity)
178 {
179  Pdfw::WriteEntity(inEntity);
180  if (inEntity->get_type_detk() == DTK_TYPE_BODY)
182  if (inEntity->get_type_detk() == DTK_TYPE_MESH)
184  if (inEntity->get_type_detk() == DTK_TYPE_FDT)
186 }

◆ PdfWriteMetaData() [1/2]

void PdfWriteMetaData ( Dtk_ComponentPtr  inComponent)
122 {
123  Dtk_Size_t i,NumMetaData;
124  NumMetaData = inComponent->GetNumMetaData();
125  if (NumMetaData)
126  {
127  Dtk_tab<Dtk_MetaDataPtr> tabMetadata;
128  for (i = 0; i < NumMetaData; i++)
129  {
130  tabMetadata.push_back(inComponent->GetMetaData(i));
131  }
132  Pdfw::AddNodeMetadata(tabMetadata);
133  }
134 }

◆ PdfWriteMetaData() [2/2]

void PdfWriteMetaData ( Dtk_tab< Dtk_MetaDataPtr > &  inTabMetadata)
137 {
138  Pdfw::AddNodeMetadata(inTabMetadata);
139 }

Variable Documentation

◆ ComponentProcessed

Dtk_tab<Dtk_ID> ComponentProcessed
extern

◆ modelInventory

std::map<Dtk_Node::NodeDataTypeEnum, Dtk_Size_t> modelInventory

◆ PdfComponents

Dtk_tab<Dtk_ID> PdfComponents

◆ toDumpPDF

Dtk_bool toDumpPDF
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:691
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Pdfw::AddNodeMetadata
DtkErrorStatus AddNodeMetadata(Dtk_tab< Dtk_MetaDataPtr > &inTabMetadata)
Add table of metadata to current node.
Dtk_Info::GetBlankedStatus
int GetBlankedStatus() const
Retrieves the entity Blanked Status.
Dtk_Node::FdtType
@ FdtType
Definition: dtk_maindoc.hpp:251
Pdfw::WriteOptions
This class provides several options to tune Pdf Writer. It must be provided to Pdfw::InitWrite method...
Definition: pdfw.hpp:113
DTK_TYPE_MESH
@ DTK_TYPE_MESH
Definition: define.h:479
Pdfw::InitWrite
DtkErrorStatus InitWrite(const Dtk_string &inOutputFile, const Dtk_string &inLogFile, Licence_dtk inLicFct, WriteOptions &inOptions)
Initialize the PDF Writer
Pdfw::WriteOptions::Layout
LayoutOptions Layout
Definition: pdfw.hpp:193
Dtk_SmartPtr::IsNotNULL
Dtk_bool IsNotNULL() const
Definition: util_ptr_dtk.hpp:119
Pdfw::Layout::EndPage
Dtk_ErrorStatus EndPage()
End of page.
Pdfw::LayoutOptions::CreateAutomaticLayout
Dtk_bool CreateAutomaticLayout
DTK_TRUE : Creates automatic layout (One page with filled with 3D Annotation), DTK_FALSE : You must u...
Definition: pdfw.hpp:37
DTK_TRUE
#define DTK_TRUE
Definition: define.h:729
Dtk_UInt32
uint32_t Dtk_UInt32
Definition: define.h:690
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:714
Dtk_Node::BodyType
@ BodyType
Definition: dtk_maindoc.hpp:248
DTK_FALSE
#define DTK_FALSE
Definition: define.h:730
Dtk_bool
char Dtk_bool
Definition: define.h:727
Pdfw::AddNodeRenderInfo
DtkErrorStatus AddNodeRenderInfo(Dtk_RenderInfosPtr inRenderInfos)
Add rendering informations to current node.
Dtk_Entity::get_type_detk
virtual enum type_detk get_type_detk() const =0
Pdfw::LayoutOptions::WriteLineThickness
Dtk_bool WriteLineThickness
DTK_TRUE : write line thickness, DTK_FALSE : Writes lines with thickness value equals to 0....
Definition: pdfw.hpp:41
Pdfw::Layout::SetCurrentPageSize
Dtk_ErrorStatus SetCurrentPageSize(PageSizes inSize, PageDirection inDirection)
Sets current page size.
Pdfw::ReinstanciatePrototype
DtkErrorStatus ReinstanciatePrototype(Dtk_ID inID)
Reinstanciate children of node to reinstanciate in current node.
Pdfw::Layout::Init3DArtwork
DtkErrorStatus Init3DArtwork(Dtk_string inAnnotName=Dtk_string(), Pdfw::WriteOptions *inWriteOptions=NULL)
Starts Writing of 3D Artwork (3D model)
Pdfw::StorePrototype
void StorePrototype(Dtk_ID inID)
Stores the identifier of a node.
Dtk_string::filename
Dtk_string filename() const
File Utility : Retrieves the filename in Dtk_string form.
Pdfw::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the PDF Writer
modelInventory
std::map< Dtk_Node::NodeDataTypeEnum, Dtk_Size_t > modelInventory
Definition: PdfWrite.cpp:22
DTK_TYPE_BODY
@ DTK_TYPE_BODY
Definition: define.h:492
Pdfw::EndNode
DtkErrorStatus EndNode()
End the node.
Pdfw::LayoutOptions::RasterizeTexts
Dtk_bool RasterizeTexts
DTK_TRUE : rasterizing texts, DTK_FALSE : Converts texts as texts with the font you provide.
Definition: pdfw.hpp:39
Pdfw::Layout::LANDSCAPE
@ LANDSCAPE
Definition: pdfw.hpp:477
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_Info::GetRenderInfos
Dtk_RenderInfosPtr GetRenderInfos() const
Retrieves the entity RenderInfos of the entity.
DTK_TYPE_FDT
@ DTK_TYPE_FDT
Definition: define.h:435
Pdfw::LayoutOptions::TTF_Font
Dtk_string TTF_Font
Definition: pdfw.hpp:45
Pdfw::Layout::SIZE_A5
@ SIZE_A5
Definition: pdfw.hpp:462
Dtk_SmartPtr< Dtk_Info >
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
PdfComponents
Dtk_tab< Dtk_ID > PdfComponents
Definition: PdfWrite.cpp:20
Dtk_string::extension
Dtk_string extension() const
File Utility : Retrieves the extension in Dtk_string form.
Pdfw::Layout::End3DArtwork
DtkErrorStatus End3DArtwork(Dtk_UInt32 &outartworkIndex)
Ends Writing of 3D Artwork.
toDumpPDF
Dtk_bool toDumpPDF
Definition: PdfWrite.cpp:18
Pdfw::WriteEntity
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity)
Write the entity provided in parameter in a node.
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Pdfw::InitNode
DtkErrorStatus InitNode(Dtk_string &inNodeName, const Dtk_transfo &inTransfo=Dtk_transfo())
Initialize a node.
Pdfw::WriteOptions::WritePRC
Dtk_bool WritePRC
DTK_TRUE : Embedding PRC file, DTK_FALSE : Embedding U3D file.
Definition: pdfw.hpp:161
Dtk_string::len
int len() const
Retrieve the length of the Dtk_string.
ComponentProcessed
Dtk_tab< Dtk_ID > ComponentProcessed
Definition: WritePrototype.cpp:12
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:144
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:417
Dtk_Node::DrawingType
@ DrawingType
Definition: dtk_maindoc.hpp:252
CreatePDFLayout
void CreatePDFLayout(const Dtk_string &inFileName, Dtk_Int32 artworkIndex, std::map< Dtk_Node::NodeDataTypeEnum, Dtk_Size_t > &inModelInventory)
Definition: PdfWriteLayout.cpp:283
Pdfw::WriteOptions::TransparentBackground
Dtk_bool TransparentBackground
DTK_TRUE : Transparent Background, DTK_FALSE : Opaque Background.
Definition: pdfw.hpp:153
Pdfw::Layout::InitPage
Dtk_ErrorStatus InitPage(Dtk_RGB inColor=Dtk_RGB(255, 255, 255), Dtk_Double64 inWidth=842, Dtk_Double64 inHeight=595)
LAYOUT METHODS.
Dtk_Node::MeshType
@ MeshType
Definition: dtk_maindoc.hpp:249