2025.6.1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.
|
||||
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
|
||||
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
||||
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
||||
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
||||
@@ -18,6 +18,7 @@ This file demonstrates numerous functionalities of HOOPS Publish.
|
||||
#define INITIALIZE_A3D_API
|
||||
#define HOOPS_PRODUCT_PUBLISH_STANDARD
|
||||
#include <A3DSDKIncludes.h>
|
||||
#include <hoops_license.h>
|
||||
#include "../common.hpp"
|
||||
#include "../CommonInit.h"
|
||||
|
||||
@@ -299,87 +300,84 @@ A3DStatus Create3DAnnot(A3DPDFDocument* pDoc,
|
||||
}
|
||||
|
||||
|
||||
//######################################################################################################################
|
||||
// Helper functions to create a Table on PDF Page using API
|
||||
|
||||
#define NOSPAN 1
|
||||
|
||||
void CreateStyle(A3DInt32 fontSize, A3DUTF8Char const* const fontName,
|
||||
A3DPDFRgbColorData* textColor, A3DPDFRgbColorData* borderColor, A3DPDFRgbColorData* bkColor,
|
||||
A3DPDFETableTextHorizontalAlign hAlignment, A3DPDFETableTextVerticalAlign vAlignment,
|
||||
A3DInt32 rowHeight, A3DInt32 columnWidth,
|
||||
A3DInt32 bPadding, A3DInt32 lPadding, A3DInt32 rPadding, A3DInt32 tPadding,
|
||||
A3DPDFTableStyleData& outStyle)
|
||||
{
|
||||
A3D_INITIALIZE_DATA(A3DPDFTableStyleData, outStyle);
|
||||
outStyle.m_iFontSize = fontSize;
|
||||
outStyle.m_pcFontName = const_cast<A3DUTF8Char*>(fontName);
|
||||
outStyle.m_pTextColor = textColor;
|
||||
outStyle.m_pBorderColor = borderColor;
|
||||
outStyle.m_pBackgroundColor = bkColor;
|
||||
outStyle.m_eHorizAlignment = hAlignment;
|
||||
outStyle.m_eVertAlignment = vAlignment;
|
||||
outStyle.m_iRowHeight = rowHeight;
|
||||
outStyle.m_iColumnWidth = columnWidth;
|
||||
outStyle.m_iPaddingBottom = bPadding;
|
||||
outStyle.m_iPaddingLeft = lPadding;
|
||||
outStyle.m_iPaddingRight = rPadding;
|
||||
outStyle.m_iPaddingTop = tPadding;
|
||||
}
|
||||
|
||||
// Creates a Cell entity and push it in Cells array
|
||||
A3DStatus AddTableCellDesc(std::vector<A3DPDFTableCellDesc*>& aCells, A3DUns8 iRowSpan, A3DUns8 iColSpan, A3DUTF8Char const* const pcCellString, A3DPDFTableStyleData* pStyle)
|
||||
{
|
||||
A3DStatus iResult = A3D_SUCCESS;
|
||||
A3DPDFTableCellDesc* pTableCellDesc = nullptr;
|
||||
A3DPDFTableCellDescData sTableCellDescData;
|
||||
A3D_INITIALIZE_DATA(A3DPDFTableCellDescData, sTableCellDescData);
|
||||
sTableCellDescData.m_iRowSpan = iRowSpan;
|
||||
sTableCellDescData.m_iColSpan = iColSpan;
|
||||
sTableCellDescData.m_pcCellString = const_cast<A3DUTF8Char*>(pcCellString);
|
||||
sTableCellDescData.m_pStyle = pStyle;
|
||||
iResult = A3DPDFTableCellDescCreate(&sTableCellDescData, &pTableCellDesc);
|
||||
if (iResult == A3D_SUCCESS)
|
||||
aCells.push_back(pTableCellDesc);
|
||||
return iResult;
|
||||
}
|
||||
|
||||
A3DUTF8Char pcHtmlTablePage1[] = "<table class=\"gridtable\"> \
|
||||
<tr>\
|
||||
<th>Deviation</th><th># of Points</th><th>% of Total</th>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.109</td><td>16903</td><td>33.9</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.218</td><td>5124</td><td>10.3</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.327</td><td>7811</td><td>15.6</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.436</td><td>7811</td><td>15.6</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.545</td><td>6605</td><td>13.2</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.654</td><td>1688</td><td>3.4</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.763</td><td>1279</td><td>2.6</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.872</td><td>1109</td><td>2.2</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>0.981</td><td>1035</td><td>2.1</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>1.09</td><td>565</td><td>1.1</td>\
|
||||
</tr>\
|
||||
</table>";
|
||||
|
||||
|
||||
A3DUTF8Char pcHtmlStyle[] = "<style type=\"text/css\"> \
|
||||
table.gridtable {\
|
||||
font-family: helvetica;\
|
||||
font-size:10pt;\
|
||||
text-align: center;\
|
||||
border-width: 0pt;\
|
||||
border-collapse: collapse;\
|
||||
}\
|
||||
table.gridtable th {\
|
||||
border-width: 0pt;\
|
||||
border-style: solid;\
|
||||
background-color: #dedede;\
|
||||
padding: 0pt;\
|
||||
width:100pt;\
|
||||
height:12pt;\
|
||||
max-width:100pt;\
|
||||
min-width:100pt;\
|
||||
}\
|
||||
table.gridtable td {\
|
||||
border-width: 0pt;\
|
||||
border-style: solid;\
|
||||
background-color: #ffffff;\
|
||||
padding: 0pt;\
|
||||
width:100pt;\
|
||||
height:12pt;\
|
||||
max-width:100pt;\
|
||||
min-width:100pt;\
|
||||
}\
|
||||
table.gridtable td.link {\
|
||||
text-decoration:underline;\
|
||||
color:blue;\
|
||||
}\
|
||||
table.gridtable td.pass {\
|
||||
background-color: rgb(0,255,0);\
|
||||
}\
|
||||
table.gridtable td.fail {\
|
||||
background-color: rgb(255,0,0);\
|
||||
}\
|
||||
</style>;";
|
||||
// Creates a Row entity populated with cells, and push it in Rows array
|
||||
A3DStatus AddTableRowDesc(std::vector<A3DPDFTableRowDesc*>& aRows, const std::vector<A3DPDFTableCellDesc*>& aCells, A3DPDFTableStyleData* pStyle)
|
||||
{
|
||||
A3DStatus iResult = A3D_SUCCESS;
|
||||
A3DPDFTableRowDesc* pTableRowDesc = nullptr;
|
||||
A3DPDFTableRowDescData sTableRowDescData;
|
||||
A3D_INITIALIZE_DATA(A3DPDFTableRowDescData, sTableRowDescData);
|
||||
sTableRowDescData.m_iNumberOfCells = static_cast<A3DUns32>(aCells.size());
|
||||
sTableRowDescData.m_ppCells = (A3DPDFTableCellDesc**)malloc(aCells.size() * sizeof(A3DPDFTableCellDesc**));
|
||||
for (size_t i = 0; i < aCells.size(); i++)
|
||||
sTableRowDescData.m_ppCells[i] = aCells[i];
|
||||
sTableRowDescData.m_pStyle = pStyle;
|
||||
iResult = A3DPDFTableRowDescCreate(&sTableRowDescData, &pTableRowDesc);
|
||||
if (iResult == A3D_SUCCESS)
|
||||
aRows.push_back(pTableRowDesc);
|
||||
return iResult;
|
||||
}
|
||||
|
||||
// Creates a Table populated with rows
|
||||
A3DStatus CreateTableDesc(A3DPDFDocument* pDoc, A3DPDFTable*& pTable, const std::vector<A3DPDFTableRowDesc*>& aRows, A3DPDFTableStyleData* pStyle)
|
||||
{
|
||||
A3DStatus iResult = A3D_SUCCESS;
|
||||
pTable = nullptr;
|
||||
A3DPDFTableDescData sTableDescData;
|
||||
A3D_INITIALIZE_DATA(A3DPDFTableDescData, sTableDescData);
|
||||
sTableDescData.m_iNumberOfRows = static_cast<A3DUns32>(aRows.size());
|
||||
sTableDescData.m_ppRows = (A3DPDFTableRowDesc**)malloc(aRows.size() * A3DUns32(sizeof(A3DPDFTableRowDesc*)));
|
||||
for (size_t i = 0; i < aRows.size(); i++)
|
||||
sTableDescData.m_ppRows[i] = aRows[i];
|
||||
sTableDescData.m_pStyle = pStyle;
|
||||
iResult = A3DPDFTableCreateFromDesc(pDoc, &sTableDescData, &pTable);
|
||||
return iResult;
|
||||
}
|
||||
|
||||
A3DStatus BuildPDFDocument()
|
||||
{
|
||||
@@ -401,12 +399,10 @@ A3DStatus BuildPDFDocument()
|
||||
|
||||
sInformationData.m_pcTitle = const_cast<A3DUTF8Char*>("HOOPS Publish Functionalities");
|
||||
sInformationData.m_pcCreator = const_cast<A3DUTF8Char*>("HOOPS Publish Sample Application");
|
||||
sInformationData.m_pcSubject = const_cast<A3DUTF8Char*>("This sample shows miscellaneous functionalities of HOOS Publish");
|
||||
sInformationData.m_pcSubject = const_cast<A3DUTF8Char*>("This sample shows miscellaneous functionalities of HOOPS Publish");
|
||||
sInformationData.m_pcAuthor = const_cast<A3DUTF8Char*>("Tech Soft 3D");
|
||||
CHECK_RET(A3DPDFDocumentSetInformation(pDoc, &sInformationData));
|
||||
|
||||
|
||||
|
||||
A3DPDFPage* pPage = NULL;
|
||||
|
||||
// creating a poster image to be used as a poster for 3D.
|
||||
@@ -421,7 +417,7 @@ A3DStatus BuildPDFDocument()
|
||||
sPageData.m_ePageSize = kA3DPDFPageLetter; // standard letter format: 612 x 792
|
||||
int iPageWidth = 792, iPageHeight = 612;
|
||||
CHECK_RET(A3DPDFDocumentAppendNewPage2(pDoc, &sPageData, &pPage));
|
||||
|
||||
|
||||
if (pPage != NULL)
|
||||
{
|
||||
// all the posX and posY parameters for WriteImage are from the bottom left!
|
||||
@@ -558,20 +554,6 @@ A3DStatus BuildPDFDocument()
|
||||
|
||||
if (pPage != NULL)
|
||||
{
|
||||
// table creation
|
||||
// Warning: table creation is only available using the free add-on TableToPDF.
|
||||
// The usage of tables using HOOPS Publish add-on requires our customer's
|
||||
// application to comply with LGPL requirements.
|
||||
// TableToPDF can be downloaded at http://developer.techsoft3d.com/tabletopdf/.
|
||||
// The deployment process is simple and just requires to copy the provided DLLs in
|
||||
// the HOOPS Publish binaries folder.
|
||||
|
||||
A3DPDFTable* pTable;
|
||||
A3DPDFTableData sTableData;
|
||||
A3D_INITIALIZE_DATA(A3DPDFTableData, sTableData);
|
||||
sTableData.m_pcHtmlTable = pcHtmlTablePage1;
|
||||
sTableData.m_pcHtmlStyle = pcHtmlStyle;
|
||||
|
||||
// all the posX and posY parameters for WriteImage are from the bottom left!
|
||||
|
||||
// logo image
|
||||
@@ -617,26 +599,106 @@ A3DStatus BuildPDFDocument()
|
||||
CHECK_RET(WriteTextString(pDoc, pPage, kA3DPDFFontHelveticaBold, 12, COL_BLACK,
|
||||
"Deviation Distribution", 230, iPageHeight - 520));
|
||||
|
||||
// Warning: the TableToPDF DLL must be in the HOOPS Publish binary directory.
|
||||
iRet = A3DPDFTableCreate(pDoc, &sTableData, &pTable);
|
||||
if (iRet == A3DPDF_CANNOT_LOAD_TABLETOPDF_DLL)
|
||||
{
|
||||
std::cout << "The TableToPDF add-on is required to run this sample. Please add the binaries from the Tabletopdf_redist archive to this installation then run this sample again.\n";
|
||||
// table creation
|
||||
|
||||
CHECK_RET(WriteTextString(pDoc, pPage, kA3DPDFFontHelveticaBold, 20, COL_RED,
|
||||
"The TableToPDF add-on is required to add table on this page", 10, iPageHeight - 600));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3 columns size 100 makes table size 300
|
||||
int iLeft = (iPageWidth - 300) / 2;
|
||||
CHECK_RET(A3DPDFPageInsertTable(pPage, pTable, iLeft, iPageHeight - 540));
|
||||
}
|
||||
A3DPDFTable* pTable = nullptr;
|
||||
// table description: defined similar to html, with definitions of rows, cells, and colspan and rowpans for scenario with cells merged.
|
||||
// styles (including cells widths and heigths) are defined at level of (by order of priority) table, then rows, then cells.
|
||||
std::vector<A3DPDFTableCellDesc*> aCells;
|
||||
std::vector<A3DPDFTableRowDesc*> aRows;
|
||||
|
||||
A3DPDFRgbColorData colorBlack;
|
||||
A3D_INITIALIZE_DATA(A3DPDFRgbColorData, colorBlack);
|
||||
colorBlack.m_dGreen = colorBlack.m_dBlue = colorBlack.m_dRed = 0.;
|
||||
A3DPDFRgbColorData colorGreyLight;
|
||||
A3D_INITIALIZE_DATA(A3DPDFRgbColorData, colorGreyLight);
|
||||
colorGreyLight.m_dRed = colorGreyLight.m_dGreen = colorGreyLight.m_dBlue = 0.85; // GreyLight
|
||||
|
||||
A3DPDFTableStyleData sStyleTableRowHeader;
|
||||
CreateStyle(10, "MyriadPro,Bold", &colorBlack, &colorBlack, &colorGreyLight, kA3DPDFTableAlignHCentered,
|
||||
kA3DPDFTableAlignVMiddle, 12, 100, 0, 0, 0, 0, sStyleTableRowHeader);
|
||||
A3DPDFTableStyleData sStyleTable;
|
||||
CreateStyle(10, "MyriadPro", &colorBlack, &colorBlack, nullptr, kA3DPDFTableAlignHCentered,
|
||||
kA3DPDFTableAlignVMiddle, 12, 100, 0, 0, 0, 0, sStyleTable);
|
||||
|
||||
//ROW 0 for Header - style defined at row level
|
||||
aCells.clear();
|
||||
AddTableCellDesc(aCells, NOSPAN, NOSPAN, "Deviation", nullptr);
|
||||
AddTableCellDesc(aCells, NOSPAN, NOSPAN, "# of Points", nullptr);
|
||||
AddTableCellDesc(aCells, NOSPAN, NOSPAN, "% of Total", nullptr);
|
||||
AddTableRowDesc(aRows, aCells, &sStyleTableRowHeader);
|
||||
|
||||
// Rows with data - no specific style on row, style will be the one defined at table level
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.109", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "16903", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "33.9", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.218", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "5124", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "10.3", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.327", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "7811", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "15.6", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.436", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "7811", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "15.6", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.545", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "6605", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "13.2", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.654", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "1688", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "3.4", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.763", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "1279", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "2.6", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.872", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "1109", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "2.2", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "0.981", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "1035", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "2.1", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
aCells.clear();
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "1.09", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "565", nullptr));
|
||||
CHECK_RET(AddTableCellDesc(aCells, NOSPAN, NOSPAN, "1.1", nullptr));
|
||||
CHECK_RET(AddTableRowDesc(aRows, aCells, nullptr));
|
||||
|
||||
// table creation
|
||||
CHECK_RET(CreateTableDesc(pDoc, pTable, aRows, &sStyleTable));
|
||||
// 3 columns size 100 makes table size 300
|
||||
int iLeft = (iPageWidth - 300) / 2;
|
||||
CHECK_RET(A3DPDFPageInsertTable(pPage, pTable, iLeft, iPageHeight - 540));
|
||||
|
||||
// bottom text line
|
||||
CHECK_RET(WriteTextString(pDoc, pPage, kA3DPDFFontHelvetica, 10, COL_BLACK,
|
||||
"Adden & Hart LLC., 123 ABC Way, Dublin, Ireland | +353.1.847.6324 | www.addenandhart.com", 93, iPageHeight - 780));
|
||||
|
||||
|
||||
// creating a poster image to be used as a poster for 3D.
|
||||
A3DPDFImage* pImage = NULL;
|
||||
A3DPDFImageCreateFromFile(pDoc, IN_POSTER_IMAGE1, kA3DPDFImageFormatUnknown, &pImage);
|
||||
@@ -724,7 +786,7 @@ int main(int, A3DUTF8Char**)
|
||||
setenv("LC_NUMERIC", "en_US.UTF-8", 1); // Locally force locale
|
||||
#endif
|
||||
// init A3DLIB library - automatically handled init/terminate
|
||||
A3DSDKHOOPSPublishLoader sHoopsPublishLoader(_T(HOOPS_BINARY_DIRECTORY));
|
||||
A3DSDKHOOPSPublishLoader sHoopsPublishLoader(_T(HOOPS_BINARY_DIRECTORY), HOOPS_LICENSE);
|
||||
CHECK_RET(sHoopsPublishLoader.m_eSDKStatus);
|
||||
CHECK_RET(A3DDllSetCallbacksMemory(CheckMalloc, CheckFree));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user