Skip to content

Commit

Permalink
Добавлена обработка нескольких правил размеров, исправлена спецификац…
Browse files Browse the repository at this point in the history
…ия в АС22
  • Loading branch information
kuvbur committed Nov 16, 2024
1 parent a417a3a commit d99181d
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 80 deletions.
23 changes: 22 additions & 1 deletion Sources/AddOn/CommonFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,38 @@ void DBprnt (GS::UniString msg, GS::UniString reportString)
{
#if defined(TESTING)
if (msg.Contains ("err") || msg.Contains ("ERROR") || reportString.Contains ("err") || reportString.Contains ("ERROR")) {
#if defined(AC_22)
DBPrintf ("== ERROR == ");
#else
DBPrint ("== ERROR == ");
#endif
}
#if defined(AC_22)
DBPrintf ("== SMSTF == ");
#else
DBPrint ("== SMSTF == ");
#endif
std::string var_str = msg.ToCStr (0, MaxUSize, GChCode).Get ();
#if defined(AC_22)
DBPrintf (var_str.c_str ());
#else
DBPrint (var_str.c_str ());
#endif
if (!reportString.IsEmpty ()) {
DBPrint (" : ");
std::string reportString_str = reportString.ToCStr (0, MaxUSize, GChCode).Get ();
#if defined(AC_22)
DBPrintf (" : ");
DBPrintf (reportString_str.c_str ());
#else
DBPrint (" : ");
DBPrint (reportString_str.c_str ());
#endif
}
#if defined(AC_22)
DBPrintf ("\n");
#else
DBPrint ("\n");
#endif
#else
UNUSED_VARIABLE (msg);
UNUSED_VARIABLE (reportString);
Expand Down
177 changes: 101 additions & 76 deletions Sources/AddOn/Dimensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool DimParsePref (GS::UniString& rawrule, DimRule& dimrule, bool& hasexpression
} else {
dimrule.pen_original = std::atoi (partstring_1[0].ToCStr ());
}
if (partstring_1[1].IsEqual ("Delete_Wall")) {
if (partstring_1[1].IsEqual ("DeleteWall")) {
dimrule.flag_change = true;
dimrule.flag_deletewall = true;
dimrule.pen_rounded = dimrule.pen_original;
Expand All @@ -116,6 +116,11 @@ bool DimParsePref (GS::UniString& rawrule, DimRule& dimrule, bool& hasexpression
dimrule.pen_rounded = dimrule.pen_original;
return true;
}
if (partstring_1[1].IsEqual ("CheckCustom")) {
dimrule.flag_change = false;
dimrule.flag_custom = true;
return true;
}
GS::Array<GS::UniString> partstring_2;
if (StringSplt (partstring_1[1], ",", partstring_2) > 1) {
dimrule.round_value = std::atoi (partstring_2[0].ToCStr ());
Expand All @@ -131,6 +136,11 @@ bool DimParsePref (GS::UniString& rawrule, DimRule& dimrule, bool& hasexpression
dimrule.flag_reset = true;
return true;
}
if (partstring_2[2].IsEqual ("CheckCustom")) {
dimrule.flag_change = false;
dimrule.flag_custom = true;
return true;
}
if (partstring_2[2].Contains ("{") && partstring_2[2].Contains ("}")) {
ParamDictValue paramDict;
GS::UniString expression = partstring_2[2];
Expand All @@ -142,7 +152,6 @@ bool DimParsePref (GS::UniString& rawrule, DimRule& dimrule, bool& hasexpression
} else {
dimrule.flag_change = (std::atoi (partstring_2[2].ToCStr ()) > 0);
}

}
if (partstring_2.GetSize () == 4) {
if (partstring_2[3].IsEqual ("Delete_Wall")) {
Expand Down Expand Up @@ -205,10 +214,15 @@ GSErrCode DimAutoRound (const API_Guid& elemGuid, DimRules& dimrules, ParamDictV
short pen_original = element.dimension.defNote.notePen;
short pen_rounded = 0;
bool flag_change_rule = false;
bool find_rule = false;
GS::UniString kstr = GS::UniString::Printf ("%d", pen_dimenstion);
if (pen_dimenstion > 0 && dimrules.ContainsKey (kstr)) find_rule = true;
if (!find_rule) {
GS::Array<DimRule> rules; //Массив найденных правил

if (pen_dimenstion > 0 && dimrules.ContainsKey (kstr)) {
DimRule d = dimrules.Get (kstr);
rules.Push (d);
}
// Если в файле только одно правило, и оно уже найдено - не смыслы запрашивать имя слоя
if (!(!rules.IsEmpty () && dimrules.GetSize () == 1)) {
API_Attribute layer;
BNZeroMemory (&layer, sizeof (API_Attribute));
layer.header.typeID = API_LayerID;
Expand All @@ -222,21 +236,13 @@ GSErrCode DimAutoRound (const API_Guid& elemGuid, DimRules& dimrules, ParamDictV
const GS::UniString& regexpstring = *cIt->key;
#endif
if (layert.Contains (regexpstring)) {
kstr = regexpstring;
find_rule = true;
break;
DimRule d = dimrules.Get (regexpstring);
rules.Push (d);
}
}
}

}
// Нет подходящего привали - выходим
if (!find_rule) return err;
DimRule dimrule = dimrules[kstr];
pen_rounded = dimrule.pen_rounded;
flag_change_rule = dimrule.flag_change;
short pen = pen_rounded;
pen_original = pen_dimenstion; // Быстрофикс
bool flag_write = false;
if (rules.IsEmpty ()) return err;
API_ElementMemo memo;
BNZeroMemory (&memo, sizeof (API_ElementMemo));
err = ACAPI_Element_GetMemo (element.header.guid, &memo);
Expand All @@ -245,79 +251,98 @@ GSErrCode DimAutoRound (const API_Guid& elemGuid, DimRules& dimrules, ParamDictV
ACAPI_DisposeElemMemoHdls (&memo);
return err;
}
API_Guid bef_elemGuid = (*memo.dimElems)[0].base.base.guid;
for (Int32 k = 1; k < element.dimension.nDimElem; k++) {
UInt32 flag_change = DIM_NOCHANGE;
UInt32 flag_highlight = DIM_NOCHANGE;
auto& dimElem = (*memo.dimElems)[k];
API_ElemTypeID elementType;
bool flag_write = false;
for (auto dimrule : rules) {
pen_rounded = dimrule.pen_rounded;
flag_change_rule = dimrule.flag_change;
short pen = pen_rounded;
pen_original = pen_dimenstion; // Быстрофикс
API_Guid bef_elemGuid = (*memo.dimElems)[0].base.base.guid;
for (Int32 k = 1; k < element.dimension.nDimElem; k++) {
UInt32 flag_change = DIM_NOCHANGE;
UInt32 flag_highlight = DIM_NOCHANGE;
auto& dimElem = (*memo.dimElems)[k];
API_ElemTypeID elementType;
#if defined AC_26 || defined AC_27 || defined AC_28
elementType = dimElem.base.base.type.typeID;
elementType = dimElem.base.base.type.typeID;
#else
elementType = dimElem.base.base.typeID;
elementType = dimElem.base.base.typeID;
#endif // AC_26

// TODO Баг в архикаде - при обработке размеров, привязанных к колонне - они слетают.
if (dimElem.dimVal == 0 && elementType == API_ColumnID) {
ACAPI_DisposeElemMemoHdls (&memo);
return err;
};
if (dimElem.dimVal == 0) continue;
GS::UniString content = GS::UniString::Printf ("%s", dimElem.note.content);
API_Guid ref_elemGuid = dimElem.base.base.guid;
if (ref_elemGuid != bef_elemGuid) ref_elemGuid = APINULLGuid;
API_NoteContentType contentType = dimElem.note.contentType;
if (DimParse (dimElem.dimVal, ref_elemGuid, contentType, content, flag_change, flag_highlight, dimrule, propertyParams)) {
if (!flag_change_rule && flag_change != DIM_CHANGE_FORCE) flag_change = DIM_CHANGE_OFF;
if (flag_change == DIM_CHANGE_ON || flag_change == DIM_CHANGE_FORCE) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Custom;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString (content);
}
if (flag_change == DIM_CHANGE_OFF && dimElem.note.contentType != API_NoteContent_Measured) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Measured;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
// TODO Баг в архикаде - при обработке размеров, привязанных к колонне - они слетают.
if (dimElem.dimVal == 0 && elementType == API_ColumnID) {
ACAPI_DisposeElemMemoHdls (&memo);
return err;
};
if (dimElem.dimVal == 0) continue;
GS::UniString content = GS::UniString::Printf ("%s", dimElem.note.content);
API_Guid ref_elemGuid = dimElem.base.base.guid;
if (ref_elemGuid != bef_elemGuid) ref_elemGuid = APINULLGuid;
API_NoteContentType contentType = dimElem.note.contentType;
if (DimParse (dimElem.dimVal, ref_elemGuid, contentType, content, flag_change, flag_highlight, dimrule, propertyParams)) {
if (!flag_change_rule && flag_change != DIM_CHANGE_FORCE) flag_change = DIM_CHANGE_OFF;
if (flag_change == DIM_CHANGE_ON || flag_change == DIM_CHANGE_FORCE) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Custom;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString (content);
}
if (flag_change == DIM_CHANGE_OFF && dimElem.note.contentType != API_NoteContent_Measured && flag_change_rule) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Measured;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
}
if (flag_highlight == DIM_HIGHLIGHT_ON) pen = pen_rounded;
if (flag_highlight == DIM_HIGHLIGHT_OFF) pen = pen_original;
if (flag_highlight != DIM_NOCHANGE && dimElem.note.notePen != pen) {
flag_write = true;
(*memo.dimElems)[k].note.notePen = pen;
}
}
if (flag_highlight == DIM_HIGHLIGHT_ON) pen = pen_rounded;
if (flag_highlight == DIM_HIGHLIGHT_OFF) pen = pen_original;
if (flag_highlight != DIM_NOCHANGE && dimElem.note.notePen != pen) {
flag_write = true;
(*memo.dimElems)[k].note.notePen = pen;
// Отключение показа толщин стен
if (dimrule.flag_deletewall) {
// Текс был пустой, запись не планировалась - но это не стена. Возвращаем текст.
if (content.IsEmpty () && !flag_write && (elementType != API_WallID || ref_elemGuid == APINULLGuid)) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Measured;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
}
// Текст не пустой и это стена
if (!content.IsEmpty () && elementType == API_WallID && ref_elemGuid != APINULLGuid) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Custom;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
}
}
}
// Отключение показа толщин стен
if (dimrule.flag_deletewall) {
// Текс был пустой, запись не планировалась - но это не стена. Возвращаем текст.
if (content.IsEmpty () && !flag_write && (elementType != API_WallID || ref_elemGuid == APINULLGuid)) {
// Сброс пользовательского текста
if (dimrule.flag_reset && dimElem.note.contentType != API_NoteContent_Measured) {
flag_write = true;
(*memo.dimElems)[k].note.notePen = pen_original;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Measured;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
}
// Текст не пустой и это стена
if (!content.IsEmpty () && elementType == API_WallID && ref_elemGuid != APINULLGuid) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Custom;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
// Проверка перебитых размеров
if (dimrule.flag_custom) {
if (contentType == API_NoteContent_Custom && dimElem.note.notePen != pen_rounded) {
flag_write = true;
(*memo.dimElems)[k].note.notePen = pen_rounded;
}
if (contentType == API_NoteContent_Measured && dimElem.note.notePen != pen_original && !flag_write) {
flag_write = true;
(*memo.dimElems)[k].note.notePen = pen_original;
}
}
bef_elemGuid = dimElem.base.base.guid;
}
// Сброс пользовательского текста
if (dimrule.flag_reset && dimElem.note.contentType != API_NoteContent_Measured) {
flag_write = true;
(*memo.dimElems)[k].note.contentType = API_NoteContent_Measured;
if ((*memo.dimElems)[k].note.contentUStr != nullptr)
delete (*memo.dimElems)[k].note.contentUStr;
(*memo.dimElems)[k].note.contentUStr = new GS::UniString ("");
}
bef_elemGuid = dimElem.base.base.guid;
}
if (flag_write) {
API_Element mask;
Expand Down
1 change: 1 addition & 0 deletions Sources/AddOn/Dimensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef struct
bool flag_change = false;
bool flag_deletewall = false;
bool flag_reset = false;
bool flag_custom = false;
GS::UniString expression = "";
GS::UniString layer = "";
ParamDictValue paramDict;
Expand Down
2 changes: 1 addition & 1 deletion Sources/AddOn/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3731,7 +3731,7 @@ void ParamHelpers::GetAllAttributeToParamDict (ParamDictValue& propertyParams)
}
ParamHelpers::AddValueToParamDictValue (propertyParams, "flag:has_attrib");
DBprnt (" GetAllAttributeToParamDict end");
}
}

// --------------------------------------------------------------------
// Получение списка глобальных переменных о местоположении проекта, солнца
Expand Down
2 changes: 1 addition & 1 deletion Sources/AddOn/SomeStuff_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ static GSErrCode __ACENV_CALL ProjectEventHandlerProc (API_NotifyEventID noti
break;
case APINotify_ChangeWindow:
case APINotify_ChangeFloor:
DimRoundAll (syncSettings);
break;
default:
break;
}
(void) param;
DimRoundAll (syncSettings);
return NoError;
} // ProjectEventHandlerProc

Expand Down
6 changes: 5 additions & 1 deletion Sources/AddOn/Spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ GSErrCode GetElementForPlace (const GS::UniString& favorite_name, API_Element& e
element.header.type.typeID = API_ObjectID;
#else
element.header.typeID = API_ObjectID;
#endif
#ifdef AC_22
element.header.variationID = APIVarId_Object;
#endif
err = ACAPI_Element_GetDefaults (&element, &memo);
if (err != NoError) {
Expand Down Expand Up @@ -894,6 +897,7 @@ GSErrCode PlaceElements (GS::Array<ElementDict>& elementstocreate, ParamDictValu
if (err != NoError) {
ACAPI_DisposeElemMemoHdls (&memo);
msg_rep ("Spec::PlaceElements", "ACAPI_Element_GetDefaults", err, APINULLGuid);
continue;
}
bool flag_find_row = GetSizePlaceElement (element, memo, dx, dy);
// Запись параметров
Expand Down Expand Up @@ -1033,7 +1037,7 @@ GSErrCode PlaceElements (GS::Array<ElementDict>& elementstocreate, ParamDictValu
err = ACAPI_Goodies (APIAny_RunGDLParScriptID, &elemsheader[i], 0);
#endif
if (err != NoError) msg_rep ("Spec::PlaceElements", "APIAny_RunGDLParScriptID", err, APINULLGuid);
}
}
return NoError;
}
}

0 comments on commit d99181d

Please sign in to comment.