Jump to content
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr ×
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr
  • 0

TChart Point, Marks 출력 문의


최남영

질문

안녕하세요

현재 TChart를 이용해 Signal Spectrum 디스플레이 기능구현하고 있습니다.

Series에서 point와 mark를 visible하면 모든 포인트에 표시가 되는데 원하는 몇개 포인트에만 포인트를 출력하고싶은데 가능한 방법에 대해 문의드립니다.

 

579167698_2022-06-14143036.jpg.495d9b76d149bcc67037f6da1169e09a.jpg

 

 

#include "WaveForm.h"
#include "HMainForm.h"
#include "Define.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TWave *Wave;

#define WAVE_COUNT 200
short int WaveBuf[WAVE_COUNT];
short int PreWaveBuf[WAVE_COUNT];
short int PeakPointNum=0;

#define WAVE_START             0x01
#define WAVE_MAX_HOLE         0x02
#define WAVE_PEAKTOPEAK     0x04
unsigned char WaveFlag=0;
//---------------------------------------------------------------------------
__fastcall TWave::TWave(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TWave::FormClose(TObject *Sender, TCloseAction &Action)
{
    char i;

    ActiveFormStatus&=~WAVE_FORM;
    Action = caFree;
}
//---------------------------------------------------------------------------
void __fastcall TWave::FormShow(TObject *Sender)
{

    ActiveFormStatus|=WAVE_FORM;
}
//---------------------------------------------------------------------------
void __fastcall TWave::Button_WaveStartClick(TObject *Sender)
{
    WaveFlag|=WAVE_START;
    memset(PreWaveBuf, 0xFFF0,sizeof(PreWaveBuf));

}
//---------------------------------------------------------------------------


void __fastcall TWave::Button_WaveStopClick(TObject *Sender)
{
    WaveFlag&=~WAVE_START;
}
//---------------------------------------------------------------------------

void PeakToPeakFunc(void)
{
    Wave->Series1->Clear(); //Absolute_Peak

}

void WaveProc(void)
{
    short int i,j, bTemp=0;

    //////////////////for test
    for(j=0; j<10; j++){
        for(i=bTemp; i<(bTemp+(WAVE_COUNT/10)); i++){
            switch(j){
                case 0:        WaveBuf[i]=(rand()%10+20)*-1;    break;
                case 1:           WaveBuf[i]=(rand()%10+20)*-1;    break;
                case 2:        WaveBuf[i]=rand()%10+20;    break;
                case 3:        WaveBuf[i]=(rand()%10+20)*-1;    break;
                case 4:     WaveBuf[i]=rand()%10+20;    break;
                case 5:           WaveBuf[i]=(rand()%10+20)*-1;    break;
                case 6:        WaveBuf[i]=rand()%10+20;    break;
                case 7:        WaveBuf[i]=(rand()%10+20)*-1;    break;
                case 8:        WaveBuf[i]=rand()%10+20;    break;
                case 9:        WaveBuf[i]=(rand()%10+20)*-1;    break;
            }
        }
        bTemp+=(WAVE_COUNT/10);
    }

    /////////////////

    if(WaveFlag&WAVE_START){
        Wave->Series1->Clear();             //maxhold도 무조건 clear
        if(WaveFlag&WAVE_MAX_HOLE){
            for(i=0; i<WAVE_COUNT; i++){
                if(PreWaveBuf[i]<WaveBuf[i]){
                  PreWaveBuf[i]=WaveBuf[i];
                }
            }
            for(i=0; i<WAVE_COUNT; i++){
                Wave->Series1->AddXY(i,(PreWaveBuf[i]));
            }
        }
        else{
            for(i=0; i<WAVE_COUNT; i++){
                Wave->Series1->AddXY(i,(WaveBuf[i]));
            }
        }

    }
}

void __fastcall TWave::ComboBox_MaxHoldChange(TObject *Sender)
{
    if(Wave->ComboBox_MaxHold->ItemIndex==1){
        WaveFlag|=WAVE_MAX_HOLE;
    }
    else{
        WaveFlag&=~WAVE_MAX_HOLE;
    }
}
//---------------------------------------------------------------------------


void __fastcall TWave::Button_PeakToPeakClick(TObject *Sender)
{
    short int PeakPower=0xFFF0, i;

    WaveFlag|=WAVE_PEAKTOPEAK;
    if(WaveFlag&WAVE_MAX_HOLE){
        for(i=0; i<WAVE_COUNT; i++){
            if(PeakPower<PreWaveBuf[i]){
              PeakPower=PreWaveBuf[i];
              PeakPointNum=i;
            }
        }
    }
    else{
        for(i=0; i<WAVE_COUNT; i++){
            if(PeakPower<WaveBuf[i]){
              PeakPower=WaveBuf[i];
              PeakPointNum=i;
            }
        }
    }

    PeakToPeakFunc();
}
//---------------------------------------------------------------------------
 

이 댓글 링크
다른 사이트에 공유하기

5 answers to this question

Recommended Posts

  • 0

특정 위치만 별도로 출력하는 기능은 TChart 에서 Legend  메소드로 제공하고 있는데 이 방법으로 하기가 어렵다면

지금 전체 표시 되는 그래프를 Gray 로 출력하고 특정 값의 포인트는 조건에 따라서 직접 포인트를 그려서 오버레이 시키는 방식을 사용하는건 어떨지요 ?

public void SetLegendCustomLocation(TChart chart, int x, int y)
{
 chart.Legend.CustomPosition = true;
 chart.Legend.Left = x;
 chart.Legend.Top = y;
}

 

 

 

이 댓글 링크
다른 사이트에 공유하기

  • 0

아래처럼 Series2를 한개 더 생성해서 출력하는 방법으로 진행하고 있습니다.

하지만 Series1처럼 새로 Display가 안되고 이전값이 계속 남아있네요

이전값 지우는 속성이 별도로 있나요?? 아무리 해봐도 안되네요 ㅠㅠ

image.png.6ab27cc2aa87f1d9451d49eee6a6c438.png

이 댓글 링크
다른 사이트에 공유하기

이 토의에 참여하세요

지금 바로 의견을 남길 수 있습니다. 그리고 나서 가입해도 됩니다. 이미 회원이라면, 지금 로그인하고 본인 계정으로 의견을 남기세요.

Guest
이 질문에 답변하기...

×   서식있는 텍스트로 붙여넣기.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   이전에 작성한 콘텐츠가 복원되었습니다..   편집창 비우기

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

중요한 정보

이용약관 개인정보보호정책 이용규칙 이 사이트가 더 잘 작동하기 위해 방문자의 컴퓨터에 쿠키가 배치됩니다. 쿠키 설정 변경에서 원하는 설정을 할 수 있습니다. 변경하지 않으면 쿠키를 허용하는 것으로 이해합니다.