ATLAS Offline Software
Loading...
Searching...
No Matches
VP1MaterialButton.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Header file for class VP1MaterialButton //
8// //
9// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10// //
11// Initial version: September 2007 //
12// //
14
15#ifndef VP1MATERIALBUTTON_H
16#define VP1MATERIALBUTTON_H
17
19#include "VP1Base/VP1Color.h"
20
21
22#include <QPushButton>
23
24class SoMaterial;
25class IVP1System;
26
27class VP1MaterialButtonBase : public QPushButton, public VP1HelperClassBase{
28 Q_OBJECT
29 public:
30 VP1MaterialButtonBase(QWidget* parent, IVP1System * sys = 0, const QString& helpername = "")
31 : QPushButton(parent),VP1HelperClassBase(sys,helpername){};
32
33 virtual bool setMaterial(SoMaterial*)=0;
34 virtual void copyValuesFromMaterial(SoMaterial*)=0;
35 virtual double lastAppliedTransparency() const=0;
36 virtual double lastAppliedShininess() const=0 ;
37 virtual double lastAppliedBrightness() const=0;
38
39 virtual QByteArray saveState() const =0;
40 virtual void restoreFromState( const QByteArray& )=0 ;
41
43 signals:
45};
46
47
49
50 Q_OBJECT
51
52public:
54 //
55 // Static methods for creating/editing "simple materials" (those
56 // edited in the simple mode of this button). Most typical use case
57 // is to first call createSimpleMaterial(..) to create a new simple
58 // material, and then subsequently connect it to some material
59 // button by the setMaterial(..) method:
60
61 static SoMaterial* createMaterial( const QColor&, const double& brightness = 0.0, const double& transp = 0.0 );
62 static SoMaterial* createMaterial( const double& r, const double& g, double b, const double& brightness = 0.0,const double& transp = 0.0 );
63 static void setMaterialParameters( SoMaterial * m, const QColor&, const double& brightness = 0.0, const double& transp = 0.0 );
64 static void setMaterialParameters( SoMaterial * m, const double& r, const double& g, const double& b, const double& brightness = 0.0, const double& transp = 0.0 );
65 static void setMaterialParametersFromRGB( SoMaterial * m, const int r, const int g, const int b, const double& brightness = 0.0, const double& transp = 0.0 );
66
68
69 VP1MaterialButton(QWidget * parent = 0, int dim = 25);//dim<=0 => Won't change sizepolicy
70 virtual ~VP1MaterialButton();
71
72 bool handleMaterial(SoMaterial *); //Returns false if already handling or null.
73 bool stopHandlingMaterial(SoMaterial *);//Returns false if didn't handle or null.
75
76 void copyValuesFromMaterial(SoMaterial*);
77
78 bool setMaterial(SoMaterial*);//calls copyValuesFromMaterial and handleMaterial in that order:
79
80 const QList<SoMaterial*>& handledMaterials() const;
81
82 void setText ( const QString & );//Forbidden!! Only here since Designer generated code needs it in public.
83
84 void setDimension(int dim);
85
86 QColor lastAppliedDiffuseColour() const;
87 QColor lastAppliedAmbientColour() const;
88 QColor lastAppliedSpecularColour() const;
89 QColor lastAppliedEmissiveColour() const;
90 double lastAppliedTransparency() const;
91 double lastAppliedShininess() const;
92 double lastAppliedBrightness() const;//Redundant
93
94 QWidget& editWindow() ;
95
96 QByteArray saveState() const;
97 void restoreFromState( const QByteArray& );
98
99signals:
100 void lastAppliedChanged(); // emitted when something changes
101
102public Q_SLOTS:
104 void setMaterialText(const QString&);//If set to XXX, title will display "Edit Material XXX"
105
106protected Q_SLOTS:
107 void updatePreview();
109 void apply();
110 void reset();
111 void updateButton();
112 void switchMode();
113 void transparencyChanged();
114
115protected:
116 void mousePressEvent(QMouseEvent *event);
117 void mouseMoveEvent(QMouseEvent *event);
118 void dropEvent(QDropEvent *event);
119 void dragEnterEvent(QDragEnterEvent *event);
120private:
121
122 class Imp;
124
125};
126
127#endif
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
virtual void restoreFromState(const QByteArray &)=0
virtual double lastAppliedShininess() const =0
virtual double lastAppliedBrightness() const =0
virtual bool setMaterial(SoMaterial *)=0
virtual void copyValuesFromMaterial(SoMaterial *)=0
virtual double lastAppliedTransparency() const =0
VP1MaterialButtonBase(QWidget *parent, IVP1System *sys=0, const QString &helpername="")
virtual QByteArray saveState() const =0
fill out with the state of the object (used for drag and drop etc)
void setText(const QString &)
bool stopHandlingMaterial(SoMaterial *)
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
void setMaterialText(const QString &)
void mousePressEvent(QMouseEvent *event)
void dragEnterEvent(QDragEnterEvent *event)
QColor lastAppliedEmissiveColour() const
static SoMaterial * createMaterial(const QColor &, const double &brightness=0.0, const double &transp=0.0)
const QList< SoMaterial * > & handledMaterials() const
QColor lastAppliedAmbientColour() const
bool setMaterial(SoMaterial *)
void dropEvent(QDropEvent *event)
double lastAppliedBrightness() const
static void setMaterialParametersFromRGB(SoMaterial *m, const int r, const int g, const int b, const double &brightness=0.0, const double &transp=0.0)
void copyValuesFromMaterial(SoMaterial *)
VP1MaterialButton(QWidget *parent=0, int dim=25)
void lastAppliedChanged()
void mouseMoveEvent(QMouseEvent *event)
QByteArray saveState() const
fill out with the state of the object (used for drag and drop etc)
void restoreFromState(const QByteArray &)
double lastAppliedTransparency() const
QColor lastAppliedDiffuseColour() const
QColor lastAppliedSpecularColour() const
bool handleMaterial(SoMaterial *)
double lastAppliedShininess() const
int r
Definition globals.cxx:22