00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef G4VIS_BUILD_OI_DRIVER
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <HEPVis/nodes/SoMarkerSet.h>
00037
00038 #include <Inventor/errors/SoDebugError.h>
00039 #include <Inventor/misc/SoState.h>
00040 #include <Inventor/actions/SoGLRenderAction.h>
00041 #include <Inventor/nodes/SoPointSet.h>
00042
00043 #include <Inventor/elements/SoCoordinateElement.h>
00044 #include <Inventor/elements/SoCacheElement.h>
00045 #include <Inventor/elements/SoLazyElement.h>
00046
00047 #include <HEPVis/SbGL.h>
00048 #include <HEPVis/actions/SoGL2PSAction.h>
00049
00050 static void drawMarker(SoAction*,int);
00051 static GLubyte* getBitmap(int,int,char []);
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00075 static char plus_5_5[] = {
00076 " x "
00077 " x "
00078 "xxxxx"
00079 " x "
00080 " x "
00081 };
00082 static char asterisk_5_5[] = {
00083 "x x x"
00084 " xxx "
00085 " x "
00086 " xxx "
00087 "x x x"
00088 };
00089 static char cross_5_5[] = {
00090 "x x"
00091 " x x "
00092 " x "
00093 " x x "
00094 "x x"
00095 };
00096 static char star_5_5[] = {
00097 "x x x"
00098 " xxx "
00099 "xxxxx"
00100 " xxx "
00101 "x x x"
00102 };
00103 static char circle_line_5_5[] = {
00104 " xxx "
00105 "x x"
00106 "x x"
00107 "x x"
00108 " xxx "
00109 };
00110 static char circle_filled_5_5[] = {
00111 " xxx "
00112 "xxxxx"
00113 "xxxxx"
00114 "xxxxx"
00115 " xxx "
00116 };
00117 static char triangle_up_line_5_5[] = {
00118 "xxxxx"
00119 " x x "
00120 " x x "
00121 " x "
00122 " x "
00123 };
00124 static char triangle_up_filled_5_5[] = {
00125 "xxxxx"
00126 " xxx "
00127 " xxx "
00128 " x "
00129 " x "
00130 };
00131 static char triangle_down_line_5_5[] = {
00132 " x "
00133 " x "
00134 " x x "
00135 " x x "
00136 "xxxxx"
00137 };
00138 static char triangle_down_filled_5_5[] = {
00139 " x "
00140 " x "
00141 " xxx "
00142 " xxx "
00143 "xxxxx"
00144 };
00145 static char david_star_line_5_5[] = {
00146 " x "
00147 "xxxxx"
00148 " x x "
00149 "xxxxx"
00150 " x "
00151 };
00152 static char david_star_filled_5_5[] = {
00153 " x "
00154 "xxxxx"
00155 " xxx "
00156 "xxxxx"
00157 " x "
00158 };
00159 static char swiss_cross_line_5_5[] = {
00160 " xxx "
00161 "xx xx"
00162 "x x"
00163 "xx xx"
00164 " xxx "
00165 };
00166 static char swiss_cross_filled_5_5[] = {
00167 " xxx "
00168 "xxxxx"
00169 "xxxxx"
00170 "xxxxx"
00171 " xxx "
00172 };
00173 static char diamond_line_5_5[] = {
00174 " x "
00175 " x x "
00176 "x x"
00177 " x x "
00178 " x "
00179 };
00180 static char diamond_filled_5_5[] = {
00181 " x "
00182 " xxx "
00183 "xxxxx"
00184 " xxx "
00185 " x "
00186 };
00187 static char square_line_5_5[] = {
00188 "xxxxx"
00189 "x x"
00190 "x x"
00191 "x x"
00192 "xxxxx"
00193 };
00194 static char square_filled_5_5[] = {
00195 "xxxxx"
00196 "xxxxx"
00197 "xxxxx"
00198 "xxxxx"
00199 "xxxxx"
00200 };
00204 static char plus_7_7[] = {
00205 " x "
00206 " x "
00207 " x "
00208 "xxxxxxx"
00209 " x "
00210 " x "
00211 " x "
00212 };
00213 static char asterisk_7_7[] = {
00214 "x x x"
00215 " x x x "
00216 " xxx "
00217 " x "
00218 " xxx "
00219 " x x x "
00220 "x x x"
00221 };
00222 static char cross_7_7[] = {
00223 "x x"
00224 " x x "
00225 " xxx "
00226 " x "
00227 " xxx "
00228 " x x "
00229 "x x"
00230 };
00231 static char star_7_7[] = {
00232 "x x x"
00233 " x x x "
00234 " xxx "
00235 "xxxxxxx"
00236 " xxx "
00237 " x x x "
00238 "x x x"
00239 };
00240 static char circle_line_7_7[] = {
00241 " xxxxx "
00242 "x x"
00243 "x x"
00244 "x x"
00245 "x x"
00246 "x x"
00247 " xxxxx "
00248 };
00249 static char circle_filled_7_7[] = {
00250 " xxxxx "
00251 "xxxxxxx"
00252 "xxxxxxx"
00253 "xxxxxxx"
00254 "xxxxxxx"
00255 "xxxxxxx"
00256 " xxxxx "
00257 };
00258 static char triangle_up_line_7_7[] = {
00259 "xxxxxxx"
00260 " x x "
00261 " x x "
00262 " x x "
00263 " x x "
00264 " x "
00265 " x "
00266 };
00267 static char triangle_up_filled_7_7[] = {
00268 "xxxxxxx"
00269 " xxxxx "
00270 " xxxxx "
00271 " xxx "
00272 " xxx "
00273 " x "
00274 " x "
00275 };
00276 static char triangle_down_line_7_7[] = {
00277 " x "
00278 " x "
00279 " x x "
00280 " x x "
00281 " x x "
00282 " x x "
00283 "xxxxxxx"
00284 };
00285 static char triangle_down_filled_7_7[] = {
00286 " x "
00287 " x "
00288 " xxx "
00289 " xxx "
00290 " xxxxx "
00291 " xxxxx "
00292 "xxxxxxx"
00293 };
00294 static char david_star_line_7_7[] = {
00295 " x "
00296 "xxxxxxx"
00297 " x x "
00298 " x x "
00299 " x x "
00300 "xxxxxxx"
00301 " x "
00302 };
00303 static char david_star_filled_7_7[] = {
00304 " x "
00305 "xxxxxxx"
00306 " xxxxx "
00307 " xxx "
00308 " xxxxx "
00309 "xxxxxxx"
00310 " x "
00311 };
00312 static char swiss_cross_line_7_7[] = {
00313 " xxx "
00314 " x x "
00315 "xxx xxx"
00316 "x x"
00317 "xxx xxx"
00318 " x x "
00319 " xxx "
00320 };
00321 static char swiss_cross_filled_7_7[] = {
00322 " xxx "
00323 " xxx "
00324 "xxxxxxx"
00325 "xxxxxxx"
00326 "xxxxxxx"
00327 " xxx "
00328 " xxx "
00329 };
00330 static char diamond_line_7_7[] = {
00331 " x "
00332 " x x "
00333 " x x "
00334 "x x"
00335 " x x "
00336 " x x "
00337 " x "
00338 };
00339 static char diamond_filled_7_7[] = {
00340 " x "
00341 " xxx "
00342 " xxxxx "
00343 "xxxxxxx"
00344 " xxxxx "
00345 " xxx "
00346 " x "
00347 };
00348 static char square_line_7_7[] = {
00349 "xxxxxxx"
00350 "x x"
00351 "x x"
00352 "x x"
00353 "x x"
00354 "x x"
00355 "xxxxxxx"
00356 };
00357 static char square_filled_7_7[] = {
00358 "xxxxxxx"
00359 "xxxxxxx"
00360 "xxxxxxx"
00361 "xxxxxxx"
00362 "xxxxxxx"
00363 "xxxxxxx"
00364 "xxxxxxx"
00365 };
00366
00370 static char plus_9_9[] = {
00371 " x "
00372 " x "
00373 " x "
00374 " x "
00375 "xxxxxxxxx"
00376 " x "
00377 " x "
00378 " x "
00379 " x "
00380 };
00381 static char asterisk_9_9[] = {
00382 "x x x"
00383 " x x x "
00384 " x x x "
00385 " xxx "
00386 " x "
00387 " xxx "
00388 " x x x "
00389 " x x x "
00390 "x x x"
00391 };
00392 static char cross_9_9[] = {
00393 "x x"
00394 " x x "
00395 " x x "
00396 " x x "
00397 " x "
00398 " x x "
00399 " x x "
00400 " x x "
00401 "x x"
00402 };
00403 static char star_9_9[] = {
00404 "x x x"
00405 " x x x "
00406 " x x x "
00407 " xxx "
00408 "xxxxxxxxx"
00409 " xxx "
00410 " x x x "
00411 " x x x "
00412 "x x x"
00413 };
00414 static char circle_line_9_9[] = {
00415 " xxx "
00416 " xx xx "
00417 " x x "
00418 "x x"
00419 "x x"
00420 "x x"
00421 " x x "
00422 " xx xx "
00423 " xxx "
00424 };
00425 static char circle_filled_9_9[] = {
00426 " xxx "
00427 " xxxxxxx "
00428 " xxxxxxx "
00429 "xxxxxxxxx"
00430 "xxxxxxxxx"
00431 "xxxxxxxxx"
00432 " xxxxxxx "
00433 " xxxxxxx "
00434 " xxx "
00435 };
00436 static char triangle_up_line_9_9[] = {
00437 "xxxxxxxxx"
00438 " x x "
00439 " x x "
00440 " x x "
00441 " x x "
00442 " x x "
00443 " x x "
00444 " x "
00445 " x "
00446 };
00447 static char triangle_up_filled_9_9[] = {
00448 "xxxxxxxxx"
00449 " xxxxxxx "
00450 " xxxxxxx "
00451 " xxxxx "
00452 " xxxxx "
00453 " xxx "
00454 " xxx "
00455 " x "
00456 " x "
00457 };
00458 static char triangle_down_line_9_9[] = {
00459 " x "
00460 " x "
00461 " x x "
00462 " x x "
00463 " x x "
00464 " x x "
00465 " x x "
00466 " x x "
00467 "xxxxxxxxx"
00468 };
00469 static char triangle_down_filled_9_9[] = {
00470 " x "
00471 " x "
00472 " xxx "
00473 " xxx "
00474 " xxxxx "
00475 " xxxxx "
00476 " xxxxxxx "
00477 " xxxxxxx "
00478 "xxxxxxxxx"
00479 };
00480 static char david_star_line_9_9[] = {
00481 " x "
00482 " x x "
00483 "xxxxxxxxx"
00484 " x x "
00485 " x x "
00486 " x x "
00487 "xxxxxxxxx"
00488 " x x "
00489 " x "
00490 };
00491 static char david_star_filled_9_9[] = {
00492 " x "
00493 " xxx "
00494 "xxxxxxxxx"
00495 " xxxxxxx "
00496 " xxxxx "
00497 " xxxxxxx "
00498 "xxxxxxxxx"
00499 " xxx "
00500 " x "
00501 };
00502 static char swiss_cross_line_9_9[] = {
00503 " xxx "
00504 " x x "
00505 " x x "
00506 "xxxx xxxx"
00507 "x x"
00508 "xxxx xxxx"
00509 " x x "
00510 " x x "
00511 " xxx "
00512 };
00513 static char swiss_cross_filled_9_9[] = {
00514 " xxx "
00515 " xxx "
00516 " xxx "
00517 "xxxxxxxxx"
00518 "xxxxxxxxx"
00519 "xxxxxxxxx"
00520 " xxx "
00521 " xxx "
00522 " xxx "
00523 };
00524 static char diamond_line_9_9[] = {
00525 " x "
00526 " x x "
00527 " x x "
00528 " x x "
00529 "x x"
00530 " x x "
00531 " x x "
00532 " x x "
00533 " x "
00534 };
00535 static char diamond_filled_9_9[] = {
00536 " x "
00537 " xxx "
00538 " xxxxx "
00539 " xxxxxxx "
00540 "xxxxxxxxx"
00541 " xxxxxxx "
00542 " xxxxx "
00543 " xxx "
00544 " x "
00545 };
00546 static char square_line_9_9[] = {
00547 "xxxxxxxxx"
00548 "x x"
00549 "x x"
00550 "x x"
00551 "x x"
00552 "x x"
00553 "x x"
00554 "x x"
00555 "xxxxxxxxx"
00556 };
00557 static char square_filled_9_9[] = {
00558 "xxxxxxxxx"
00559 "xxxxxxxxx"
00560 "xxxxxxxxx"
00561 "xxxxxxxxx"
00562 "xxxxxxxxx"
00563 "xxxxxxxxx"
00564 "xxxxxxxxx"
00565 "xxxxxxxxx"
00566 "xxxxxxxxx"
00567 };
00568
00569 static char* sFigures[54] = {
00570 plus_5_5,
00571 asterisk_5_5,
00572 cross_5_5,
00573 star_5_5,
00574 circle_line_5_5,
00575 circle_filled_5_5,
00576 triangle_up_line_5_5,
00577 triangle_up_filled_5_5,
00578 triangle_down_line_5_5,
00579 triangle_down_filled_5_5,
00580 david_star_line_5_5,
00581 david_star_filled_5_5,
00582 swiss_cross_line_5_5,
00583 swiss_cross_filled_5_5,
00584 diamond_line_5_5,
00585 diamond_filled_5_5,
00586 square_line_5_5,
00587 square_filled_5_5,
00588 plus_7_7,
00589 asterisk_7_7,
00590 cross_7_7,
00591 star_7_7,
00592 circle_line_7_7,
00593 circle_filled_7_7,
00594 triangle_up_line_7_7,
00595 triangle_up_filled_7_7,
00596 triangle_down_line_7_7,
00597 triangle_down_filled_7_7,
00598 david_star_line_7_7,
00599 david_star_filled_7_7,
00600 swiss_cross_line_7_7,
00601 swiss_cross_filled_7_7,
00602 diamond_line_7_7,
00603 diamond_filled_7_7,
00604 square_line_7_7,
00605 square_filled_7_7,
00606 plus_9_9,
00607 asterisk_9_9,
00608 cross_9_9,
00609 star_9_9,
00610 circle_line_9_9,
00611 circle_filled_9_9,
00612 triangle_up_line_9_9,
00613 triangle_up_filled_9_9,
00614 triangle_down_line_9_9,
00615 triangle_down_filled_9_9,
00616 david_star_line_9_9,
00617 david_star_filled_9_9,
00618 swiss_cross_line_9_9,
00619 swiss_cross_filled_9_9,
00620 diamond_line_9_9,
00621 diamond_filled_9_9,
00622 square_line_9_9,
00623 square_filled_9_9
00624 };
00625
00626 SO_NODE_SOURCE(HEPVis_SoMarkerSet)
00628 void HEPVis_SoMarkerSet::initClass (
00629 )
00632 {
00633 SO_NODE_INIT_CLASS(HEPVis_SoMarkerSet,SoPointSet,"PointSet");
00634 }
00636 HEPVis_SoMarkerSet::HEPVis_SoMarkerSet (
00637 )
00640 {
00641 SO_NODE_CONSTRUCTOR(HEPVis_SoMarkerSet);
00642
00643 SO_NODE_ADD_FIELD(markerIndex,(CROSS_5_5));
00644 }
00646 HEPVis_SoMarkerSet::~HEPVis_SoMarkerSet (
00647 )
00650 {
00651 }
00653 void HEPVis_SoMarkerSet::GLRender (
00654 SoGLRenderAction* aAction
00655 )
00658 {
00659 SoState* state = aAction->getState();
00660
00661 const SoCoordinateElement* coordinateElement =
00662 SoCoordinateElement::getInstance(state);
00663 if(coordinateElement==NULL) return;
00664
00665 if(aAction->isOfType(SoGL2PSAction::getClassTypeId())) {
00666 SoCacheElement::invalidate(state);
00667 }
00668
00669 const SbColor& color = SoLazyElement::getDiffuse(aAction->getState(),0);
00670 float red,green,blue;
00671 color.getValue(red,green,blue);
00672
00673 int mark = markerIndex[0];
00674
00675 int starti = startIndex.getValue();
00676 int pointn = numPoints.getValue();
00677 int pointi;
00678
00679 glPushAttrib( (GLbitfield)(GL_CURRENT_BIT | GL_ENABLE_BIT));
00680 glDisable(GL_LIGHTING);
00681 glColor3f(red,green,blue);
00682
00683 #ifdef WIN32
00684
00685 glDisable(GL_DEPTH_TEST);
00686 #endif
00687
00688 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
00689 for(pointi=starti;pointi<pointn;pointi++){
00690 const SbVec3f& vec = coordinateElement->get3(pointi);
00691 glRasterPos3f(vec[0],vec[1],vec[2]);
00692
00693
00694
00695
00696
00697
00698
00699 drawMarker(aAction,mark);
00700 }
00701
00702 glPopAttrib();
00703 }
00705 void drawMarker(
00706 SoAction* aAction
00707 ,int aStyle
00708 )
00711 {
00712 GLsizei w = 0,h = 0;
00713 GLfloat xorig = 0,yorig = 0;
00714 GLfloat xmove = 0,ymove = 0;
00715
00716 if((aStyle>=0)&&(aStyle<18)) {
00717 w = h = 5;
00718 xorig = yorig = 2;
00719 GLubyte* bitmap = getBitmap(w,h,sFigures[aStyle]);
00720 glBitmap(w,h,xorig,yorig,0.,0.,bitmap);
00721 delete [] bitmap;
00722 } else if((aStyle>=18)&&(aStyle<36)) {
00723 w = h = 7;
00724 xorig = yorig = 3;
00725 GLubyte* bitmap = getBitmap(w,h,sFigures[aStyle]);
00726 glBitmap(w,h,xorig,yorig,0.,0.,bitmap);
00727 delete [] bitmap;
00728 } else if((aStyle>=36)&&(aStyle<54)) {
00729 w = h = 9;
00730 xorig = yorig = 4;
00731 GLubyte* bitmap = getBitmap(w,h,sFigures[aStyle]);
00732 glBitmap(w,h,xorig,yorig,0.,0.,bitmap);
00733 delete [] bitmap;
00734 } else {
00735 return;
00736 }
00737
00738 if(aAction->isOfType(SoGL2PSAction::getClassTypeId())) {
00739 ((SoGL2PSAction*)aAction)->addBitmap(w,h,xorig,yorig,xmove,ymove);
00740 }
00741
00742 }
00744 GLubyte* getBitmap(
00745 int aW
00746 ,int aH
00747 ,char aFigure[]
00748 )
00749
00750
00751 {
00752 int index = 0;
00753 GLubyte* bitmap = new GLubyte[aW * aH + 1];
00754 int ichar = 0;
00755 int ibit = 0;
00756 unsigned char byte = 0;
00757 for ( int row = 0; row < aH; row++ ){
00758 for ( int col = 0; col < aW; col++){
00759 unsigned char c = aFigure[ichar];
00760 ichar++;
00761 if(c==' ') {
00762 ibit++;
00763 } else {
00764 byte += (1<<(7-ibit));
00765 ibit++;
00766 }
00767 if(ibit==8) {
00768
00769
00770
00771 bitmap[index] = byte;
00772 index++;
00773 ibit = 0;
00774 byte = 0;
00775 }
00776
00777 }
00778 if(ibit!=8) {
00779
00780
00781
00782 bitmap[index] = byte;
00783 index++;
00784 ibit = 0;
00785 byte = 0;
00786 }
00787 }
00788 return bitmap;
00789 }
00790
00791 #endif