source: branches/blt4/packages/vizservers/vtkvis/Text3D.h @ 3892

Last change on this file since 3892 was 3892, checked in by gah, 11 years ago
File size: 2.1 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2013  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef VTKVIS_TEXT3D_H
9#define VTKVIS_TEXT3D_H
10
11#include <vtkSmartPointer.h>
12#include <vtkTextActor3D.h>
13#include <vtkTextProperty.h>
14#include <vtkProp3DFollower.h>
15#include <vtkRenderer.h>
16
17#include "GraphicsObject.h"
18#include "DataSet.h"
19
20namespace VtkVis {
21
22/**
23 * \brief Text Label with 3D transform
24 *
25 * This class creates a text label that can be positioned in 3D space
26 */
27class Text3D : public GraphicsObject
28{
29public:
30    Text3D();
31    virtual ~Text3D();
32
33    virtual const char *getClassName() const
34    {
35        return "Text3D";
36    }
37
38    virtual void setDataSet(DataSet *dataSet,
39                            Renderer *renderer)
40    {
41        assert(dataSet == NULL);
42        update();
43    }
44
45    virtual void initProp();
46
47    virtual void setOpacity(double opacity);
48
49    virtual void setColor(float color[3]);
50
51    virtual void setClippingPlanes(vtkPlaneCollection *planes);
52
53    void setText(const char *string)
54    {
55        vtkTextActor3D *textActor = getTextActor();
56        if (textActor != NULL) {
57            textActor->SetInput(string);
58        }
59    }
60
61    void setFont(const char *fontName);
62
63    void setFontSize(int size);
64
65    void setBold(bool state);
66
67    void setItalic(bool state);
68
69    void setShadow(bool state);
70
71    void setFollowCamera(bool state, vtkRenderer *renderer);
72
73private:
74    virtual void update();
75
76    vtkTextActor3D *getTextActor()
77    {
78        if (vtkTextActor3D::SafeDownCast(_prop) != NULL) {
79            return vtkTextActor3D::SafeDownCast(_prop);
80        } else if (vtkProp3DFollower::SafeDownCast(_prop) != NULL) {
81            return vtkTextActor3D::SafeDownCast(vtkProp3DFollower::SafeDownCast(_prop)->GetProp3D());
82        }
83        return NULL;
84    }
85
86    vtkTextProperty *getTextProperty()
87    {
88        vtkTextActor3D *textActor = getTextActor();
89        if (textActor == NULL)
90            return NULL;
91        return textActor->GetTextProperty();
92    }
93};
94
95}
96
97#endif
Note: See TracBrowser for help on using the repository browser.