Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine time handling and close 1649 #1652

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
78937f8
added 2 undocumented keywords to caldat to help in lable_date procedure.
GillesDuvert Oct 18, 2023
4969e6f
new label_date should give good results in most cases, even if some k…
GillesDuvert Oct 18, 2023
a297e21
new label_date should give good results in most cases, even if some k…
GillesDuvert Oct 18, 2023
5890716
better behaviour wrt. IDL's
GillesDuvert Oct 19, 2023
3e52e76
There was an error in the computation of Week Of Day, we were wrong b…
GillesDuvert Oct 19, 2023
12a23dd
added test for label_date. tests also caldat and julday, indirectly.
GillesDuvert Oct 19, 2023
77210f4
added test_label_date to list
GillesDuvert Oct 19, 2023
0aff28c
temporary disable error reporting by this test
GillesDuvert Oct 19, 2023
eea3488
changed way tickinterval and tickunits are treated.
GillesDuvert Oct 19, 2023
01631f9
device accepts negative interlignes
GillesDuvert Oct 20, 2023
34f33c8
Almost got exact positions for box labels and titles. TBD: some xtick…
GillesDuvert Oct 20, 2023
6137f4c
insure labels are 'length' max as this is a fixed static size in plpl…
GillesDuvert Oct 21, 2023
b0afadd
just a few adjustments needed yet
GillesDuvert Oct 24, 2023
2f903ed
further simplification
GillesDuvert Oct 24, 2023
3a343f6
subpage region miust take into account forgotten ![xyz]omargin !!!
GillesDuvert Oct 28, 2023
9a75286
-remove writetitleandsubtitle function as titles and subtitles MUST b…
GillesDuvert Oct 28, 2023
20b2ae0
-remove writetitleandsubtitle function as titles and subtitles MUST b…
GillesDuvert Oct 28, 2023
5b1be3d
en route towards our own basic axis writing routine.
GillesDuvert Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/basic_pro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,12 @@ static DWORD launch_cmd(BOOL hide, BOOL nowait,
SizeT nParam = e->NParam(1);
if (nParam == 1) return;
DDoubleGDL* p0 = e->GetParAs<DDoubleGDL>(0);


static int GDL_DOW = e->KeywordIx("GDL_DOW");
bool hasDow = e->WriteableKeywordPresent(GDL_DOW); //insure the output variable exist and is of 'good' type
static int GDL_ICAP = e->KeywordIx("GDL_ICAP");
bool hasIcap = e->WriteableKeywordPresent(GDL_ICAP); //insure the output variable exist and is of 'good' type

// checking output (if present and global); exiting if nothing to do
bool global[6];
{
Expand All @@ -2374,6 +2379,11 @@ static DWORD launch_cmd(BOOL hide, BOOL nowait,
BaseGDL*** ret;
ret = (BaseGDL***) malloc((nParam - 1) * sizeof (BaseGDL**));
GDLGuard<BaseGDL**, void, void> retGuard(ret, free);

DLongGDL* retdow;
DLongGDL* reticap;
if (hasDow) retdow=new DLongGDL(dimension(nEl));
if (hasIcap) reticap=new DLongGDL(dimension(nEl));

for (int i = nParam - 2; i >= 0; i--) {
if (global[i]) {
Expand Down Expand Up @@ -2416,7 +2426,12 @@ static DWORD launch_cmd(BOOL hide, BOOL nowait,

// seconds
if (global[6 - 1]) (*static_cast<DDoubleGDL*> (*ret[6 - 1]))[i] = Second;

if (hasDow) (*retdow)[i]= dow;
if (hasIcap) (*reticap)[i]= icap;
}
if (hasDow) e->SetKW(GDL_DOW,retdow);
if (hasIcap) e->SetKW(GDL_ICAP,reticap);
// now guarded. s. a.
// free((void *)ret);
}
Expand Down
2 changes: 1 addition & 1 deletion src/calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ using namespace std;
F = JD - Z;
// note that IDL dow is false before Sun dec 31 12:00:00 -4714, (type: a=[-2,-1]& PRINT, FORMAT='(C())',a)
// ...and ... we are not!
if ((DLong)Z > 0) dow = ((DLong)Z) % 7; else dow = ((DLong)Z+1099) % 7; //just translate axis...
if ((DLong)Z+1 > 0) dow = ((DLong)Z+1) % 7; else dow = ((DLong)Z+1099) % 7; //just translate axis...

if (Z < 2299161) A = (DLong)Z;
else {
Expand Down
63 changes: 47 additions & 16 deletions src/gdlgstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "graphicsdevice.hpp"
#include "gdlgstream.hpp"
#include "initsysvar.hpp"
#ifndef MAX
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif

using namespace std;

Expand Down Expand Up @@ -380,8 +383,9 @@ void GDLGStream::SetCharSize(DLong ichx, DLong chy) {
gdlDefaultCharInitialized=1;
}

void GDLGStream::NextPlot( bool erase )
{
void GDLGStream::NextPlot( bool erase ) {
// restore charsize to default for newpage at beginning since adv() uses charsize to get box position.
if (!erase) sizeChar(1.0);
DLongGDL* pMulti = SysVar::GetPMulti();

DLong nx = (*pMulti)[ 1];
Expand Down Expand Up @@ -446,8 +450,7 @@ void GDLGStream::NextPlot( bool erase )
--(*pMulti)[0];
}
}
// restore charsize to default for newpage
sizeChar(1.0);

}

void GDLGStream::NoSub()
Expand Down Expand Up @@ -505,7 +508,7 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
// - ... a look-up table instead of the long switch/case blocks ...

size_t len = strlen(in);
if (stringLength) *stringLength=0;
if (stringLength!=NULL) *stringLength=0;
// skip conversion if the string is empty
if (len == 0) return "";

Expand Down Expand Up @@ -694,12 +697,12 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
}
else
{
if (stringLength) *stringLength+=base*fact[curr_lev%7];
if (stringLength!=NULL) *stringLength+=base*fact[curr_lev%7];
curr_pos++;
// handling IDL exclamation mark escape '!!'
if (in[i] == '!') {
i++;
if (stringLength) *stringLength+=base*fact[curr_lev%7];
if (stringLength!=NULL) *stringLength+=base*fact[curr_lev%7];
}
// handling plplot number sign escape '##'
if
Expand Down Expand Up @@ -1029,12 +1032,12 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
activeFontCodeNum = curr_fnt;
//if gdlGetStringLength function is available, use it to give back a better value ("X" and "I" do not have the same width in hershey format!)
#if PLPLOT_PRIVATE_NOT_HIDDEN
if (stringLength) *stringLength=gdlGetStringLength(out)/this->mmCharLength();
if (stringLength!=NULL) *stringLength=gdlGetStringLength(out)/this->mmCharLength();
#endif
return out;
retrn:
activeFontCodeNum = curr_fnt;
if (stringLength) *stringLength=0;
if (stringLength!=NULL) *stringLength=0;
cout << "ERROR: GDLGStream::TranslateFormatCodes(\"" << in << "\") = \"" << out << "\"" << endl;
return "";
}
Expand Down Expand Up @@ -1339,18 +1342,46 @@ void GDLGStream::adv(PLINT page)
(*static_cast<DFloatGDL*>(SysVar::Z()->GetTag(regionTag, 0)))[1]=szmax;
}

void GDLGStream::getSubpageRegion(PLFLT &sxmin, PLFLT &symin, PLFLT &sxmax, PLFLT &symax, PLFLT *szmin, PLFLT *szmax){
void GDLGStream::getSubpageRegion(PLFLT &sxmin, PLFLT &symin, PLFLT &sxmax, PLFLT &symax, PLFLT *szmin, PLFLT *szmax) {
//here we must take into account the contents of ![X|Y|Z].OMARGIN
unsigned int omarginTag = SysVar::X()->Desc()->TagIndex("OMARGIN");
DFloat xstart = (*static_cast<DFloatGDL*> (SysVar::X()->GetTag(omarginTag, 0)))[0];
xstart=MAX(xstart,0);
DFloat xend = (*static_cast<DFloatGDL*> (SysVar::X()->GetTag(omarginTag, 0)))[1];
xend=MAX(xend,0);
omarginTag = SysVar::Y()->Desc()->TagIndex("OMARGIN");
DFloat ystart = (*static_cast<DFloatGDL*> (SysVar::Y()->GetTag(omarginTag, 0)))[0];
ystart=MAX(ystart,0);
DFloat yend = (*static_cast<DFloatGDL*> (SysVar::Y()->GetTag(omarginTag, 0)))[1];
yend=MAX(yend,0);
// Z OMARGIN to BE CHECKED and code must be written.
// omarginTag = SysVar::Z()->Desc()->TagIndex("OMARGIN");
// DFloat zstart = (*static_cast<DFloatGDL*> (SysVar::Z()->GetTag(omarginTag, 0)))[0];
// DFloat zend = (*static_cast<DFloatGDL*> (SysVar::Z()->GetTag(omarginTag, 0)))[1];
DFloat xNormedPageSize=1-(xend+xstart)*theCurrentChar.ndsx;
DFloat yNormedPageSize=1-(yend+ystart)*theCurrentChar.nspacing;
if (xNormedPageSize < 0 || xNormedPageSize > 1 || yNormedPageSize < 0 || yNormedPageSize > 1) {
Message,"Data coordinate system not established.";
if (xNormedPageSize < 0) xNormedPageSize=0;
if (yNormedPageSize < 0) yNormedPageSize=0;
if (xNormedPageSize > 1) xNormedPageSize=1;
if (yNormedPageSize > 1) yNormedPageSize=1;
}
DFloat zNormedPageSize=1; //zend-zstart??;
DFloat xNormedOffset=xstart*theCurrentChar.ndsx;
DFloat yNormedOffset=yend*theCurrentChar.nspacing;
//check silly values: normed must be >0 and < 1
int p=thePage.curPage-1;
PLFLT width=1.0/thePage.nx;
PLFLT height=1.0/thePage.ny;
PLFLT profund=1.0/thePage.nz;
PLFLT width=xNormedPageSize/thePage.nx;
PLFLT height=yNormedPageSize/thePage.ny;
PLFLT profund=zNormedPageSize/thePage.nz;
int k= p / (thePage.nx*thePage.ny);
int l= p - k*(thePage.nx*thePage.ny);
int j= l /thePage.nx ;
int i= (l - j*thePage.nx);
sxmin=i*width;
int i= (l - j*thePage.nx);
sxmin=i*width+xNormedOffset;
sxmax=sxmin+width;
symax=1-(j*height);
symax=1-(j*height+yNormedOffset);
symin=symax-height;
if (szmin != NULL) {
*szmin=k*profund;
Expand Down
3 changes: 2 additions & 1 deletion src/libinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,8 @@ void LibInit()

new DLibFunRetNew(lib::t_pdf,string("T_PDF"),2);

new DLibPro(lib::caldat, string("CALDAT"), 7);
const string caldatKey[]={"GDL_DOW","GDL_ICAP",KLISTEND};
new DLibPro(lib::caldat, string("CALDAT"), 7, caldatKey);
new DLibFunRetNew(lib::julday, string("JULDAY"), 6);

// SA: the HYBRID key is used in imsl_zerosys.pro to switch to the modif. brent algo.
Expand Down
Loading
Loading