Skip to content

Commit

Permalink
Добавил логи
Browse files Browse the repository at this point in the history
  • Loading branch information
kuvbur committed Sep 5, 2023
1 parent 0fb67f1 commit 8951444
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 25 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# User-specific files
*.rsuser
*.suo
*.pln
*.bpn
*.lck
*.user
Expand Down
6 changes: 5 additions & 1 deletion Sources/AddOn/Dimensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
GSErrCode DimReadPref(DimRules& dimrules) {
GS::Array<GS::ArrayFB<GS::UniString, 3> > autotexts;
API_AutotextType type = APIAutoText_Custom;
DBPrintf ("== SMSTF == DimReadPref start\n");
GSErrCode err = ACAPI_Goodies(APIAny_GetAutoTextsID, &autotexts, (void*)(GS::IntPtr)type);
if (err != NoError) {
msg_rep("DimReadPref", "ACAPI_Goodies", err, APINULLGuid);
Expand Down Expand Up @@ -58,9 +59,11 @@ GSErrCode DimReadPref(DimRules& dimrules) {
dimrules.Add(kstr, dimrule);
}
}
DBPrintf ("== SMSTF == DimReadPref end!!\n");
return err;
}
}
DBPrintf ("== SMSTF == DimReadPref end\n");
return err;
}

Expand Down Expand Up @@ -345,15 +348,16 @@ void DimRoundAll(const SyncSettings& syncSettings) {
(void)syncSettings;
DoneElemGuid doneelemguid;
DimRules dimrules;
DBPrintf ("== SMSTF == DimRoundAll start\n");
const GSErrCode err = DimReadPref(dimrules);
if (dimrules.GetSize() == 0 || err != NoError) return;
bool flag_chanel = false;
ParamDictValue propertyParams;
ParamHelpers::GetAllPropertyDefinitionToParamDict(propertyParams);
if (!flag_chanel) flag_chanel = DimRoundByType(API_DimensionID, doneelemguid, dimrules, propertyParams);

//if (!flag_chanel) flag_chanel = DimRoundByType(API_RadialDimensionID, doneelemguid, dimrules, propertyParams);
//if (!flag_chanel) flag_chanel = DimRoundByType(API_LevelDimensionID, doneelemguid, dimrules, propertyParams);
DBPrintf ("== SMSTF == DimRoundAll end\n");
}

// -----------------------------------------------------------------------------
Expand Down
51 changes: 31 additions & 20 deletions Sources/AddOn/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ void msg_rep(const GS::UniString& modulename, const GS::UniString& reportString,
}
GS::UniString msg = modulename + ": " + reportString + " " + error_type;
ACAPI_WriteReport(msg, false);
DBPrintf (msg.ToCStr());
}

