Merged revision(s) 51383 #9f13b0b11a, 52335 #11f4712b8d, 52339-52340 #11f4b132d1-#11f4b132d1, 52346-52347 #cc9413a516-#cc9413a516, 52389 #55188988d4, 52391 #c51bc87bab from trunk:

tachart: fix compiling for the coming TRect advanced functions in FPC 3.1.1 (see issue #29479)
........
TAChart: Add missing declaration of PutPixel to TOpenGLDrawer.
........
TAChart: Remove path to TADrawerOpenGl from opengl demo.
........
TAChart: Fix pen style and pen width in OpenGL drawer.
........
TAChart: Set "AddToUsesPkgSection" flag of TADrawerOpenGL to false (had been changed in r52340 #c3114ad322, resolves issue #0030169)
........
TAChart: Fix missing initialization of glut library in opengl demo.
........
TAChart: Publish event OnContextPopup
........
TAChart: Avoid chart popup menu opening at the end of a pan-drag operation with right mouse button.
........

git-svn-id: branches/fixes_1_6@52456 -
This commit is contained in:
maxim 2016-06-08 22:14:11 +00:00
parent d1fb44a761
commit b7a6b2c951
6 changed files with 85 additions and 10 deletions

View File

@ -2,16 +2,17 @@ object Form1: TForm1
Left = 308 Left = 308
Height = 319 Height = 319
Top = 132 Top = 132
Width = 684 Width = 688
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 319 ClientHeight = 319
ClientWidth = 684 ClientWidth = 688
LCLVersion = '1.1' OnCreate = FormCreate
LCLVersion = '1.7'
object OpenGLControl1: TOpenGLControl object OpenGLControl1: TOpenGLControl
Left = 344 Left = 344
Height = 319 Height = 319
Top = 0 Top = 0
Width = 340 Width = 344
Align = alClient Align = alClient
AutoResizeViewport = True AutoResizeViewport = True
OnPaint = OpenGLControl1Paint OnPaint = OpenGLControl1Paint
@ -45,7 +46,6 @@ object Form1: TForm1
OnAfterPaint = Chart1AfterPaint OnAfterPaint = Chart1AfterPaint
Align = alLeft Align = alLeft
Color = clSkyBlue Color = clSkyBlue
ParentColor = False
object Chart1LineSeries1: TLineSeries object Chart1LineSeries1: TLineSeries
LinePen.Color = clBlue LinePen.Color = clBlue
LinePen.Width = 3 LinePen.Width = 3

View File

@ -20,6 +20,7 @@ type
OpenGLControl1: TOpenGLControl; OpenGLControl1: TOpenGLControl;
RandomChartSource1: TRandomChartSource; RandomChartSource1: TRandomChartSource;
procedure Chart1AfterPaint(ASender: TChart); procedure Chart1AfterPaint(ASender: TChart);
procedure FormCreate(Sender: TObject);
procedure OpenGLControl1Paint(Sender: TObject); procedure OpenGLControl1Paint(Sender: TObject);
end; end;
@ -31,13 +32,27 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
TADrawUtils, TADrawerOpenGL in '..\..\TADrawerOpenGL.pas', TADrawerCanvas; glut, TADrawUtils, TADrawerOpenGL in '../../tadraweropengl.pas', TADrawerCanvas;
procedure TForm1.Chart1AfterPaint(ASender: TChart); procedure TForm1.Chart1AfterPaint(ASender: TChart);
begin begin
OpenGLControl1.Invalidate; OpenGLControl1.Invalidate;
end; end;
{ Initialization of glut library, needed for text output }
procedure TForm1.FormCreate(Sender: TObject);
var
CmdCount : Integer;
Cmd : Array of Pchar;
I: Integer;
begin
CmdCount := Paramcount+1;
SetLength(Cmd,CmdCount);
for I := 0 to CmdCount - 1 do
Cmd[I] := PChar(ParamStr(I));
glutInit (@CmdCount,@Cmd);
end;
procedure TForm1.OpenGLControl1Paint(Sender: TObject); procedure TForm1.OpenGLControl1Paint(Sender: TObject);
var var
d: IChartDrawer; d: IChartDrawer;

View File

@ -30,6 +30,7 @@ type
FPenWidth: Integer; FPenWidth: Integer;
FPos: TPoint; FPos: TPoint;
procedure ChartGLColor(AColor: TFPColor); procedure ChartGLColor(AColor: TFPColor);
procedure ChartGLPenStyle(APenStyle: TFPPenStyle);
procedure InternalPolyline( procedure InternalPolyline(
const APoints: array of TPoint; AStartIndex, ANumPts, AMode: Integer); const APoints: array of TPoint; AStartIndex, ANumPts, AMode: Integer);
procedure SetBrush(ABrush: TFPCustomBrush); procedure SetBrush(ABrush: TFPCustomBrush);
@ -56,6 +57,7 @@ type
procedure Polyline( procedure Polyline(
const APoints: array of TPoint; AStartIndex, ANumPts: Integer); const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
procedure PrepareSimplePen(AColor: TChartColor); procedure PrepareSimplePen(AColor: TChartColor);
procedure PutPixel(AX, AY: Integer; AColor: TChartColor); override;
procedure RadialPie( procedure RadialPie(
AX1, AY1, AX2, AY2: Integer; AX1, AY1, AX2, AY2: Integer;
AStartAngle16Deg, AAngleLength16Deg: Integer); AStartAngle16Deg, AAngleLength16Deg: Integer);
@ -88,6 +90,27 @@ begin
glColor4us(red, green, blue, (255 - FTransparency) shl 8); glColor4us(red, green, blue, (255 - FTransparency) shl 8);
end; end;
procedure TOpenGLDrawer.ChartGLPenStyle(APenStyle: TFPPenStyle);
var
pattern: Word;
begin
case APenStyle of
psClear : pattern := %0000000000000000;
psDot : pattern := %0011001100110011;
psDash : pattern := %0000000011111111;
psDashDot : pattern := %0001100011111111;
psDashDotDot : pattern := %0001101100111111;
else
glDisable(GL_LINE_STIPPLE); // --> psSolid
exit;
// psPattern will render as psSolid because there are differences in
// implementations between fpc and lcl.
// psInsideFrame will render as psSolid - I don't know what this is...
end;
glLineStipple(1, pattern);
glEnable(GL_LINE_STIPPLE);
end;
procedure TOpenGLDrawer.ClippingStart(const AClipRect: TRect); procedure TOpenGLDrawer.ClippingStart(const AClipRect: TRect);
type type
TGLClipPlaneEqn = record A, B, C, D: GLdouble; end; TGLClipPlaneEqn = record A, B, C, D: GLdouble; end;
@ -156,9 +179,8 @@ var
i: Integer; i: Integer;
begin begin
if FPenStyle = psClear then exit; if FPenStyle = psClear then exit;
glBegin(AMode);
ChartGLColor(FPenColor); ChartGLColor(FPenColor);
glLineWidth(FPenWidth); glBegin(AMode);
for i := AStartIndex to AStartIndex + ANumPts - 1 do for i := AStartIndex to AStartIndex + ANumPts - 1 do
glVertex2iv(@APoints[i]); glVertex2iv(@APoints[i]);
glEnd(); glEnd();
@ -169,7 +191,6 @@ begin
if FPenStyle = psClear then exit; if FPenStyle = psClear then exit;
glBegin(GL_LINES); glBegin(GL_LINES);
ChartGLColor(FPenColor); ChartGLColor(FPenColor);
glLineWidth(FPenWidth);
glVertex2i(AX1, AY1); glVertex2i(AX1, AY1);
glVertex2i(AX2, AY2); glVertex2i(AX2, AY2);
glEnd(); glEnd();
@ -300,12 +321,15 @@ begin
FPenWidth := APen.Width; FPenWidth := APen.Width;
FPenColor := APen.FPColor; FPenColor := APen.FPColor;
FPenStyle := APen.Style; FPenStyle := APen.Style;
glLineWidth(FPenWidth);
ChartGLPenStyle(FPenStyle);
end; end;
procedure TOpenGLDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); procedure TOpenGLDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
begin begin
FPenStyle := AStyle; FPenStyle := AStyle;
FPenColor := FChartColorToFPColorFunc(AColor); FPenColor := FChartColorToFPColorFunc(AColor);
ChartGLPenStyle(AStyle);
end; end;
procedure TOpenGLDrawer.SetTransparency(ATransparency: TChartTransparency); procedure TOpenGLDrawer.SetTransparency(ATransparency: TChartTransparency);

View File

@ -101,9 +101,11 @@ type
TBasicChartTool = class(TIndexedComponent) TBasicChartTool = class(TIndexedComponent)
strict protected strict protected
FChart: TChart; FChart: TChart;
FStartMousePos: TPoint;
procedure Activate; virtual; procedure Activate; virtual;
procedure Deactivate; virtual; procedure Deactivate; virtual;
function PopupMenuConflict: Boolean; virtual;
public public
property Chart: TChart read FChart; property Chart: TChart read FChart;
end; end;
@ -268,6 +270,8 @@ type
procedure VisitSources( procedure VisitSources(
AVisitor: TChartOnSourceVisitor; AAxis: TChartAxis; var AData); AVisitor: TChartOnSourceVisitor; AAxis: TChartAxis; var AData);
protected protected
FDisablePopupMenu: Boolean;
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); override;
function DoMouseWheel( function DoMouseWheel(
AShift: TShiftState; AWheelDelta: Integer; AShift: TShiftState; AWheelDelta: Integer;
AMousePos: TPoint): Boolean; override; AMousePos: TPoint): Boolean; override;
@ -435,6 +439,7 @@ type
published published
property OnClick; property OnClick;
property OnContextPopup;
property OnDblClick; property OnDblClick;
property OnDragDrop; property OnDragDrop;
property OnDragOver; property OnDragOver;
@ -793,6 +798,12 @@ begin
AxisList.Draw(MaxInt, axisIndex); AxisList.Draw(MaxInt, axisIndex);
end; end;
procedure TChart.DoContextPopup(MousePos: TPoint; var Handled: Boolean);
begin
if FDisablePopupMenu then Handled := true;
inherited;
end;
function TChart.DoMouseWheel( function TChart.DoMouseWheel(
AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean; AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean;
const const
@ -1873,12 +1884,21 @@ procedure TBasicChartTool.Activate;
begin begin
FChart.FActiveToolIndex := Index; FChart.FActiveToolIndex := Index;
FChart.MouseCapture := true; FChart.MouseCapture := true;
FChart.FDisablePopupMenu := false;
FStartMousePos := Mouse.CursorPos;
end; end;
procedure TBasicChartTool.Deactivate; procedure TBasicChartTool.Deactivate;
begin begin
FChart.MouseCapture := false; FChart.MouseCapture := false;
FChart.FActiveToolIndex := -1; FChart.FActiveToolIndex := -1;
if PopupMenuConflict then
FChart.FDisablePopupMenu := true;
end;
function TBasicChartTool.PopupMenuConflict: Boolean;
begin
Result := false;
end; end;
procedure SkipObsoleteChartProperties; procedure SkipObsoleteChartProperties;

View File

@ -1018,7 +1018,7 @@ var
with imageBar do begin with imageBar do begin
TopLeft := ParentChart.GraphToImage(graphBar.a); TopLeft := ParentChart.GraphToImage(graphBar.a);
BottomRight := ParentChart.GraphToImage(graphBar.b); BottomRight := ParentChart.GraphToImage(graphBar.b);
NormalizeRect(imageBar); TAGeometry.NormalizeRect(imageBar);
// Draw a line instead of an empty rectangle. // Draw a line instead of an empty rectangle.
if Bottom = Top then Dec(Top); if Bottom = Top then Dec(Top);

View File

@ -69,6 +69,7 @@ type
procedure MouseUp(APoint: TPoint); virtual; procedure MouseUp(APoint: TPoint); virtual;
procedure MouseWheelDown(APoint: TPoint); virtual; procedure MouseWheelDown(APoint: TPoint); virtual;
procedure MouseWheelUp(APoint: TPoint); virtual; procedure MouseWheelUp(APoint: TPoint); virtual;
function PopupMenuConflict: Boolean; override;
procedure PrepareDrawingModePen(ADrawer: IChartDrawer; APen: TFPCustomPen); procedure PrepareDrawingModePen(ADrawer: IChartDrawer; APen: TFPCustomPen);
procedure RestoreCursor; procedure RestoreCursor;
procedure SetCursor; procedure SetCursor;
@ -835,6 +836,21 @@ begin
Unused(APoint); Unused(APoint);
end; end;
function TChartTool.PopupMenuConflict: Boolean;
var
P: TPoint;
begin
Result := false;
if Shift = [ssRight] then begin
P := Mouse.CursorPos;
if (P.X = FStartMousePos.X) then
exit;
if (P.Y = FStartMousePos.Y) then
exit;
Result := true;
end;
end;
procedure TChartTool.PrepareDrawingModePen( procedure TChartTool.PrepareDrawingModePen(
ADrawer: IChartDrawer; APen: TFPCustomPen); ADrawer: IChartDrawer; APen: TFPCustomPen);
begin begin