Skip to content

Commit

Permalink
ISSUE #695 updated dwg file processor to use our own colour policy, a…
Browse files Browse the repository at this point in the history
…nd updated unit tests
  • Loading branch information
sebjf committed Sep 23, 2024
1 parent a4243b4 commit 37e4f97
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ if (REPO_ASSET_GENERATOR_SUPPORT)
add_subdirectory(submodules/asset_generator)
endif()

if (REPO_SVG_EXPORT_SUPPORT)
if (ODA_SUPPORT AND REPO_SVG_EXPORT_SUPPORT) # (The Svg exporter is an ODA extension so ODA is required)
add_definitions(-DREPO_SVG_EXPORT_SUPPORT)
add_subdirectory(submodules/svgexport)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void FileProcessorDwg::importDrawing(OdDbDatabasePtr pDb)
pDbGiContext->setHatchAsPolygon(OdGiDefaultContext::kHatchPolygon);
dev->properties()->putAt(L"MinimalWidth", OdRxVariantValue(0.08));
dev->properties()->putAt(L"UseHLR", OdRxVariantValue(true));
dev->properties()->putAt(L"ColorPolicy", OdRxVariantValue((OdInt32)2)); // kGrayscale
dev->properties()->putAt(L"ColorPolicy", OdRxVariantValue((OdInt32)3)); // kDarken
pDbGiContext->setPaletteBackground(ODRGB(255, 255, 255));

OdDbBaseDatabasePEPtr pBaseDatabase(pDb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,38 @@ TEST(DrawingImportManager, ImportDWG)

// Check a number of properties that we expect to be consistent

// We expect the dimensions and viewbox to be set, as these are required by the
// frontend.

EXPECT_EQ(svgTree.get<std::string>("svg.<xmlattr>.width"), "1024");
EXPECT_EQ(svgTree.get<std::string>("svg.<xmlattr>.height"), "768");
EXPECT_EQ(svgTree.get<std::string>("svg.<xmlattr>.viewBox"), "0 0 1024 768");


int groupPrimitives = 0;
for (auto g : svgTree.get_child("svg"))
{
// We expect that the white square in the test drawing is drawn as a black
// square, because we set the background of the exporter to White.

auto p = g.second.get_child_optional("polyline");
if (p) {
EXPECT_EQ(g.second.get<std::string>("<xmlattr>.stroke"), "rgb(0,0,0)");
groupPrimitives++;
}

// We expect the Red circle to be off-shade, because we apply a colour
// correction.

auto c = g.second.get_child_optional("circle");
if (c) {
EXPECT_EQ(g.second.get<std::string>("<xmlattr>.stroke"), "rgb(127,0,0)");
groupPrimitives++;
}
}

// And of course expect that the DWG holds the above geometries

EXPECT_EQ(groupPrimitives, 2);
}

0 comments on commit 37e4f97

Please sign in to comment.