void MenuItemCheckAC(short itemInd, bool checked) {
Expand Down Expand Up @@ -1200,7 +1201,7 @@ bool ParamHelpers::ReadMorphParam(const API_Element& element, ParamDictValue& pd
ParamHelpers::AddVal(pdictvaluemorph, element.header.guid, "morph:", "a", A);
ParamHelpers::AddVal(pdictvaluemorph, element.header.guid, "morph:", "b", B);
ParamHelpers::AddVal(pdictvaluemorph, element.header.guid, "morph:", "zzyzx", ZZYZX);
ParamHelpers::Compare(pdictvaluemorph, pdictvalue, "ReadMorphParam");
ParamHelpers::Compare(pdictvaluemorph, pdictvalue);
ACAPI_DisposeElemMemoHdls(&memo);
return true;
}
Expand Down Expand Up @@ -1645,7 +1646,7 @@ bool ParamHelpers::ReadElemCoords(const API_Element & element, ParamDictValue &
ParamHelpers::AddVal(pdictvaluecoord, element.header.guid, "coord:", "symb_rotangle_mod45", fmod(angz, 45.0));
ParamHelpers::AddVal(pdictvaluecoord, element.header.guid, "coord:", "symb_rotangle_mod90", fmod(angz, 90.0));
ParamHelpers::AddVal(pdictvaluecoord, element.header.guid, "coord:", "symb_rotangle_mod180", fmod(angz, 180.0));
ParamHelpers::Compare(pdictvaluecoord, params, "ReadElemCoords");
ParamHelpers::Compare(pdictvaluecoord, params);
return true;
}

Expand Down Expand Up @@ -2432,13 +2433,15 @@ bool GetElemState(const API_Guid & elemGuid, const GS::Array<API_PropertyDefinit
// --------------------------------------------------------------------
void ParamHelpers::ElementsWrite(ParamDictElement & paramToWrite) {
if (paramToWrite.IsEmpty()) return;
DBPrintf ("== SMSTF == acttype == ElementsWrite start\n");
for (GS::HashTable<API_Guid, ParamDictValue>::PairIterator cIt = paramToWrite.EnumeratePairs(); cIt != NULL; ++cIt) {
ParamDictValue& params = *cIt->value;
API_Guid elemGuid = *cIt->key;
if (!params.IsEmpty()) {
ParamHelpers::Write(elemGuid, params);
}
}
DBPrintf ("== SMSTF == acttype == ElementsWrite end\n");
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -2482,6 +2485,7 @@ void ParamHelpers::Write(const API_Guid & elemGuid, ParamDictValue & params) {
// --------------------------------------------------------------------
void ParamHelpers::InfoWrite(ParamDictElement & paramToWrite) {
if (paramToWrite.IsEmpty()) return;
DBPrintf ("== SMSTF == InfoWrite start\n");
ParamDictValue paramsinfo;
for (GS::HashTable<API_Guid, ParamDictValue>::PairIterator cIt = paramToWrite.EnumeratePairs(); cIt != NULL; ++cIt) {
ParamDictValue& params = *cIt->value;
Expand Down Expand Up @@ -2521,6 +2525,7 @@ void ParamHelpers::WriteGDLValues(const API_Guid & elemGuid, ParamDictValue & pa
if (params.IsEmpty()) return;
if (elemGuid == APINULLGuid) return;
if (params.IsEmpty()) return;
DBPrintf ("== SMSTF == WriteGDLValues\n");
API_Elem_Head elem_head = {};
API_Element element = {};
API_ElemTypeID elemType;
Expand Down Expand Up @@ -2633,6 +2638,7 @@ void ParamHelpers::WriteGDLValues(const API_Guid & elemGuid, ParamDictValue & pa
void ParamHelpers::WritePropertyValues(const API_Guid & elemGuid, ParamDictValue & params) {
if (params.IsEmpty()) return;
if (elemGuid == APINULLGuid) return;
DBPrintf ("== SMSTF == WritePropertyValues\n");
GS::Array<API_Property> properties;
for (GS::HashTable<GS::UniString, ParamValue>::PairIterator cIt = params.EnumeratePairs(); cIt != NULL; ++cIt) {
ParamValue& param = *cIt->value;
Expand All @@ -2647,7 +2653,6 @@ void ParamHelpers::WritePropertyValues(const API_Guid & elemGuid, ParamDictValue
}
}
}

//if (properties.IsEmpty()) return;
//GSErrCode error = ACAPI_Element_SetProperties(elemGuid, properties);
}
Expand Down Expand Up @@ -2718,6 +2723,7 @@ bool ParamHelpers::hasUnreadGlob(ParamDictElement & paramToRead, ParamDictValue
// --------------------------------------------------------------------
void ParamHelpers::ElementsRead(ParamDictElement & paramToRead, ParamDictValue & propertyParams) {
if (paramToRead.IsEmpty()) return;
DBPrintf ("== SMSTF == ElementsRead start\n");
if (ParamHelpers::hasUnreadInfo(paramToRead, propertyParams)) ParamHelpers::GetAllInfoToParamDict(propertyParams);
if (ParamHelpers::hasUnreadGlob(paramToRead, propertyParams)) ParamHelpers::GetAllGlobToParamDict(propertyParams);

Expand All @@ -2731,11 +2737,11 @@ void ParamHelpers::ElementsRead(ParamDictElement & paramToRead, ParamDictValue &
ParamDictValue& params = *cIt->value;
API_Guid elemGuid = *cIt->key;
if (!params.IsEmpty()) {
if (!propertyParams.IsEmpty()) ParamHelpers::Compare(propertyParams, params, "ElementsRead"); // Сопоставляем свойства
if (!propertyParams.IsEmpty()) ParamHelpers::Compare(propertyParams, params); // Сопоставляем свойства
ParamHelpers::Read(elemGuid, params, propertyParams);
}
}
return;
DBPrintf ("== SMSTF == ElementsRead end\n");
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -2841,7 +2847,7 @@ void ParamHelpers::Read(const API_Guid & elemGuid, ParamDictValue & params, Para
needCompare = ParamHelpers::ReadMorphParam(element, paramByType);
}
if (needCompare) {
ParamHelpers::Compare(paramByType, params, paramType);
ParamHelpers::Compare(paramByType, params);
}
}
}
Expand All @@ -2856,6 +2862,7 @@ void ParamHelpers::Read(const API_Guid & elemGuid, ParamDictValue & params, Para
void ParamHelpers::GetAllInfoToParamDict(ParamDictValue & propertyParams) {
GS::Array<GS::ArrayFB<GS::UniString, 3> > autotexts;
API_AutotextType type = APIAutoText_Custom;
DBPrintf ("== SMSTF == GetAllInfoToParamDict\n");
GSErrCode err = ACAPI_Goodies(APIAny_GetAutoTextsID, &autotexts, (void*)(GS::IntPtr)type);
if (err != NoError) {
msg_rep("GetAllInfoToParamDict", "APIAny_GetAutoTextsID", err, APINULLGuid);
Expand All @@ -2881,6 +2888,7 @@ void ParamHelpers::GetAllGlobToParamDict(ParamDictValue & propertyParams) {
GS::UniString rawName = "";
ParamValue pvalue;
API_PlaceInfo placeInfo = {};
DBPrintf ("== SMSTF == GetAllGlobToParamDict\n");
GSErrCode err = ACAPI_Environment(APIEnv_GetPlaceSetsID, &placeInfo, nullptr);
if (err != NoError) {
msg_rep("GetAllGlobToParamDict", "APIEnv_GetPlaceSetsID", err, APINULLGuid);
Expand Down Expand Up @@ -2916,6 +2924,7 @@ void ParamHelpers::GetAllGlobToParamDict(ParamDictValue & propertyParams) {
// Заполнение свойств для элемента
// --------------------------------------------------------------------
void ParamHelpers::GetAllPropertyDefinitionToParamDict(ParamDictValue & propertyParams, const API_Guid & elemGuid) {
DBPrintf ("== SMSTF == GetAllPropertyDefinitionToParamDict\n");
if (elemGuid == APINULLGuid) {
ParamHelpers::GetAllPropertyDefinitionToParamDict(propertyParams);
}
Expand Down Expand Up @@ -3018,7 +3027,7 @@ void ParamHelpers::GetAllPropertyDefinitionToParamDict(ParamDictValue & property
// --------------------------------------------------------------------
// Сопоставление двух словарей ParamDictValue
// --------------------------------------------------------------------
void ParamHelpers::Compare(const ParamDictValue & paramsFrom, ParamDictValue & paramsTo, GS::UniString fname) {
void ParamHelpers::Compare(const ParamDictValue & paramsFrom, ParamDictValue & paramsTo) {
if (paramsFrom.IsEmpty() || paramsTo.IsEmpty()) return;
if (paramsTo.IsEmpty()) return;
UInt32 nparams = paramsTo.GetSize();
Expand Down Expand Up @@ -3173,8 +3182,8 @@ bool ParamHelpers::ReadGDLValues(const API_Element & element, const API_Elem_Hea
if (!paramByName.IsEmpty()) flag_find_name = ParamHelpers::GDLParamByName(element, elem_head, paramByName);

if (flag_find_desc && flag_find_name) {
ParamHelpers::Compare(paramBydescription, params, "GDLParamByDescription");
ParamHelpers::Compare(paramByName, params, "GDLParamByName");
ParamHelpers::Compare(paramBydescription, params);
ParamHelpers::Compare(paramByName, params);
}
else {
if (flag_find_desc) params = paramBydescription;
Expand Down Expand Up @@ -3290,7 +3299,7 @@ bool ParamHelpers::ReadMaterial(const API_Element & element, ParamDictValue & pa

// В свойствах могли быть ссылки на другие свойста. Проверим, распарсим
if (!paramsAdd.IsEmpty()) {
ParamHelpers::Compare(propertyParams, paramsAdd, "ReadMaterial");
ParamHelpers::Compare(propertyParams, paramsAdd);
GS::HashTable<API_AttributeIndex, bool> existsmaterial; // Словарь с уже прочитанными материалами
for (GS::HashTable<GS::UniString, ParamValue>::PairIterator cIt = paramlayers.EnumeratePairs(); cIt != NULL; ++cIt) {
ParamValue& param_composite = *cIt->value;
Expand Down Expand Up @@ -3330,23 +3339,25 @@ bool ParamHelpers::ReadMaterial(const API_Element & element, ParamDictValue & pa
API_AttributeIndex constrinx = param_composite.composite[i].inx;

// Если нужно заполнить толщину
if (params.ContainsKey("{@material:layer thickness}")) {
GS::UniString layer_thickness = "{@material:layer thickness}";
if (params.ContainsKey(layer_thickness)) {
double fillThick = param_composite.composite[i].fillThick;
GS::UniString formatsting = params.Get("{@material:layer thickness}").val.stringformat;
GS::UniString formatsting = params.Get(layer_thickness).val.stringformat;
if (formatsting.IsEmpty()) {
formatsting = "1mm";
params.Get("{@material:layer thickness}").val.stringformat = formatsting;
params.Get("{@material:layer thickness}").val.n_zero = 1;
params.Get(layer_thickness).val.stringformat = formatsting;
params.Get(layer_thickness).val.n_zero = 1;
}
GS::UniString fillThickstring = PropertyHelpers::NumToString(fillThick, formatsting);
templatestring.ReplaceAll("{@material:layer thickness}", fillThickstring);
templatestring.ReplaceAll(layer_thickness, fillThickstring);
}
templatestring.ReplaceAll("{@material:n}", GS::UniString::Printf("%d", i + 1));

// Если для материала было указано уникальное наименование - заменим его
GS::UniString attribsuffix = CharENTER + GS::UniString::Printf("%d", constrinx) + "}";
if (params.ContainsKey("{@property:sync_name" + attribsuffix)) {
if (params.Get("{@property:sync_name" + attribsuffix).isValid) templatestring.ReplaceAll("{@property:buildingmaterialproperties/building material name", "{@property:sync_name");
GS::UniString syncname = "{@property:sync_name" + attribsuffix;
if (params.ContainsKey(syncname)) {
if (params.Get(syncname).isValid && !params.Get(syncname).property.isDefault) templatestring = "{@property:sync_name}";
}
templatestring.ReplaceAll("}", attribsuffix);
if (ParamHelpers::ReplaceParamInExpression(params, templatestring)) {
Expand Down Expand Up @@ -3850,7 +3861,7 @@ bool ParamHelpers::GetComponentsBasicStructure(const API_AttributeIndex & constr
for (GS::HashTable<GS::UniString, ParamValue>::PairIterator cIt = paramlayers.EnumeratePairs(); cIt != NULL; ++cIt) {
paramlayers.Get(*cIt->key).composite = param_composite.composite;
}
ParamHelpers::Compare(paramlayers, params, "GetComponentsBasicStructure");
ParamHelpers::Compare(paramlayers, params);
return true;
}

Expand Down Expand Up @@ -3893,7 +3904,7 @@ bool ParamHelpers::GetComponentsCompositeStructure(const API_Guid & elemguid, AP
for (GS::HashTable<GS::UniString, ParamValue>::PairIterator cIt = paramlayers.EnumeratePairs(); cIt != NULL; ++cIt) {
paramlayers.Get(*cIt->key).composite = param_composite.composite;
}
ParamHelpers::Compare(paramlayers, params, "GetComponentsCompositeStructure");
ParamHelpers::Compare(paramlayers, params);
ACAPI_DisposeAttrDefsHdls(&defs);
return true;
}
Expand Down Expand Up @@ -4041,7 +4052,7 @@ bool ParamHelpers::GetComponentsProfileStructure(ProfileVectorImage & profileDes
paramlayers.Get(*cIt->key).composite = paramout;
}
}
ParamHelpers::Compare(paramlayers, params, "GetComponentsProfileStructure");
ParamHelpers::Compare(paramlayers, params);
}
return hasData;
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AddOn/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ namespace ParamHelpers {
// --------------------------------------------------------------------
// Сопоставление двух словарей ParamDictValue
// --------------------------------------------------------------------
void Compare(const ParamDictValue& paramsFrom, ParamDictValue& paramsTo, GS::UniString fname);
void Compare(const ParamDictValue& paramsFrom, ParamDictValue& paramsTo);

// --------------------------------------------------------------------
// Чтение значений свойств в ParamDictValue
Expand Down
18 changes: 17 additions & 1 deletion Sources/AddOn/SomeStuff_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static GSErrCode __ACENV_CALL ReservationChangeHandler(const GS::HashTable<API_G
const GS::HashSet<API_Guid>& deleted) {
(void)deleted;
(void)released;
DBPrintf ("== SMSTF == ReservationChangeHandler\n");
SyncSettings syncSettings(false, false, true, true, true, true, false);
LoadSyncSettingsFromPreferences(syncSettings);
#ifdef PK_1
Expand All @@ -41,6 +42,7 @@ static GSErrCode __ACENV_CALL ReservationChangeHandler(const GS::HashTable<API_G
// Срабатывает при событиях проекта (открытие, сохранение)
// -----------------------------------------------------------------------------
static GSErrCode __ACENV_CALL ProjectEventHandlerProc(API_NotifyEventID notifID, Int32 param) {
DBPrintf ("== SMSTF == ProjectEventHandlerProc\n");
SyncSettings syncSettings(false, false, true, true, true, true, false);
LoadSyncSettingsFromPreferences(syncSettings);
#ifdef PK_1
Expand Down Expand Up @@ -86,11 +88,15 @@ GSErrCode __ACENV_CALL ElementEventHandlerProc(const API_NotifyElementType* elem
if (elemType->notifID == APINotifyElement_BeginEvents || elemType->notifID == APINotifyElement_EndEvents) return NoError;
if (elemType->elemHead.hotlinkGuid != APINULLGuid) return false;
// Смотрим - что поменялось
DBPrintf ("== SMSTF == ElementEventHandlerProc start\n");
API_ActTranPars actTranPars;
ACAPI_Notify_GetTranParams(&actTranPars);
API_EditCmdID acttype = actTranPars.typeID;
if (acttype == APIEdit_Drag) {
if (is_equal(actTranPars.theDisp.x,0) && is_equal(actTranPars.theDisp.y, 0) && is_equal(actTranPars.theDispZ, 0)) return NoError;
if (is_equal(actTranPars.theDisp.x, 0) && is_equal(actTranPars.theDisp.y, 0) && is_equal(actTranPars.theDispZ, 0)) {
DBPrintf ("== SMSTF == acttype == APIEdit_Drag\n");
return NoError;
}
}

#ifdef AC_26
Expand All @@ -116,6 +122,7 @@ GSErrCode __ACENV_CALL ElementEventHandlerProc(const API_NotifyElementType* elem
default:
break;
}
DBPrintf ("== SMSTF == ElementEventHandlerProc end\n");
return NoError;
} // ElementEventHandlerProc

Expand All @@ -126,12 +133,15 @@ void Do_ElementMonitor(bool& syncMon) {
#ifdef PK_1
syncMon = true;
#endif

if (syncMon) {
DBPrintf ("== SMSTF == Do_ElementMonitor on\n");
ACAPI_Notify_CatchNewElement(nullptr, ElementEventHandlerProc); // for all elements
ACAPI_Notify_InstallElementObserver(ElementEventHandlerProc);
ACAPI_Notify_CatchElementReservationChange(ReservationChangeHandler);
}
if (!syncMon) {
DBPrintf ("== SMSTF == Do_ElementMonitor off\n");
ACAPI_Notify_CatchNewElement(nullptr, nullptr);
ACAPI_Notify_InstallElementObserver(nullptr);
ACAPI_Notify_CatchElementReservationChange(nullptr);
Expand All @@ -152,6 +162,7 @@ void MenuSetState(SyncSettings& syncSettings) {

static GSErrCode MenuCommandHandler(const API_MenuParams* menuParams) {
GSErrCode err = NoError;
DBPrintf ("== SMSTF == MenuCommandHandler start\n");
SyncSettings syncSettings(false, false, true, true, true, true, false);
LoadSyncSettingsFromPreferences(syncSettings);
#ifdef PK_1
Expand Down Expand Up @@ -211,22 +222,26 @@ static GSErrCode MenuCommandHandler(const API_MenuParams* menuParams) {
MenuSetState(syncSettings);
ACAPI_Interface(APIIo_CloseProcessWindowID, nullptr, nullptr);
ACAPI_KeepInMemory(true);
DBPrintf ("== SMSTF == MenuCommandHandler end\n");
return NoError;
}

API_AddonType __ACDLL_CALL CheckEnvironment(API_EnvirParams* envir) {
DBPrintf ("== SMSTF == CheckEnvironment\n");
RSGetIndString(&envir->addOnInfo.name, AddOnInfoID, AddOnNameID, ACAPI_GetOwnResModule());
RSGetIndString(&envir->addOnInfo.description, AddOnInfoID, AddOnDescriptionID, ACAPI_GetOwnResModule());
ACAPI_KeepInMemory(true);
return APIAddon_Preload;
}

GSErrCode __ACDLL_CALL RegisterInterface(void) {
DBPrintf ("== SMSTF == RegisterInterface\n");
GSErrCode err = ACAPI_Register_Menu(AddOnMenuID, AddOnPromtID, MenuCode_Tools, MenuFlag_Default);
return err;
}

GSErrCode __ACENV_CALL Initialize(void) {
DBPrintf ("== SMSTF == Initialize\n");
SyncSettings syncSettings(false, false, true, true, true, true, false);
LoadSyncSettingsFromPreferences(syncSettings);
#ifdef PK_1
Expand All @@ -241,5 +256,6 @@ GSErrCode __ACENV_CALL Initialize(void) {
}

GSErrCode __ACENV_CALL FreeData(void) {
DBPrintf ("== SMSTF == FreeData\n");
return NoError;
}
Loading

0 comments on commit 8951444

Please sign in to comment.