//
//	Copyright © 2005 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Ben Atwood

#pragma once

namespace VWFC
{
    namespace Tools
    {
        // This class supplements VWParametricObj and adds support for a tag label component.
        // Users should derive from this class, call InitTag during initialization, and
        // implement DrawTagBody to display the tag data.  A call to DrawTag will draw the
        // leader line and call back to DrawTagBody with the correct parameters.
        class VWTaggedObj
        {
        public:
		
			virtual ~VWTaggedObj();

            // Internal ID numbers for the control points
            enum EPointID {
                kTagPoint = 1,
                kShoulderPoint= 2,
                kEndPoint = 3
            };

            // Enumeration for the orientation options for the tag.
            enum ETagOrientation {
                kTagNone = 0,           // Do not draw the tag
                kTagLeft = 1,           // The shoulder should always be facing left
                kTagRight = 2,          // The shoulder should always be facing right
                kTagFloating = 3,
                kTagOrientationMax = 3
            };

            static const char*	TagOrientationStrings[];

            // Call this function to initialize the tag on your parametric object.
            void InitTag(   const MCObjectHandle taggedObjectPtr,
                            short tagControlPointIdx, 
                            short shoulderControlPointIdx, 
                            short endControlPointIdx,
                            short approachLineAngleIdx,
                            short shoulderLineAngleIdx,
                            short tagOrientationIdx,
                            bool useEndMarker,
                            bool useLeaderLineShoulder);

            // Returns the coordinates of the specified control point
            WorldPt GetTagControlPoint(EPointID controlPointID);
    
            // Call this function to draw the tag.  Will call DrawTagBody after the leader line.
            void DrawTag(InternalIndex classID);

            // Call this function to draw the leader line in interactive mode, such as while a
            // control point is being dragged.
            void DrawTagInteractive(EPointID movedPointID, VWPoint2D *cursorOffset = nil);


            // Call this function when a control point has been moved by the user.
            void OnMoveTagControlPoint(EPointID movedPointID, VWPoint2D *cursorOffset = nil);

            void OnControlPointSelected(EPointID movedPointID);

            // Abstract function to be defined by the inheriting class
            // This function should draw the tag body and data with the given parameters.
            virtual void DrawTagBody(VWPoint2D point, double rotation, bool isRightOriented) = 0;

        protected:

            // Returns the absolute angle of the shoulder line.
            double GetAngle(WorldPt a, WorldPt b);

        private:

            //Returns the orientation of the tag.
            ETagOrientation GetTagOrientation();

            //Sets the orientation of the tag
            void SetTagOrientation(ETagOrientation orientation);

            //Draws just the leader line.
            void DrawLeaderLine(InternalIndex classID);

            short tagPointIdx;
            short shoulderPointIdx;
            short endPointIdx;
            short approachAngleIdx;
            short shoulderAngleIdx;
            short orientationIdx;

            bool useMarker;
            bool useShoulder;
            MCObjectHandle objectHandle;

        };
    }
}
