Skip to content

Commit

Permalink
Improved work cleaning mtext.
Browse files Browse the repository at this point in the history
Previously, the code did not process the special text (\ l and \ o). Now everything works
Added commands to the menu Modify -> Text
  • Loading branch information
veb86 committed Nov 1, 2018
1 parent ab77501 commit 7c8662c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
27 changes: 9 additions & 18 deletions cad_source/zcad/velec/uzvstripmtext.pas
Expand Up @@ -35,6 +35,7 @@ interface
uzcdrawings, //Drawings manager, all open drawings are processed him
uzccombase,
gzctnrvectortypes,
uzcinterface,
RegExpr;


Expand All @@ -56,53 +57,42 @@ function stripMtext_com(operands:TCommandOperands):TCommandResult;
begin
clearText:=a;
re := TRegExpr.Create;

re.Expression := '(\\\\)';
clearText:= re.Replace(clearText, '#levoeNaklonnayCherta#', false);

re.Expression := '(\\P)';
clearText:= re.Replace(clearText, '#nachaloNovoyStroki#', false);
//HistoryOutStr(clearText);

re.Expression := '(\\{)';
clearText:= re.Replace(clearText, '#figurSkobkaOtkr#', false);
//HistoryOutStr(clearText);

re.Expression := '(\\})';
clearText:= re.Replace(clearText, '#figurSkobkaZakr#', false);
//HistoryOutStr(clearText);

re.Expression := '(\\\\)';
clearText:= re.Replace(clearText, '#levoeNaklonnayCherta#', false);
//HistoryOutStr(clearText);

re.Expression := '\\[^\\]*?;';
clearText:= re.Replace(clearText, '', false);
//HistoryOutStr(clearText);

re.Expression := '[\\][\\]';
clearText:= re.Replace(clearText, '\', false);
//HistoryOutStr(clearText);

re.Expression := '[{}]';
clearText:= re.Replace(clearText, '', false);
//HistoryOutStr(clearText);

re.Expression := '(\\(L|O))';
re.Expression := '(\\([lL]|[oO]))';
clearText:= re.Replace(clearText, '', false);
//HistoryOutStr(clearText);

re.Expression := '(#figurSkobkaOtkr#)';
clearText:= re.Replace(clearText, '\{', false);
//HistoryOutStr(clearText);

re.Expression := '(#figurSkobkaZakr#)';
clearText:= re.Replace(clearText, '\}', false);
//HistoryOutStr(clearText);

re.Expression := '(#nachaloNovoyStroki#)';
clearText:= re.Replace(clearText, '\P', false);
//HistoryOutStr(clearText);

re.Expression := '(#levoeNaklonnayCherta#)';
clearText:= re.Replace(clearText, '\\\\', false);
//HistoryOutStr(clearText);
clearText:= re.Replace(clearText, '\\', false);

re.free;
end;
Expand All @@ -117,8 +107,9 @@ function stripMtext_com(operands:TCommandOperands):TCommandResult;
if pobj^.GetObjType=GDBMTextID then //работа только с кабелями
begin
pmtext:=PGDBObjMText(pobj);
//ZCMsgCallBackInterface.TextMessage('Do : ' + pmtext^.Template,TMWOHistoryOut);
newText:=clearText(pmtext^.Template);

//ZCMsgCallBackInterface.TextMessage('After : ' + newText,TMWOHistoryOut);
pmtext^.Template:=newText;
pmtext^.Content:=newText;
end;
Expand Down
2 changes: 2 additions & 0 deletions environment/runtimefiles/common/menu/actionscontent.xml
Expand Up @@ -87,6 +87,8 @@
<ZAction Name="ACN_POLYED" Command="PolyED" Img="polyed" Caption="Edit polyline"/>
<ZAction Name="ACN_OBJVARMAN" Command="ObjVarMan" Img="varman" Caption="Object variables manager"/>
<ZAction Name="ACN_MULTIOBJVARMAN" Command="MultiObjVarMan" Img="mvarman" Caption="Multi object variables manager"/>
<ZAction Name="ACN_smtextall" Command="stripmtext(ALL)" Img="stripmtextall" Caption="Start command clear mtext all"/>
<ZAction Name="ACN_smtextarea" Command="stripmtext" Img="stripmtextsel" Caption="Start command clear mtext area"/>
</Group>
<Group Category="Draw">
<ZAction Name="ACN_LINE" Command="Line" Img="line" Caption="Line" Hint="Draw line" ShortCut="CTRL+ALT+L" SecondaryShortCuts="L"/>
Expand Down
5 changes: 5 additions & 0 deletions environment/runtimefiles/common/menu/menuscontent.xml
Expand Up @@ -150,6 +150,11 @@
<Action Name="ACN_SCALE"/>
<Action Name="ACN_STRETCH"/>
<Action Name="ACN_MIRROR"/>
<Separator/>
<MainMenuItem Name="Text">
<Action Name="ACN_smtextall"/>
<Action Name="ACN_smtextarea"/>
</MainMenuItem>
<Separator/>
<Action Name="ACN_OBJVARMAN"/>
<Action Name="ACN_MULTIOBJVARMAN"/>
Expand Down
Expand Up @@ -5,8 +5,6 @@
<ZAction Name="ACN_slagcabCom" Command="slagcab" Img="#D()" Caption="Start command panels for autocabeling SL"/>
<ZAction Name="ACN_agslr" Command="AGSLROOM" Img="#ASL" Caption="Start command ASL"/>
<ZAction Name="ACN_SupeLine" Command="DrawSuperLine" Img="superline.bmp" Caption="SuperLine"/>
<ZAction Name="ACN_smtextall" Command="stripmtext(ALL)" Img="stripmtextall" Caption="Start command clear mtext all"/>
<ZAction Name="ACN_smtextarea" Command="stripmtext" Img="stripmtextsel" Caption="Start command clear mtext area"/>
</Group>
</ActionsContent>
</CONFIG>
Expand Up @@ -4,8 +4,6 @@
<ElectrotechVelec Type="ToolBar">
<Action Name="ACN_SUPELINE"/>
<Action Name="ACN_slagcabCom"/>
<Action Name="ACN_smtextall"/>
<Action Name="ACN_smtextarea"/>
</ElectrotechVelec>
</ToolBarsContent>
</CONFIG>

0 comments on commit 7c8662c

Please sign in to comment.