mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-10 03:54:54 -06:00
bazaar: PlotLib,PlotCtrl
git-svn-id: svn://ultimatepp.org/upp/trunk@2877 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2f58051acd
commit
197765d1a4
26 changed files with 1472 additions and 0 deletions
86
bazaar/PlotLib/PlotData.cpp
Normal file
86
bazaar/PlotLib/PlotData.cpp
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#include "PlotLib.h"
|
||||
|
||||
/* PlotData */
|
||||
|
||||
PlotData& PlotData::SetSymbol(String Symbol,Sizef size,RGBA color,RGBA frame,double thickness){
|
||||
symbol=PlotSymbol::Create(PlotSymbol::TypeIndex(Symbol));
|
||||
if(size.cx<0||size.cy<0){size.cx=size.cy=0;}
|
||||
if(symbol->GetThickness()<0){thickness=1;}
|
||||
symbol->SetSize(size).SetColor(color).SetFrameColor(frame).SetThickness(thickness);
|
||||
return *this;
|
||||
}
|
||||
PlotData& PlotData::SetSymbol(String Symbol){
|
||||
symbol=PlotSymbol::Create(PlotSymbol::TypeIndex(Symbol));
|
||||
if(symbol->GetSize().cx<0||symbol->GetSize().cy<0){symbol->SetSize(Sizef(0,0));}
|
||||
if(symbol->GetThickness()<0){symbol->SetThickness(1);}
|
||||
return *this;
|
||||
}
|
||||
PlotData& PlotData::SetSymbol(PlotSymbol* Symbol){
|
||||
symbol=Symbol->Copy();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Image PlotData::GetIcon(){
|
||||
ImageBuffer ib(40,20);
|
||||
BufferPainter bp(ib);
|
||||
bp.Clear(White());
|
||||
bp.Dash(dash).DrawLine(0,20,40,0,t,color);
|
||||
if(symbol){
|
||||
symbol->Paint(bp,Pointf(20,10));
|
||||
}
|
||||
return ib;
|
||||
}
|
||||
void PlotData::AddXY(double x,double y){Vector<Pointf>::Add(Pointf(x,y));}
|
||||
|
||||
String PlotData::ToString()const{
|
||||
return title+(visible?" (visible) ":" (invisible) ");
|
||||
}
|
||||
|
||||
PlotData::PlotData(){
|
||||
SetDefaults();
|
||||
}
|
||||
PlotData::PlotData(const PlotData& pd,int):
|
||||
Vector<Pointf>(pd,1),
|
||||
color(pd.color),
|
||||
t(pd.t),
|
||||
dash(pd.dash),
|
||||
title(pd.title),
|
||||
visible(pd.visible),
|
||||
BB(pd.BB)
|
||||
{
|
||||
symbol=pd.symbol->Copy();
|
||||
}
|
||||
|
||||
PlotData::PlotData(const Vector<Pointf>& data,const char* name){
|
||||
SetDefaults();
|
||||
SetCount(data.GetCount());
|
||||
for(int i=0;i<data.GetCount();i++){
|
||||
(*this)[i]=data[i];
|
||||
// BB.Union(data[i]);
|
||||
}
|
||||
}
|
||||
PlotData::PlotData(const Array<Pointf>& data,const char* name){
|
||||
SetDefaults();
|
||||
SetCount(data.GetCount());
|
||||
for(int i=0;i<data.GetCount();i++){
|
||||
(*this)[i]=data[i];
|
||||
// BB.Union(data[i]);
|
||||
}
|
||||
}
|
||||
PlotData& PlotData::SetDefaults(){
|
||||
color=LtBlue();
|
||||
dash="";
|
||||
title="";
|
||||
visible=true;
|
||||
t=1;
|
||||
BB=Null;
|
||||
symbol=PlotSymbol::Create(0);
|
||||
return *this;
|
||||
}
|
||||
void PlotData::RefreshBB(){
|
||||
BB=Null;
|
||||
for(int i = 0; i < GetCount(); i++){
|
||||
BB.Union((*this)[i]);
|
||||
}
|
||||
if(BB.IsNullInstance()){BB.Clear();}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue