a.Row a.Col для матрицы

This commit is contained in:
miks1965 2016-11-16 10:00:30 +03:00
parent 5e4b3e032d
commit 7c8cb2f502
13 changed files with 96 additions and 23 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "2";
public const string Build = "0";
public const string Revision = "1336";
public const string Revision = "1337";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=2
%REVISION%=1336
%COREVERSION%=0
%REVISION%=1337
%MINOR%=2
%MAJOR%=3

View file

@ -1440,6 +1440,17 @@
</i>
</OCtx>
</Node>
<Node Name="FindIndex" NL="0,5634766" NG="0,5947266">
<FileName>\SyntaxTree\tree\TreeHelper.cs</FileName>
<Text>public int FindIndex(syntax_tree_node node)</Text>
<OCtx>
<i Type="Method">public int FindIndex ( syntax_tree_node node )</i>
<i Type="ClassOrNamespace">public partial class syntax_tree_node</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . SyntaxTree</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
</Node>
</Items>
</Node>
</AspectFile>

View file

@ -1 +1 @@
!define VERSION '3.2.0.1336'
!define VERSION '3.2.0.1337'

View file

@ -20,7 +20,7 @@ public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseEnterExitVisit
return new ident("$GenContFE" + GenIdNum.ToString());
}
public void ReplaceStatement(statement from, IEnumerable<statement> to)
public void ReplaceStatement(statement from, IEnumerable<statement> to, Desc d = Desc.DirectDescendants)
{
foreach (var x in to)
x.Parent = from.Parent;
@ -34,7 +34,7 @@ public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseEnterExitVisit
var l = new statement_list();
l.AddMany(to);
l.source_context = from.source_context;
from.Parent.Replace(from, l);
from.Parent.Replace(from, l, d);
}
}

View file

