/*************************************************************************** * Copyright (c) 2011-2012 Luke Parry * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #ifndef GUI_SODATUMLABEL_H #define GUI_SODATUMLABEL_H #include #include #include #include #include #include #include #include #include #include #include #include namespace Gui { class GuiExport SoDatumLabel : public SoShape { using inherited = SoShape; SO_NODE_HEADER(SoDatumLabel); public: enum Type { ANGLE, DISTANCE, DISTANCEX, DISTANCEY, RADIUS, DIAMETER, SYMMETRIC }; static void initClass(); SoDatumLabel(); /*The points have to be on XY plane, ie they need to be 2D points. To draw on other planes, you need to attach a SoTransform to the SoDatumLabel (or parent).*/ void setPoints(SbVec3f p1, SbVec3f p2); SoMFString string; SoSFColor textColor; SoSFEnum datumtype; SoSFName name; SoSFInt32 size; SoSFFloat param1; SoSFFloat param2; SoSFFloat param3; SoMFVec3f pnts; SoSFVec3f norm; SoSFImage image; SoSFFloat lineWidth; bool useAntialiasing; protected: ~SoDatumLabel() override {} void GLRender(SoGLRenderAction *action) override; void computeBBox(SoAction *, SbBox3f &box, SbVec3f ¢er) override; void generatePrimitives(SoAction * action) override; void notify(SoNotList * l) override; private: float getScaleFactor(SoState*) const; void generateDistancePrimitives(SoAction * action, const SbVec3f&, const SbVec3f&); void generateDiameterPrimitives(SoAction * action, const SbVec3f&, const SbVec3f&); void generateAnglePrimitives(SoAction * action, const SbVec3f&); void generateSymmetricPrimitives(SoAction * action, const SbVec3f&, const SbVec3f&); private: void drawImage(); SbBox3f bbox; float imgWidth; float imgHeight; bool glimagevalid; }; } #endif // GUI_SODATUMLABEL_H