1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
| oQtExaminerViewer::SoQtExaminerViewer(QWidget * parent,
const char * name,
SbBool embed,
SoQtFullViewer::BuildFlag flag,
SoQtViewer::Type type)
: inherited(parent, name, embed, flag, type, FALSE)
{
PRIVATE(this) = new SoQtExaminerViewerP(this);
PRIVATE(this)->constructor(TRUE);
}
// *************************************************************************
// Documented in common/viewers/SoGuiExaminerViewer.cpp.in.
SoQtExaminerViewer::SoQtExaminerViewer(QWidget * parent,
const char * name,
SbBool embed,
SoQtFullViewer::BuildFlag flag,
SoQtViewer::Type type,
SbBool build)
: inherited(parent, name, embed, flag, type, FALSE)
{
PRIVATE(this) = new SoQtExaminerViewerP(this);
PRIVATE(this)->constructor(build);
}
// *************************************************************************
SoQtExaminerViewer::~SoQtExaminerViewer()
{
delete PRIVATE(this);
}
// *************************************************************************
// Documented in superclass.
void
SoQtExaminerViewer::setCamera(SoCamera * newCamera)
{
// This method overridden from parent class to toggle the camera
// type selection button pixmap and string of the zoom/dolly
// thumbwheel.
if (newCamera) {
SoType camtype = newCamera->getTypeId();
SbBool orthotype =
camtype.isDerivedFrom(SoOrthographicCamera::getClassTypeId());
this->setRightWheelString(orthotype ? "Zoom" : "Dolly");
if (PRIVATE(this)->cameratogglebutton) {
PRIVATE(this)->cameratogglebutton->setPixmap(orthotype ?
* (PRIVATE(this)->orthopixmap) :
* (PRIVATE(this)->perspectivepixmap));
}
}
inherited::setCamera(newCamera);
}
// *************************************************************************
// Documented in superclass. Overridden so we can append the camera
// type switch button in the rightside button column.
void
SoQtExaminerViewer::createViewerButtons(QWidget * parent, SbPList * buttonlist)
{
inherited::createViewerButtons(parent, buttonlist);
PRIVATE(this)->cameratogglebutton = new QPushButton(parent);
#if (defined Q_WS_MAC && QT_VERSION >=0x030100) && defined(HAVE_QSTYLEFACTORY_H)
// Since Qt/Mac 3.1.x, all pushbuttons (even those < 32x32) are drawn
// using the Aqua style, i.e. with rounded edges and shading. This
// looks really ugly in the viewer decoration. Drawing the buttons
// in the Windows style gives us the flat, square buttons we want.
QStyle * style = QStyleFactory::create("windows");
if (style) { PRIVATE(this)->cameratogglebutton->setStyle(style); }
#endif
PRIVATE(this)->cameratogglebutton->setFocusPolicy(QTWIDGET_NOFOCUS);
assert(PRIVATE(this)->perspectivepixmap);
assert(PRIVATE(this)->orthopixmap);
QPixmap * p = NULL;
SoType t = this->getCameraType();
if (t.isDerivedFrom(SoOrthographicCamera::getClassTypeId()))
p = PRIVATE(this)->orthopixmap;
else if (t.isDerivedFrom(SoPerspectiveCamera::getClassTypeId()))
p = PRIVATE(this)->perspectivepixmap;
else assert(0 && "unsupported cameratype");
PRIVATE(this)->cameratogglebutton->setPixmap(*p);
PRIVATE(this)->cameratogglebutton->adjustSize();
QObject::connect(PRIVATE(this)->cameratogglebutton, SIGNAL(clicked()),
PRIVATE(this), SLOT(cameratoggleClicked()));
buttonlist->append(PRIVATE(this)->cameratogglebutton);
}
// *************************************************************************
// SoQtExaminerViewerP "private implementation" class.
#ifndef DOXYGEN_SKIP_THIS
SoQtExaminerViewerP::SoQtExaminerViewerP(SoQtExaminerViewer * publ)
: SoGuiExaminerViewerP(publ)
{
}
SoQtExaminerViewerP::~SoQtExaminerViewerP()
{
// Button pixmaps.
delete this->orthopixmap;
delete this->perspectivepixmap;
this->genericDestructor();
}
// This contains the real constructor code (the two SoQtExaminerViewer
// constructors are only entry points for this method).
void
SoQtExaminerViewerP::constructor(SbBool build)
{
this->genericConstructor();
this->cameratogglebutton = NULL;
this->orthopixmap = new QPixmap((const char **)ortho_xpm);
this->perspectivepixmap = new QPixmap((const char **)perspective_xpm);
assert(this->orthopixmap->size() == this->perspectivepixmap->size());
PUBLIC(this)->setClassName("SoQtExaminerViewer");
PUBLIC(this)->setPopupMenuString("Examiner Viewer");
PUBLIC(this)->setLeftWheelString("Rotx");
PUBLIC(this)->setBottomWheelString("Roty");
if (build) {
QWidget * widget = PUBLIC(this)->buildWidget(PUBLIC(this)->getParentWidget());
PUBLIC(this)->setBaseWidget(widget);
}
}
void
SoQtExaminerViewerP::cameratoggleClicked()
{
if (PUBLIC(this)->getCamera()) PUBLIC(this)->toggleCameraType();
}
// *************************************************************************
#endif // DOXYGEN_SKIP_THIS
#undef PRIVATE
#undef PUBLIC |
Partager