@ -26,13 +26,22 @@ namespace PascalABCCompiler.SyntaxTree
PreOrder
}
public enum Desc
{
All,
DirectDescendants
}
public partial class syntax_tree_node
{
public syntax_tree_node Parent;
public int FindIndex(syntax_tree_node node)
public int FindIndex(syntax_tree_node node, Desc d = Desc.All)
{
int ind = -1;
for (var i = 0; i < subnodes_count; i++)
var count = d == Desc.All ? subnodes_count : subnodes_without_list_elements_count;
for (var i = 0; i < count; i++)
if (node == this[i])
{
ind = i;
@ -43,9 +52,16 @@ namespace PascalABCCompiler.SyntaxTree
return ind;
}
public void Replace(syntax_tree_node from, syntax_tree_node to) // есть риск, что типы не совпадут
/*public void Replace(syntax_tree_node from, syntax_tree_node to, Desc d = Desc.All) // есть риск, что типы не совпадут
{
var ind = FindIndex(from);
var ind = FindIndex(from,d);
this[ind] = to;
}*/
// Безопасная версия Replace
public void Replace<T,T1>(T from, T1 to, Desc d = Desc.All) where T: syntax_tree_node where T1 : T
{
var ind = FindIndex(from,d);
this[ind] = to;
}

Binary file not shown.

View file

@ -44,6 +44,7 @@ type
procedure DrawFieldOnly;
procedure DrawXY;
public
dmwidth := 2;
// Добавил - МА
TaskName: string;
//
@ -70,6 +71,8 @@ type
procedure MakerPenDown;
procedure MakerToPoint(x,y: integer);
procedure MakerOnVector(x,y: integer);
procedure SetDrawManWidth(w: integer);
// примитивы для выполнителя
procedure DrawDM;
@ -217,16 +220,14 @@ begin
end;
procedure TDMField.DrawDMDrawing;
var i: integer;
begin
for i:=0 to DMColl.Count-1 do
for var i:=0 to DMColl.Count-1 do
DMLine(DMColl[i].p.x,DMColl[i].p.y,DMColl[i].p.x+DMColl[i].v.x,DMColl[i].p.y+DMColl[i].v.y,colorSolve);
end;
procedure TDMField.DrawDMMakerDrawing;
var i: integer;
begin
for i:=0 to DMMakerColl.Count-1 do
for var i:=0 to DMMakerColl.Count-1 do
DMLine(DMMakerColl[i].p.x,DMMakerColl[i].p.y,DMMakerColl[i].p.x+DMMakerColl[i].v.x,DMMakerColl[i].p.y+DMMakerColl[i].v.y,colorTask);
end;
@ -243,17 +244,16 @@ begin
end;
procedure TDMField.DrawFieldOnly;
var ix,iy,w,h: integer;
begin
w := CellSize*DimX;
h := CellSize*DimY;
var w := CellSize*DimX;
var h := CellSize*DimY;
Brush.Color := clWhite;
FillRectangle(X0,Y0,X0+ZazX1+w+1+ZazX2,Y0+ZazY1+h+1+ZazY2);
Pen.Width := 1;
Pen.Color := RGB(191,191,191);
for ix:=0 to DimX do
for var ix:=0 to DimX do
Line(X0+ZazX1+ix*CellSize,Y0+ZazY1,X0+ZazX1+ix*CellSize,Y0+ZazY1+h);
for iy:=0 to DimY do
for var iy:=0 to DimY do
Line(X0+ZazX1,Y0+ZazY1+iy*CellSize,X0+ZazX1+w,Y0+ZazY1+iy*CellSize);
Pen.Color := clGray;
if (orx>-DimX) and (orx<0) then
@ -266,7 +266,7 @@ begin
end;
procedure TDMField.DrawXY;
var x,y,ww: integer;
var ww: integer;
s: string;
interval: integer;
bs: BrushStyleType;
@ -283,7 +283,7 @@ begin
Brush.Style := bsClear;
Font.Name := 'MS Sans Serif';
Font.Size := 8;
for x:=0 to DimX do
for var x:=0 to DimX do
if (x+orx) mod interval = 0 then
begin
s:=IntToStr(x+orx);
@ -291,7 +291,7 @@ begin
// hh:=Canvas.TextHeight(s);
TextOut(X0+ZazX1+x*CellSize-ww div 2+1,Y0+ZazY1+DimY*CellSize+1+2,s);
end;
for y:=0 to DimY do
for var y:=0 to DimY do
if (y+ory) mod interval = 0 then
begin
s:=IntToStr(y+ory);
@ -306,6 +306,7 @@ end;
procedure TDMField.DMLine(x1,y1,x2,y2: integer; c: GraphABC.Color);
begin
Pen.Width := dmwidth;
Line(X0+ZazX1+(x1-orx)*CellSize,Y0+ZazY1+(DimY-y1+ory)*CellSize,X0+ZazX1+(x2-orx)*CellSize,Y0+ZazY1+(DimY-y2+ory)*CellSize,c);
end;
@ -364,6 +365,11 @@ begin
MakerToPoint(MakerX+x,MakerY+y);
end;
procedure TDMField.SetDrawManWidth(w: integer);
begin
dmwidth := 2;
end;
procedure TDMField.DrawDM;
var
ZZ: integer;
@ -376,6 +382,7 @@ begin
r1 := r;
r1.Offset(X0+ZazX1+(DMX-orx)*CellSize-4+1,Y0+ZazY1+(DimY-DMY+ory)*CellSize-4+1);
DMPicture.CopyRect(r,GraphBufferBitmap,r1);
Pen.Width := 1;
DrawRectangle(X0+ZazX1+(DMX-orx)*CellSize-ZZ+1,Y0+ZazY1+(DimY+ory-DMY)*CellSize-ZZ+1,X0+ZazX1+(DMX-orx)*CellSize+ZZ,Y0+ZazY1+(DimY+ory-DMY)*CellSize+ZZ);
end;

View file

@ -1,4 +1,4 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
///Исполнитель Чертежник предназначен для построения рисунков и чертежей на плоскости с координатами.
@ -29,6 +29,9 @@ procedure Start;
/// Остановить Чертежника
procedure Stop;
/// Установить ширину пера Чертежника
procedure SetDrawmanWidth(w: integer);
///--
procedure __InitModule__;
///--
@ -38,6 +41,11 @@ implementation
uses DMTaskMaker,DMZadan,DrawmanField;
procedure SetDrawmanWidth(w: integer);
begin
DMField.dmwidth := w
end;
procedure Start;
begin
DMField.Start;

View file

@ -2904,7 +2904,10 @@ end;
procedure SetPenWidth(Width: integer);
begin
lock f do
begin
Pen.NETPen.Width := Width;
_ColorLinePen.Width := Width;
end;
end;
function PenWidth: integer;

View file

@ -8636,6 +8636,16 @@ begin
Result := Self;
end;
function Rows<T>(Self: array [,] of T): integer; extensionmethod;
begin
Result := Self.GetLength(0);
end;
function Cols<T>(Self: array [,] of T): integer; extensionmethod;
begin
Result := Self.GetLength(1);
end;
// -----------------------------------------------------
//>> Методы расширения типа array of T # Extension methods for array of T
// -----------------------------------------------------

Binary file not shown.

View file

@ -8646,6 +8646,24 @@ begin
Result := Self.GetLength(1);
end;
function Row<T>(Self: array [,] of T; k: integer): array of T; extensionmethod;
begin
var n := Self.Cols();
var res := new T[n];
for var j:=0 to n-1 do
res[j] := Self[k,j];
Result := res;
end;
function Col<T>(Self: array [,] of T; k: integer): array of T; extensionmethod;
begin
var m := Self.Rows();
var res := new T[m];
for var i:=0 to m-1 do
res[i] := Self[i,k];
Result := res;
end;
// -----------------------------------------------------
//>> Методы расширения типа array of T # Extension methods for array of T
// -----------------------------------------------------