Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   PictureBox (https://www.clubdelphi.com/foros/showthread.php?t=31187)

FGarcia 01-05-2006 07:25:18

PictureBox
 
Hola a todos!

una pregunta "simple" :D en VB existe un control llamado PictureBox (he visto que realizan graficas de tendencias (trend) con el) cual seria su equivalente en Delphi7.

Un ejemplo de codigo de uso del PictureBox

' Graph the PV, Process Variable
Picture1.Cls
pvgraph(100) = pv
For x = 0 To 99
pvgraph(x) = pvgraph(x + 1)
Picture1.PSet (x, 3000 - (pvgraph(x)))
Next x

Gracias por la ayuda!

Delfino 02-05-2006 00:22:54

Has mirado el componente PaintBox de Delphi?:rolleyes:

FGarcia 04-05-2006 19:28:19

Hola!

No encuentro ese componente (PaintBox) en delphi 7. ¿Alguna pista?

roman 04-05-2006 19:46:23

Cita:

Empezado por FGarcia
¿Alguna pista?

Pestaña System de la paleta de herramientas.

// Saludos

FGarcia 04-05-2006 19:54:23

Gracias!

Esta tan simple el icono que lo ignoraba, solo veia el TTimer y el TmediaPlayer
Nuevamente Gracias

Lepe 05-05-2006 09:52:43

Yo directamente no uso la paleta... Menú de delphi View --> Component Palete --> escribir: TPaintBox. Claro que lo tengo en la barra de herramientas para no tener que acceder al menú.

Saludos

FGarcia 05-05-2006 23:56:55

Uff! Que sigue con PaintBox?
 
Saludos !
Pues siguiendo el consejo investigue un poco del PaintBox en delphi 7 y llegue a esto:


Código Delphi [-]
unit Plot;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls;
type
  TForm1 = class(TForm)
    Plotter: TPaintBox;
    tbSetpoint: TTrackBar;
    tbProceso: TTrackBar;
    tbSalida: TTrackBar;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure PlotterPaint(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  x, y: integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
 tbsetpoint.Position := 75;
 tbProceso.Position := 50;
 tbSalida.Position := 25;
 Label1.Color := clBlack;
 Label2.Color := clBlack;
 Label3.Color := clBlack;
 Label1.Font.Color := clYellow;
 Label2.Font.Color := clLime;
 Label3.Font.Color := clRed;
 Label1.Caption := 'Setpoint:' + ' ' + IntTostr( tbSetpoint.Position );
 Label2.Caption := 'Proceso:' + ' ' + IntTostr( tbSetpoint.Position );
 Label3.Caption := 'Salida:' + ' ' + IntTostr( tbSetpoint.Position );
 with Plotter.Canvas do
  begin
    Brush.Color := clBlack;
    Pen.Width := 5;
    FillRect(Plotter.Canvas.ClipRect );
    Rectangle(48,20,Width, Height);
  end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  //incremento en 1 la posicion en el eje de las X
  x := x + 1;
  //Verificamos si los valores cambiaron y dibujamos
  Label1.Caption := 'Setpoint:' + IntTostr( tbSetpoint.Position );
  Plotter.Canvas.Pixels[x, Plotter.Height - (tbSetpoint.Position * 2)] := clYellow;
  Label2.Caption := 'Proceso:' + IntTostr( tbProceso.Position );
  Plotter.Canvas.Pixels[x, Plotter.Height - (tbProceso.Position * 2)] := clLime;
  Label3.Caption := 'Salida:' + IntTostr( tbSalida.Position );
  Plotter.Canvas.Pixels[x, Plotter.Height - (tbSalida.Position * 2)] := clRed;
end;
procedure TForm1.PlotterPaint(Sender: TObject);
begin
   Plotter.Canvas.Rectangle (0,0,Width, Height);
   Plotter.Canvas.Pixels[x, Plotter.Height - (tbSetpoint.Position * 2)] := clYellow;
   Plotter.Canvas.Pixels[x, Plotter.Height - (tbProceso.Position * 2)] := clLime;
   Plotter.Canvas.Pixels[x, Plotter.Height - (tbSalida.Position * 2)] := clRed;
end;
 
end.




El Form:


Código Delphi [-]
object Form1: TForm1
  Left = 248
  Top = 187
  Width = 400
  Height = 272
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Plotter: TPaintBox
    Left = 8
    Top = 8
    Width = 210
    Height = 200
    Color = clBlack
    ParentColor = False
    OnPaint = PlotterPaint
  end
  object Label1: TLabel
    Left = 240
    Top = 8
    Width = 39
    Height = 13
    Caption = 'Setpoint'
  end
  object Label2: TLabel
    Left = 240
    Top = 72
    Width = 39
    Height = 13
    Caption = 'Proceso'
  end
  object Label3: TLabel
    Left = 240
    Top = 136
    Width = 29
    Height = 13
    Caption = 'Salida'
  end
  object tbSetpoint: TTrackBar
    Left = 232
    Top = 24
    Width = 150
    Height = 45
    LineSize = 2
    Max = 100
    TabOrder = 0
  end
  object tbProceso: TTrackBar
    Left = 232
    Top = 88
    Width = 150
    Height = 45
    LineSize = 2
    Max = 100
    TabOrder = 1
  end
  object tbSalida: TTrackBar
    Left = 232
    Top = 152
    Width = 150
    Height = 45
    LineSize = 2
    Max = 100
    TabOrder = 2
  end
  object Timer1: TTimer
    Interval = 500
    OnTimer = Timer1Timer
    Left = 24
    Top = 16
  end
end




y Bueno ya dibuja los puntos que quiero, ahora bien cuando llega el trazo hasta el final del PaintBox ¿como hago para que lo que ya esta dibujado se desplaze hacia la izquierda y me permita seguir viendo los nuevos trazos?

Sinceramente ya no le encuentro! Gracias por la atencion y la ayuda!!

roman 06-05-2006 07:50:23

FGarcia, edité tu mensaje anterior para corregir las etiquetas [delphi]. No sé cómo las colocaste que se perdieron.

// Saludos


La franja horaria es GMT +2. Ahora son las 14:14:04.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi