⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zklinewidget.ui.h

📁 股票分析系统
💻 H
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/void ZKLineWidget::drawRectF(QPainter *p,float x1,float y1,float x2,float y2){    int X1=zw->x(x1); int Y1=zw->y(y1); int X2=zw->x(x2); int Y2=zw->y(y2);    int X0,W,Y0,H;    if(X1<=X2) {	X0=X1;	W=X2-X1;    }    else     	{	X0=X2;	W=X1-X2;    }      if(Y1<=Y2) {	Y0=Y1;	H=Y2-Y1;    }    else 	{	Y0=Y2;	H=Y1-Y2;    }        if(W==0 || H==0)   {	p->drawLine(X0,Y0,X0+W,Y0+H);    }    else    {	p->drawRect(X0,Y0,W,H);    }}    void ZKLineWidget::clear(){    this->Tel=NULL;    this->CurrentDay=0;    this->repaint();    this->Data=NULL;    this->drawCurrent=false;}void ZKLineWidget::paintEvent( QPaintEvent * ){//    textOut->hide();    const int w0=58;const int ht=18;    int w=this->width();    int h=this->height();    int h0=0; int h2=6; int h4=0; int h1=(h-h0-h2-h4)/2;  int h3=h1;    QPainter paint( this );    paint.setFont(*TextFont);    paint.setPen( QPen(BoardColor,2) );     paint.drawRect(w0,h0+1,w-w0,h1-1);         paint.setPen(QPen(BoardColor,0,Qt::DotLine));    paint.drawLine(w0,h0+h1/3,w,h0+h1/3);    paint.drawLine(w0,h0+h1*2/3,w,h0+h1*2/3);        int hc0=h0+h1+h2;    paint.setPen( QPen(BoardColor,2) );     paint.drawRect(w0,hc0,w-w0,h3);         paint.setPen(QPen(BoardColor,0,Qt::DotLine));    paint.drawLine(w0,hc0+h3/2,w,hc0+h3/2);        if(Tel==NULL)    {	return;    }    if(days==0)    {	return;    }        int i;    float MAX=-1;float MIN=10E12;    for(i=0;i<DisplayDays;i++)    {	ZDaysStruct *k=Data+i;	if(MAX<k->high())MAX=k->high();	if(MIN>k->low())MIN=k->low();    }    paint.setPen(NameColor);    paint.drawText(0,h0,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg(MAX,0,'f',2));    paint.drawText(0,h0+h1/3-ht/2,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg((MAX-MIN)/3+MIN,0,'f',2));    paint.drawText(0,h0+h1*2/3-ht/2,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg((MAX-MIN)*2/3+MIN,0,'f',2));    paint.drawText(0,h0+h1-ht,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg(MIN,0,'f',2));      zw->setWorld(w0,h0,w-w0,h1,-0.5,MIN,((float)(DisplayDays)-0.5),MAX);    for(i=0;i<DisplayDays;i++)    {	ZDaysStruct *k=Data+i;	if(k->open() <= k->close())	{	    paint.setPen( UpColor );	    paint.setBrush(UpColor);	}	else	{	    paint.setPen( DownColor );	    paint.setBrush(DownColor);	}	drawRectF(&paint,(-0.4+i),(k->close()),(0.4+i),(k->open())); 	paint.drawLine(zw->x(i),zw->y(k->low()),zw->x(i),zw->y(k->high()));	    }        writeAvr(&paint,5,Avr1Color);    writeAvr(&paint,10,Avr2Color);    writeAvr(&paint,20,Avr3Color);        if(drawCurrent)    {	paint.setPen( QColor(0,0,0) );	paint.drawLine(zw->x(CurrentDay),zw->y(MIN),zw->x(CurrentDay),zw->y(MAX));    }//    cerr<<"Paint End!"<<endl;     MAX=-1; MIN=0;    for(i=0;i<DisplayDays;i++)    {	ZDaysStruct *k=Data+i;	if(MAX<k->count())MAX=k->count();    }        paint.setPen( NameColor );     paint.drawText(0,hc0,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg(MAX,0,'f',0));    paint.drawText(0,hc0+h3/2-ht/2,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg((MAX+MIN)/2,0,'f',0));    paint.drawText(0,hc0+h3-ht,w0,ht,Qt::AlignRight | Qt::AlignVCenter,QString("%1").arg(MIN,0,'f',0));    zw->setWorld(w0,hc0,w-w0,h3,-0.5,MIN,((float)(DisplayDays)-0.5),MAX);    for(i=0;i<DisplayDays;i++)    {	ZDaysStruct *k=Data+i;	if(k->open() <= k->close())	{	    paint.setPen( UpColor );	    paint.setBrush(UpColor);	}	else	{	    paint.setPen( DownColor );	    paint.setBrush(DownColor);	}	drawRectF(&paint,-0.4+i,0.0,0.4+i,(k->count()));     }            if(drawCurrent)    {	paint.setPen( QColor(0,0,0) );	paint.drawLine(zw->x(CurrentDay),zw->y(MIN),zw->x(CurrentDay),zw->y(MAX));	writeCurrent(&paint,0,0,w0,200);    }//    textOut->show();}void ZKLineWidget::writeAvr(QPainter* p,int days1,QColor c){    p->setPen(c);        float avr=0,lastAvr;	for(int j=0;j<days1;j++)	{	    avr=avr+(Data+j)->close();	} 	avr=avr/days1;	lastAvr=avr;	    for(int i=days1;i<days;i++)    {	avr=0;	for(int j=0;j<days1;j++)	{	    avr=avr+(Data+i-j)->close();	} 	avr=avr/days1;	p->drawLine(zw->x(i-1),zw->y(lastAvr),zw->x(i),zw->y(avr));	lastAvr=avr;	    }}void ZKLineWidget::writeCurrent(QPainter* p,int x,int y,int w,int h){//    p->setRasterOp ( Qt::XorROP ) ;    p->setPen( PopColor );    p->setBrush(PopColor);        p->drawRect(x,y,w,h);        p->setPen((NameColor));    int ht=h/12;    zDrawText(p,x,y,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("时间:")),NameColor);    zDrawText(p,x,y+ht,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("%1").arg((Data+CurrentDay)->date())),NameColor);    zDrawText(p,x,y+2*ht,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("开盘:")),NameColor);    zDrawFloat(p,x,y+3*ht,w+2,ht,(Data+CurrentDay)->open(),LastClose);    zDrawText(p,x,y+4*ht,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("最高:")),NameColor);    zDrawFloat(p,x,y+5*ht,w+2,ht,(Data+CurrentDay)->high(),LastClose);   zDrawText(p,x,y+6*ht,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("最低:")),NameColor);    zDrawFloat(p,x,y+7*ht,w+2,ht,(Data+CurrentDay)->low(),LastClose);    zDrawText(p,x,y+8*ht,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("收盘:")),NameColor);    zDrawFloat(p,x,y+9*ht,w+2,ht,(Data+CurrentDay)->close(),LastClose);    zDrawText(p,x,y+10*ht,w+2,ht,Qt::AlignLeft | Qt::AlignVCenter,tr(QString("成交:")),NameColor);    zDrawInt(p,x,y+11*ht,w+2,ht,(int)(Data+CurrentDay)->count());}void ZKLineWidget::setCurrentDay(unsigned int d ){    this->CurrentDay=d;    this->repaint();}void ZKLineWidget::setData(ZTel* tel,unsigned char style){    this->Tel=tel;    this->style=style;        if((style==0x10) || (style==0x20))    {	if(Tel->isIndexDaysTel())	{	    Data=((ZDaysTel*)Tel)->getDay(0);	    days=((ZDaysTel*)Tel)->getDays();	    getMinutes(Data+days-1);	}	else	{	    return;	}    }    else     {	if(Tel->isStockDaysTel())	{	    Data= ((ZDaysTel*)Tel)->getDay(0);	    days=((ZDaysTel*)Tel)->getDays();	}	else	{	    return;	}	    }        DisplayDays=days;    CurrentDay=days-1;    this->repaint();}void ZKLineWidget::mousePressEvent( QMouseEvent * e ){    if(Data==NULL)return;    if(e->button()==Qt::RightButton)    {	drawCurrent=false;	this->repaint();	return;    }    else if(e->button()==Qt::LeftButton)    {	int cu=(int)(((double)(zw->fx(e->x())))+0.5);	if((cu<0))cu=0;	if(cu>days-1)cu=days-1;	CurrentDay=cu;	drawCurrent=true;//	getCurrentDay(currentDay+Data,currentDay);    if(CurrentDay==0)setLastClose(Data->close());    else setLastClose((Data+CurrentDay-1)->close());	repaint();	return;    }    else     {	return;    }    }void ZKLineWidget::mouseDoubleClickEvent ( QMouseEvent * e ){    if(Data==NULL)return;    if(e->button()!=Qt::LeftButton)return;    int currentDay=(int)(((double)(zw->fx(e->x())))+0.5);    if(currentDay<0)currentDay=0;    drawCurrent=true;    if(currentDay==0)setLastClose(Data->close());    else setLastClose((Data+currentDay-1)->close());    CurrentDay=currentDay;    getMinutes(Data+currentDay);}void ZKLineWidget::setLastClose(float f){    this->LastClose=f;}void ZKLineWidget::init(){    zw=new ZWorld();    Tel=NULL;    Data=NULL;//    textOut=new ZXORWidget(this);//    textOut->setGeometry(100,50,100,250);     this->drawCurrent=false;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -