Changeset 1971 in Sophya for trunk/SophyaPI/PIext/servnobjm.cc
- Timestamp:
- Apr 30, 2002, 2:34:41 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/servnobjm.cc
r1931 r1971 53 53 mOmg = omg; 54 54 dynlink = NULL; 55 InitGrAttNames();56 55 } 57 56 … … 235 234 vya->DefineXCoordinate(xmin, (xmax-xmin)/np); 236 235 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ; 237 bool fgsr = true; 238 dopt = "thinline," + dopt; 239 int opt = DecodeDispOption(dopt, fgsr); 240 int rsid = mImgapp->DispScDrawer(dr, titre, opt); 241 if (fgsr) mImgapp->RestoreGraphicAtt(); 236 dopt = "thinline " + dopt; 237 int rsid = mImgapp->DispScDrawer(dr, titre, dopt); 242 238 if (nom.length() > 0) { 243 239 mOmg->AddObj(vpy, nom); … … 245 241 } 246 242 } 247 248 243 return; 249 244 } … … 304 299 } 305 300 else titre = nom; 306 bool fgsr = true;307 int opt = DecodeDispOption(dopt, fgsr);308 301 P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false); 309 302 arr->DefineXYCoordinates(xmin, ymin, dx, dy); 310 303 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true); 311 int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt); 312 if (fgsr) mImgapp->RestoreGraphicAtt(); 304 int rsid = mImgapp->Disp3DDrawer(sdr, titre, dopt); 313 305 if (nom.length() > 0) { 314 306 mOmg->AddObj(mtx, nom); … … 352 344 // nt->Print(0,10); 353 345 PINTuple* pin = new PINTuple(nt, true); 354 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));355 346 pin->SelectXY(ntn[0], ntn[1]); 356 347 if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]); 357 348 358 bool fgsr = true; 359 dopt = "defline," + dopt; 360 int opt = DecodeDispOption(dopt, fgsr); 349 dopt = "defline " + dopt; 361 350 string titre = nom + ":" + expy + "%" + expx; 362 mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt); 363 if (fgsr) mImgapp->RestoreGraphicAtt(); 351 mImgapp->DispScDrawer( (PIDrawer*)pin, titre, dopt); 364 352 return; 365 353 } … … 392 380 PINTuple3D* pin = new PINTuple3D(nt, true); 393 381 pin->SelectXYZ(ntn[0], ntn[1], ntn[2]); 394 bool fgsr = true; 395 dopt = "defline," + dopt; 396 int opt = DecodeDispOption(dopt, fgsr); 382 dopt = "defline " + dopt; 397 383 398 384 // Pour plot a partir de DispScDrawer … … 401 387 // Pour plot a partir de Disp3DDrawer 402 388 string titre = nom + ":" + expy + "%" + expx; 403 mImgapp->Disp3DDrawer(pin, titre, opt); 404 405 if (fgsr) mImgapp->RestoreGraphicAtt(); 389 mImgapp->Disp3DDrawer(pin, titre, dopt); 390 406 391 return; 407 392 } … … 432 417 433 418 PINTuple* pin = new PINTuple(nt, true); 434 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));435 419 pin->SelectXY(ntn[0], ntn[1]); 436 420 pin->SelectWt(ntn[2]); 437 421 438 bool fgsr = true;439 int opt = DecodeDispOption(dopt, fgsr);440 422 string titre = nom + ":" + expwt + "_" + expy + "%" + expx ; 441 mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt); 442 if (fgsr) mImgapp->RestoreGraphicAtt(); 423 mImgapp->DispScDrawer( (PIDrawer*)pin, titre, dopt); 443 424 return; 444 425 } … … 1315 1296 1316 1297 1317 // Variable pour stocker l'option de stat des drawers1318 static bool stats_option = true;1319 /* --Methode-- */1320 void Services2NObjMgr::SetDefaultStatsOption(bool opt)1321 {1322 stats_option = opt;1323 }1324 1325 typedef vector<string> GraTok;1326 1327 /* --Methode-- */1328 bool Services2NObjMgr::GetStatsOption(string& gratt)1329 {1330 int ropt = Disp_Next;1331 for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);1332 // On separe en mots separes par des virgules1333 gratt = ","+gratt;1334 size_t p = 0;1335 size_t q = 0;1336 size_t l = gratt.length();1337 string token;1338 1339 GraTok grt;1340 1341 while (q < l) {1342 p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token1343 if (p>=l) break;1344 q = gratt.find_first_of(" ,",p); // la fin du token;1345 token = gratt.substr(p,q-p);1346 grt.push_back(token);1347 }1348 int k;1349 bool fgsame = false;1350 int option = 0;1351 for(k=0; k<grt.size(); k++) {1352 if ( (grt[k] == "same") || (grt[k] == "s") ) option = 1;1353 else if ( (grt[k] == "stat") || (grt[k] == "stats") ) option = 2;1354 else if ( (grt[k] == "nostat") || (grt[k] == "nostats") ) option = 3;1355 }1356 1357 if (option == 0) return(stats_option);1358 else if ( (option == 1) || (option == 3) ) return(false);1359 else return(true);1360 }1361 1362 /* --Methode-- */1363 int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)1364 {1365 int ropt = Disp_Next;1366 if (!mImgapp) return(ropt);1367 1368 for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);1369 1370 if (fgsrgr) mImgapp->SaveGraphicAtt();1371 1372 if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini1373 mImgapp->SetColAtt();1374 mImgapp->SetLineAtt();1375 mImgapp->SetFontName();1376 mImgapp->SetFontAtt();1377 mImgapp->SetMarkerAtt();1378 mImgapp->SetColMapId();1379 mImgapp->SetReverseColMapFlag();1380 mImgapp->SetZoomAtt();1381 mImgapp->SetAxesAtt();1382 mImgapp->SetXYLimits();1383 mImgapp->UseXYLimits();1384 mImgapp->SetImageCenterPosition();1385 mImgapp->UseImageCenter();1386 mImgapp->SetXLogScale();1387 mImgapp->SetYLogScale();1388 mImgapp->SetAutoAddTitle();1389 stats_option = true;1390 return(ropt);1391 }1392 1393 // On separe en mots separes par des virgules1394 gratt = ","+gratt;1395 size_t p = 0;1396 size_t q = 0;1397 size_t l = gratt.length();1398 string token;1399 1400 GraTok grt;1401 1402 while (q < l) {1403 p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token1404 if (p>=l) break;1405 q = gratt.find_first_of(" ,",p); // la fin du token;1406 token = gratt.substr(p,q-p);1407 grt.push_back(token);1408 }1409 1410 1411 static GrAttNames::iterator it;1412 1413 int k;1414 bool fgcont = true;1415 fgsrgr = false;1416 1417 for(k=0; k<grt.size(); k++) {1418 // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;1419 1420 // Decodage option affichage (win, next, etc1421 fgcont = true;1422 if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;1423 else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;1424 else if ( (grt[k] == "inset") || (grt[k] == "ins") ) ropt = Disp_Inset;1425 else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;1426 else fgcont = false;1427 if (fgcont) continue;1428 1429 // Utilisation limites X-Y1430 if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }1431 if ( grt[k] == "centerimg" ) { mImgapp->UseImageCenter(true); fgsrgr = true; continue; }1432 // Echelle logarithmique d'axe1433 if ( grt[k] == "logx" ) { mImgapp->SetXLogScale(true); fgsrgr = true; continue; }1434 if ( grt[k] == "linx" ) { mImgapp->SetXLogScale(false); fgsrgr = true; continue; }1435 if ( grt[k] == "logy" ) { mImgapp->SetYLogScale(true); fgsrgr = true; continue; }1436 if ( grt[k] == "liny" ) { mImgapp->SetYLogScale(false); fgsrgr = true; continue; }1437 // Ajout automatique de titre1438 if ( ( grt[k] == "tit" ) || ( grt[k] == "title" ) )1439 { mImgapp->SetAutoAddTitle(true); fgsrgr = true; continue; }1440 if ( ( grt[k] == "notit" ) || ( grt[k] == "notitle" ) )1441 { mImgapp->SetAutoAddTitle(false); fgsrgr = true; continue; }1442 1443 // Inversion d'indexage de ColorMap1444 if (grt[k] == "revcmap")1445 { mImgapp->SetReverseColMapFlag(true); fgsrgr = true; continue; }1446 1447 // Si c'est une couleur1448 it = GrAcolors.find(grt[k]);1449 if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }1450 // Si c'est un attribut de lignes1451 it = GrAlines.find(grt[k]);1452 if (it != GrAlines.end()) { mImgapp->SetLineAtt(PILineAtt((PILineTypes)((*it).second.a1))); fgsrgr = true; continue; }1453 // Si c'est un attribut de fontes1454 it = GrAfonts.find(grt[k]);1455 if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );1456 fgsrgr = true; continue; }1457 // Si c'est un nom de fontes1458 it = GrAfontNames.find(grt[k]);1459 if (it != GrAfontNames.end()) { mImgapp->SetFontName((PIFontName)((*it).second.a1));1460 fgsrgr = true; continue; }1461 // Si c'est un attribut de markers1462 it = GrAmarkers.find(grt[k]);1463 if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );1464 fgsrgr = true; continue; }1465 // Si c'est un colormap1466 it = GrAcmap.find(grt[k]);1467 if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }1468 // Si c'est un facteur de zoom1469 it = GrAzoom.find(grt[k]);1470 if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }1471 // Si c'est un attribut d'axe1472 it = GrAaxes.find(grt[k]);1473 if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }1474 1475 }1476 1477 return(ropt);1478 }1479 1480 1481 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1482 // Initialisation des chaines de caracteres designant les attributs graphiques1483 1484 /* --Methode-- */1485 void Services2NObjMgr::InitGrAttNames()1486 {1487 gratt_item gi;1488 // Les couleurs1489 gi.a2 = 0;1490 gi.a1 = PI_NotDefColor;1491 GrAcolors["defcol"] = gi;1492 gi.a1 = PI_Black;1493 GrAcolors["black"] = gi;1494 gi.a1 = PI_White;1495 GrAcolors["white"] = gi;1496 gi.a1 = PI_Grey;1497 GrAcolors["grey"] = gi;1498 gi.a1 = PI_Red;1499 GrAcolors["red"] = gi;1500 gi.a1 = PI_Blue;1501 GrAcolors["blue"] = gi;1502 gi.a1 = PI_Green;1503 GrAcolors["green"] = gi;1504 gi.a1 = PI_Yellow;1505 GrAcolors["yellow"] = gi;1506 gi.a1 = PI_Magenta;1507 GrAcolors["magenta"] = gi;1508 1509 gi.a1 = PI_Cyan;1510 GrAcolors["cyan"] = gi;1511 gi.a1 = PI_Turquoise;1512 GrAcolors["turquoise"] = gi;1513 gi.a1 = PI_NavyBlue;1514 GrAcolors["navyblue"] = gi;1515 gi.a1 = PI_Orange;1516 GrAcolors["orange"] = gi;1517 gi.a1 = PI_SiennaRed;1518 GrAcolors["siennared"] = gi;1519 gi.a1 = PI_Purple;1520 GrAcolors["purple"] = gi;1521 gi.a1 = PI_LimeGreen;1522 GrAcolors["limegreen"] = gi;1523 gi.a1 = PI_Gold;1524 GrAcolors["gold"] = gi;1525 gi.a1 = PI_Violet;1526 GrAcolors["violet"] = gi;1527 gi.a1 = PI_VioletRed;1528 GrAcolors["violetred"] = gi;1529 gi.a1 = PI_BlueViolet;1530 GrAcolors["blueviolet"] = gi;1531 gi.a1 = PI_DarkViolet;1532 GrAcolors["darkviolet"] = gi;1533 1534 // Les attributs de lignes1535 gi.a2 = 0;1536 gi.a1 = PI_NotDefLineAtt;1537 GrAlines["defline"] = gi;1538 gi.a1 = PI_NormalLine;1539 GrAlines["normalline"] = gi;1540 gi.a1 = PI_ThinLine;1541 GrAlines["thinline"] = gi;1542 gi.a1 = PI_ThickLine;1543 GrAlines["thickline"] = gi;1544 gi.a1 = PI_DashedLine;1545 GrAlines["dashedline"] = gi;1546 gi.a1 = PI_ThinDashedLine;1547 GrAlines["thindashedline"] = gi;1548 gi.a1 = PI_ThickDashedLine;1549 GrAlines["thickdashedline"] = gi;1550 gi.a1 = PI_DottedLine;1551 GrAlines["dottedline"] = gi;1552 gi.a1 = PI_ThinDottedLine;1553 GrAlines["thindottedline"] = gi;1554 gi.a1 = PI_ThickDottedLine;1555 GrAlines["thickdottedline"] = gi;1556 gi.a1 = PI_DashDottedLine;1557 GrAlines["dashdottedline"] = gi;1558 gi.a1 = PI_ThinDashDottedLine;1559 GrAlines["thindashdottedline"] = gi;1560 gi.a1 = PI_ThickDashDottedLine;1561 GrAlines["thickdashdottedline"] = gi;1562 1563 // Noms de fontes1564 gi.a2 = 0;1565 gi.a1 = PI_DefaultFont;1566 GrAfontNames["deffont"] = gi;1567 gi.a1 = PI_CourierFont;1568 GrAfontNames["courierfont"] = gi;1569 gi.a1 = PI_HelveticaFont;1570 GrAfontNames["helveticafont"] = gi;1571 gi.a1 = PI_TimesFont;1572 GrAfontNames["timesfont"] = gi;1573 gi.a1 = PI_SymbolFont;1574 GrAfontNames["symbolfont"] = gi;1575 1576 // Attributs de fontes1577 gi.a2 = PI_NotDefFontSize;1578 gi.a1 = PI_NotDefFontAtt;1579 GrAfontNames["deffontatt"] = gi;1580 gi.a2 = PI_NormalSizeFont;1581 gi.a1 = PI_RomanFont;1582 GrAfonts["normalfont"] = gi;1583 gi.a1 = PI_BoldFont;1584 GrAfonts["boldfont"] = gi;1585 gi.a1 = PI_ItalicFont;1586 GrAfonts["italicfont"] = gi;1587 gi.a1 = PI_BoldItalicFont;1588 GrAfonts["bolditalicfont"] = gi;1589 gi.a2 = PI_SmallSizeFont;1590 gi.a1 = PI_RomanFont;1591 GrAfonts["smallfont"] = gi;1592 gi.a1 = PI_BoldFont;1593 GrAfonts["smallboldfont"] = gi;1594 gi.a1 = PI_ItalicFont;1595 GrAfonts["smallitalicfont"] = gi;1596 gi.a1 = PI_BoldItalicFont;1597 GrAfonts["smallbolditalicfont"] = gi;1598 gi.a2 = PI_LargeSizeFont;1599 gi.a1 = PI_RomanFont;1600 GrAfonts["bigfont"] = gi;1601 GrAfonts["largefont"] = gi;1602 gi.a1 = PI_BoldFont;1603 GrAfonts["bigboldfont"] = gi;1604 gi.a1 = PI_ItalicFont;1605 GrAfonts["bigitalicfont"] = gi;1606 GrAfonts["largeitalicfont"] = gi;1607 gi.a1 = PI_BoldItalicFont;1608 GrAfonts["bigbolditalicfont"] = gi;1609 GrAfonts["largebolditalicfont"] = gi;1610 gi.a2 = PI_HugeSizeFont;1611 gi.a1 = PI_RomanFont;1612 GrAfonts["hugefont"] = gi;1613 gi.a1 = PI_BoldFont;1614 GrAfonts["hugeboldfont"] = gi;1615 gi.a1 = PI_ItalicFont;1616 GrAfonts["hugeitalicfont"] = gi;1617 gi.a1 = PI_BoldItalicFont;1618 GrAfonts["hugebolditalicfont"] = gi;1619 1620 1621 // Les markers1622 const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",1623 "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",1624 "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};1625 PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,1626 PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,1627 PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};1628 1629 gi.a2 = 0;1630 gi.a1 = PI_NotDefMarker;1631 GrAmarkers["defmarker"] = gi;1632 1633 for(int j=0; j<11; j++) {1634 string smrk;1635 char buff[16];1636 for(int m=1; m<10; m+=2) {1637 sprintf(buff,"%d",m);1638 smrk = (string)mrkn[j] + (string)buff;1639 gi.a1 = mrk[j]; gi.a2 = m;1640 GrAmarkers[smrk] = gi;1641 }1642 }1643 1644 // Les tables de couleurs1645 gi.a2 = 0;1646 gi.a1 = CMAP_OTHER;1647 GrAcmap["defcmap"] = gi;1648 for(int kcc=0; kcc<PIColorMap::NumberStandardColorMaps(); kcc++) {1649 gi.a1 = PIColorMap::GetStandardColorMapId(kcc);1650 string colname = PIColorMap::GetStandardColorMapName(kcc);1651 for(int jll=0; jll<colname.length(); jll++)1652 colname[jll] = tolower(colname[jll]);1653 GrAcmap[colname] = gi;1654 }1655 1656 1657 // La valeur de zoom1658 gi.a2 = 0;1659 gi.a1 = 0;1660 GrAzoom["defzoom"] = gi;1661 gi.a1 = 1;1662 GrAzoom["zoomx1"] = gi;1663 gi.a1 = 2;1664 GrAzoom["zoomx2"] = gi;1665 gi.a1 = 3;1666 GrAzoom["zoomx3"] = gi;1667 gi.a1 = 4;1668 GrAzoom["zoomx4"] = gi;1669 gi.a1 = 5;1670 GrAzoom["zoomx5"] = gi;1671 gi.a1 = -2;1672 GrAzoom["zoom/2"] = gi;1673 gi.a1 = -3;1674 GrAzoom["zoom/3"] = gi;1675 gi.a1 = -4;1676 GrAzoom["zoom/4"] = gi;1677 gi.a1 = -5;1678 GrAzoom["zoom/5"] = gi;1679 1680 // Attributs d'axes1681 gi.a2 = 0;1682 gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);1683 GrAaxes["stdaxes"] = gi;1684 GrAaxes["defaxes"] = gi;1685 GrAaxes["boxaxes"] = gi;1686 gi.a1 = (int)kAxesDflt;1687 GrAaxes["simpleaxes"] = gi;1688 gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);1689 GrAaxes["boxaxesgrid"] = gi;1690 1691 gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);1692 GrAaxes["fineaxes"] = gi;1693 gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);1694 GrAaxes["grid"] = gi;1695 GrAaxes["fineaxesgrid"] = gi;1696 1697 }1698 1298 1699 1299
Note:
See TracChangeset
for help on using the changeset viewer.