** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phantom.cpp,v 1.4 2000/06/22 10:17:28 kevin Exp $
+** $Id: phantom.cpp,v 1.7 2000/07/15 08:36:13 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
Phantom::PhantomID
Phantom::convertNameToPhantomID (const char* const phmName)
{
- PhantomID id;
+ PhantomID id = PHM_INVALID;
if (strcasecmp (phmName, PHM_HERMAN_STR) == 0)
id = PHM_HERMAN;
id = PHM_BROWLAND;
else if (strcasecmp (phmName, PHM_UNITPULSE_STR) == 0)
id = PHM_UNITPULSE;
- else
- id = PHM_INVALID;
return (id);
}
Phantom::createFromPhantom (const char* const phmName)
{
PhantomID phmid = convertNameToPhantomID (phmName);
- m_name = phmName;
+ if (phmid == PHM_INVALID) {
+ m_fail = true;
+ m_failMessage = "Invalid phantom name ";
+ m_failMessage += phmName;
+ return false;
+ }
+ m_name = phmName;
createFromPhantom (phmid);
+ return true;
}
bool
addPElem ("ellipse", 0., 0., 1., 1., 0., 1.); // pulse
break;
default:
- sys_error (ERR_WARNING, "Illegal phantom id %d\n", phmid);
- m_name += " -- INVALID";
m_fail = true;
+ m_failMessage = "Illegal phantom id ";
+ m_failMessage += phmid;
return false;
- break;
}
m_id = phmid;
ymax = ymin + wsize;
printf("Drawing Phantom:\n\n");
- printf(" data limits: %9.3g, %9.3g, %9.3g, %9.3g\n",
- m_xmin, m_ymin, m_xmax, m_ymax);
- printf(" window size: %9.3g, %9.3g, %9.3g, %9.3g\n",
- xmin, ymin, xmax, ymax);
+ printf(" data limits: %9.3g, %9.3g, %9.3g, %9.3g\n", m_xmin, m_ymin, m_xmax, m_ymax);
+ printf(" window size: %9.3g, %9.3g, %9.3g, %9.3g\n", xmin, ymin, xmax, ymax);
- gid = sgp2_init(0, 0, "Phantom Show");
+ gid = sgp2_init (0, 0, "Phantom Show");
sgp2_window (xmin, ymin, xmax, ymax);
draw();
- termgrf2();
+ sgp2_close (gid);
}
#endif
void
Phantom::addStdRowland (void)
{
- addPElem("ellipse", 0.0000, 0.0000, 0.6900, 0.9200, 0.0, 1.00);
- addPElem("ellipse", 0.0000, -0.0184, 0.6624, 0.8740, 0.0, -0.98);
- addPElem("ellipse", 0.2200, 0.0000, 0.1100, 0.3100, -18.0, -0.02);
- addPElem("ellipse", -0.2200, 0.0000, 0.1600, 0.4100, 18.0, -0.02);
- addPElem("ellipse", 0.0000, 0.3500, 0.2100, 0.2500, 0.0, 0.01);
- addPElem("ellipse", 0.0000, 0.1000, 0.0460, 0.0460, 0.0, 0.01);
- addPElem("ellipse", 0.0000, -0.1000, 0.0460, 0.0460, 0.0, 0.01);
- addPElem("ellipse", -0.0800, -0.6050, 0.0460, 0.0230, 0.0, 0.01);
- addPElem("ellipse", 0.0000, -0.6050, 0.0230, 0.0230, 0.0, 0.01);
- addPElem("ellipse", 0.0600, -0.6050, 0.0230, 0.0230, 0.0, 0.01);
- addPElem("ellipse", 0.5538, -0.3858, 0.0330, 0.2060, -18.0, 0.03);
+ addPElem ("ellipse", 0.0000, 0.0000, 0.6900, 0.9200, 0.0, 1.00);
+ addPElem ("ellipse", 0.0000, -0.0184, 0.6624, 0.8740, 0.0, -0.98);
+ addPElem ("ellipse", 0.2200, 0.0000, 0.1100, 0.3100, -18.0, -0.02);
+ addPElem ("ellipse", -0.2200, 0.0000, 0.1600, 0.4100, 18.0, -0.02);
+ addPElem ("ellipse", 0.0000, 0.3500, 0.2100, 0.2500, 0.0, 0.01);
+ addPElem ("ellipse", 0.0000, 0.1000, 0.0460, 0.0460, 0.0, 0.01);
+ addPElem ("ellipse", 0.0000, -0.1000, 0.0460, 0.0460, 0.0, 0.01);
+ addPElem ("ellipse", -0.0800, -0.6050, 0.0460, 0.0230, 0.0, 0.01);
+ addPElem ("ellipse", 0.0000, -0.6050, 0.0230, 0.0230, 0.0, 0.01);
+ addPElem ("ellipse", 0.0600, -0.6050, 0.0230, 0.0230, 0.0, 0.01);
+ addPElem ("ellipse", 0.5538, -0.3858, 0.0330, 0.2060, -18.0, 0.03);
}
void
void
Phantom::addStdHerman (void)
{
- addPElem("ellipse", 0.000, 1.50, 0.375, 0.3000, 90.00, -0.003);
- addPElem("ellipse", 0.675, -0.75, 0.225, 0.1500, 140.00, 0.010);
- addPElem("ellipse", 0.750, 1.50, 0.375, 0.2250, 50.00, 0.003);
- addPElem("segment", 1.375, -7.50, 1.100, 0.6250, 19.20, -0.204);
- addPElem("segment", 1.375, -7.50, 1.100, 4.3200, 19.21, 0.204);
- addPElem("segment", 0.000, -2.25, 1.125, 0.3750, 0.00, -0.003);
- addPElem("segment", 0.000, -2.25, 1.125, 3.0000, 0.00, 0.003);
- addPElem("segment", -1.000, 3.75, 1.000, 0.5000, 135.00, -0.003);
- addPElem("segment", -1.000, 3.75, 1.000, 3.0000, 135.00, 0.003);
- addPElem("segment", 1.000, 3.75, 1.000, 0.5000, 225.00, -0.003);
- addPElem("segment", 1.000, 3.75, 1.000, 3.0000, 225.00, 0.003);
- addPElem("triangle", 5.025, 3.75, 1.125, 0.5000, 110.75, 0.206);
- addPElem("triangle",-5.025, 3.75, 1.125, 0.9000,-110.75, 0.206);
- addPElem("ellipse", 0.000, 0.00, 8.625, 6.4687, 90.00, 0.416);
- addPElem("ellipse", 0.000, 0.00, 7.875, 5.7187, 90.00, -0.206);
+ addPElem ("ellipse", 0.000, 1.50, 0.375, 0.3000, 90.00, -0.003);
+ addPElem ("ellipse", 0.675, -0.75, 0.225, 0.1500, 140.00, 0.010);
+ addPElem ("ellipse", 0.750, 1.50, 0.375, 0.2250, 50.00, 0.003);
+ addPElem ("segment", 1.375, -7.50, 1.100, 0.6250, 19.20, -0.204);
+ addPElem ("segment", 1.375, -7.50, 1.100, 4.3200, 19.21, 0.204);
+ addPElem ("segment", 0.000, -2.25, 1.125, 0.3750, 0.00, -0.003);
+ addPElem ("segment", 0.000, -2.25, 1.125, 3.0000, 0.00, 0.003);
+ addPElem ("segment", -1.000, 3.75, 1.000, 0.5000, 135.00, -0.003);
+ addPElem ("segment", -1.000, 3.75, 1.000, 3.0000, 135.00, 0.003);
+ addPElem ("segment", 1.000, 3.75, 1.000, 0.5000, 225.00, -0.003);
+ addPElem ("segment", 1.000, 3.75, 1.000, 3.0000, 225.00, 0.003);
+ addPElem ("triangle", 5.025, 3.75, 1.125, 0.5000, 110.75, 0.206);
+ addPElem ("triangle",-5.025, 3.75, 1.125, 0.9000,-110.75, 0.206);
+ addPElem ("ellipse", 0.000, 0.00, 8.625, 6.4687, 90.00, 0.416);
+ addPElem ("ellipse", 0.000, 0.00, 7.875, 5.7187, 90.00, -0.206);
}
void
Phantom::addStdHermanBordered (void)
{
- addPElem("ellipse", 0., 0., 6.6, 5.9, 90., 0.);
+ addStdHerman();
+ addPElem ("ellipse", 0.000, 0.000, 8.650, 8.650, 0.00, 0.000);
}