|
@@ -59,45 +59,6 @@ bool BBox_DrawRectangle(corel *cdr) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-#include <thread>
|
|
|
-#include <mutex>
|
|
|
-
|
|
|
-std::mutex mtx;
|
|
|
-
|
|
|
-void groupShapes(std::vector<int> shapes, IVGShapeRangePtr srgp, IVGShapeRangePtr sr) {
|
|
|
- for (int index : shapes) {
|
|
|
- srgp->Add(sr->Shapes->Item[index]);
|
|
|
- }
|
|
|
- if (shapes.size() > 1) {
|
|
|
-
|
|
|
- mtx.lock();
|
|
|
- srgp->Group();
|
|
|
- mtx.unlock();
|
|
|
- }
|
|
|
- srgp->RemoveAll();
|
|
|
-}
|
|
|
-
|
|
|
-void processGroups(std::map<int, std::vector<int>> groups, corel* cdr , IVGShapeRangePtr sr) {
|
|
|
- std::vector<std::thread> threads;
|
|
|
-
|
|
|
- for (const auto& group : groups) {
|
|
|
-
|
|
|
- auto srgp = cdr->CreateShapeRange();
|
|
|
-
|
|
|
-
|
|
|
- threads.emplace_back(groupShapes, group.second, srgp, sr);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (auto& thread : threads) {
|
|
|
- if (thread.joinable()) {
|
|
|
- thread.join();
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -162,13 +123,17 @@ bool Box_AutoGroup(corel *cdr) {
|
|
|
groups[root].push_back(i + 1);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- processGroups(groups, cdr, sr);
|
|
|
+ auto srgp = cdr->CreateShapeRange();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ for (const auto& group : groups) {
|
|
|
+ for (int index : group.second) {
|
|
|
+ srgp->Add(sr->Shapes->Item[index]);
|
|
|
+ }
|
|
|
+ if(sr->Count >1)
|
|
|
+ srgp->Group();
|
|
|
+ srgp->RemoveAll();
|
|
|
+ }
|
|
|
|
|
|
EndOpt(cdr);
|
|
|
return true;
|