common.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: common.h,v 1.40.16.4 2007/04/20 14:16:50 amoll Exp $
00005 //
00006 
00007 #ifndef BALL_VIEW_KERNEL_COMMON_H
00008 #define BALL_VIEW_KERNEL_COMMON_H
00009 
00010 #ifndef BALL_DATATYPE_STRING_H
00011  #include <BALL/DATATYPE/string.h>
00012 #endif
00013 
00014 #ifndef BALL_MATHS_VECTOR3
00015  #include <BALL/MATHS/vector3.h>
00016 #endif
00017 
00018 #ifndef BALL_CONCEPT_COMPOSITE_H
00019  #include <BALL/CONCEPT/composite.h>
00020 #endif
00021 
00022 #ifndef BALL_DATATYPE_LIST_H
00023  #include <BALL/DATATYPE/list.h>
00024 #endif
00025 
00026 #ifndef BALL_DATATYPE_REGULARDATA3D_H
00027  #include <BALL/DATATYPE/regularData3D.h>
00028 #endif
00029 
00030 #include <QtCore/QEvent>
00031 #include <QtGui/QColorDialog>
00032 #include <QtGui/QLabel>
00033 #include <QtGui/QDropEvent>
00034 
00035 namespace BALL
00036 {
00037   namespace VIEW
00038   {
00039 
00040     class GeometricObject;
00041     class MainControl;
00042     class ColorRGBA;
00043     class Camera;
00044 
00049 
00054     #define VIEW_DEFAULT_PORT 20000
00055 
00058     #define BALL_ASSIGN_NAME(OBJ)\
00059       OBJ->setObjectName(#OBJ);
00060   
00062 
00068 
00075     enum EventsIDs
00076     {
00078       MESSAGE_EVENT = 60000,
00079 
00081       LOG_EVENT,
00082 
00084       TRANSFORMATION_EVENT_6D,
00085       
00087       HEADTRACKING_EVENT,
00088 
00090       MOTIONTRACKING_EVENT,
00091 
00093       BUTTON_PRESS_EVENT,
00094 
00096       BUTTON_RELEASE_EVENT
00097     };
00098 
00100 
00105 
00107     enum DrawingMode
00108     {
00110       DRAWING_MODE_DOTS = 0,
00111 
00113       DRAWING_MODE_WIREFRAME,
00114 
00116       DRAWING_MODE_SOLID,
00117       
00119       DRAWING_MODE_TOON
00120     };
00121 
00123     #define BALL_VIEW_MAXIMAL_DRAWING_MODE 4
00124 
00126     enum DrawingPrecision
00127     {
00129       DRAWING_PRECISION_INVALID = -1,
00130 
00132       DRAWING_PRECISION_LOW = 0,
00133 
00135       DRAWING_PRECISION_MEDIUM,
00136 
00138       DRAWING_PRECISION_HIGH,
00139 
00141       DRAWING_PRECISION_ULTRA
00142     };
00143     
00145     #define BALL_VIEW_MAXIMAL_DRAWING_PRECISION 4
00146 
00148     #define BALL_VIEW_MAXIMAL_DISPLAY_LIST_OBJECT_SIZE  BALL_VIEW_MAXIMAL_DRAWING_PRECISION * BALL_VIEW_MAXIMAL_DRAWING_MODE
00149 
00151     BALL_VIEW_EXPORT extern float SurfaceDrawingPrecisions[4];
00152 
00163     enum ModelType
00164     {
00166       MODEL_LINES = 0,
00167 
00169       MODEL_STICK,
00170 
00172       MODEL_BALL_AND_STICK,
00173       
00175       MODEL_VDW,
00176 
00178       MODEL_SE_SURFACE,
00179 
00181       MODEL_SA_SURFACE,
00182 
00184       MODEL_BACKBONE,
00185 
00187       MODEL_CARTOON,
00188 
00190       MODEL_RIBBON,
00191 
00193       MODEL_HBONDS,
00194 
00196       MODEL_FORCES,
00197 
00198       // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
00199       // add new model types before this comment!!!!
00200       // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
00201       
00203       MODEL_LABEL = 100,
00204 
00206       MODEL_CONTOUR_SURFACE,
00207 
00209       MODEL_GRID_SLICE,
00210 
00212       MODEL_GRID_VOLUME,
00213 
00215       MODEL_FIELD_LINES,
00216 
00218       MODEL_INFORMATIONS,
00219 
00221       MODEL_COORDINATE_SYSTEM,
00222 
00224       MODEL_UNKNOWN = 200
00225     };
00226 
00227 
00231     enum ColoringMethod
00232     {
00234       COLORING_ELEMENT          = 0,
00235 
00237       COLORING_RESIDUE_INDEX,
00238 
00240       COLORING_RESIDUE_NAME,
00241 
00243       COLORING_SECONDARY_STRUCTURE,
00244 
00246       COLORING_ATOM_CHARGE,
00247 
00249       COLORING_DISTANCE,
00250 
00252       COLORING_TEMPERATURE_FACTOR,
00253 
00255       COLORING_OCCUPANCY,
00256 
00258       COLORING_FORCES,
00259 
00261       COLORING_RESIDUE_TYPE,
00262 
00264       COLORING_CHAIN,
00265       
00267       COLORING_MOLECULE,
00268 
00269       // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
00270       // add new coloring types before this comment!!!!
00271       // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
00272       
00274       COLORING_CUSTOM,
00275 
00277       COLORING_UNKNOWN = 200
00278     };
00279 
00284     BALL_VIEW_EXPORT extern Composite composite_to_be_ignored_for_colorprocessors_;
00285 
00287 
00289     BALL_VIEW_EXPORT String vector3ToString(const Vector3& v);
00290 
00292     BALL_VIEW_EXPORT bool stringToVector3(const String& data, Vector3& v);
00293 
00295     BALL_VIEW_EXPORT String createFloatString(float value, Size precision);
00296 
00304     BALL_VIEW_EXPORT MainControl* getMainControl();
00305 
00307     BALL_VIEW_EXPORT String createTemporaryFilename();
00308 
00310     BALL_VIEW_EXPORT Vector3 getNormal(const Vector3& v);
00311 
00313     class BALL_VIEW_EXPORT LogEvent
00314       : public QEvent
00315     {
00316       public:
00317 
00319         LogEvent();
00320 
00322         void setMessage(const String& msg) {message_ = msg;}
00323 
00325         String getMessage() {return message_;}
00326 
00328         bool isImportant() { return important_;}
00329 
00331         void setImportant(bool state) { important_ = state;}
00332 
00334         bool showOnlyInLogView() const { return only_log_;}
00335 
00337         void setShowOnlyInLogView(bool state) { only_log_ = state;}
00338 
00339       protected:
00340         String message_;
00341         bool   important_;
00342         bool   only_log_;
00343     };
00344 
00346     BALL_VIEW_EXPORT void logString(const String& data);
00347 
00349     #define BALLVIEW_DEBUG logString(String("A problem occured in ") + __FILE__ + " " + \
00350                            String(__LINE__) + ".  Please notify us per mail: ball@bioinf.uni-sb.de\n");
00351 
00352   
00353     BALL_VIEW_EXPORT void processDropEvent(QDropEvent* e);
00354 
00358     BALL_VIEW_EXPORT Camera focusCamera(Composite* composite);
00359 
00363     BALL_VIEW_EXPORT Camera focusCamera(const List<Vector3>& points);
00364 
00366     BALL_VIEW_EXPORT String ascii(const QString& str);
00367     
00369     BALL_VIEW_EXPORT ColorRGBA getColor(const QLabel* label);
00370     
00372     BALL_VIEW_EXPORT void setColor(const QLabel* label, const ColorRGBA& color);
00373 
00375     BALL_VIEW_EXPORT QColor chooseColor(QLabel* label);
00376 
00378     BALL_VIEW_EXPORT void setTextColor(QLabel* label, const ColorRGBA& color);
00379 
00383     BALL_VIEW_EXPORT void cubicInterpolation(const Vector3& a, const Vector3& b,
00384                                    const Vector3& tangent_a, const Vector3& tangent_b,
00385                                    std::vector<Vector3>& interpolated_values);
00386 
00389     extern float    icosaeder_vertices[12][3];
00390     extern Position icosaeder_indices[20][3];
00391 
00392     BALL_VIEW_EXPORT void subdivideTriangle(vector<Vector3>& results, Vector3& v1, Vector3& v2, Vector3& v3, Size precision);
00393 
00394     BALL_VIEW_EXPORT vector<Vector3> createSphere(Size precision);
00395 
00396     BALL_VIEW_EXPORT void calculateHistogramEqualization(const vector<float>& values, vector<float>& normalized_values, bool use_absolute_values = false);
00397 
00399     BALL_VIEW_EXPORT void calculateRandomPoints(const RegularData3D& grid, Size nr_points, vector<Vector3>& resulting_points);
00400 
00402 
00403   } // namespace VIEW
00404 } // namespace BALL
00405 
00406 #endif // BALL_VIEW_KERNEL_COMMON_H