Week 2 Report

Posted 3 years ago

Hello,
As mentioned in the last post, the work on implementing Annotations for MuseScore has begun! I've coded the header file to begin with. There were a few options for design initially :
1. Use multiple inheritance : Annotation base class inherits from a Text class and a graphical class.
TextAnnotation, ShapeAnnotation, HighlightAnnotation / SegmentAnnotation, ElementAnnotation, RangeAnnotation could then be subclasses in the hierarchy. (For eg : Annotation -> SegmentAnnotation -> TextAnnotation) However, this design looks cumbersome (also includes multiple inheritance) and is perhaps not the best way to implement it.
2. Use a single class and use members to indicate different types of annotations / attachments. I've written the header file keeping this design in mind.
It looks something like this :

class Annotation : public Element {
        Q_OBJECT
        Text* _defaultText;
        QString AnchorType;
        QString AnnotationType;
 
        public:
        void showAnnotation();
        void hideAnnotation();
        void setFgColor(QString);
        void setBgColor(QString);
        void addShape(QString);
        void setTextAnnotation(QString);
        QString getTextAnnotation();
        void editAnnotation();
        QString getAnnotationType();
        QString getAnchorType();
        void attachToAnchor(Element*);
        void delete();
};

Any inputs on the design are welcome.