Changeset 2836 for trunk/packages


Ignore:
Timestamp:
Mar 9, 2012 3:58:03 PM (12 years ago)
Author:
ldelgass
Message:

More cleanups, remove NEW_FLOW_ENGINE define flag

Location:
trunk/packages/vizservers/nanovis
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/NvCamera.cpp

    r2798 r2836  
    1414 * ======================================================================
    1515 */
     16#include <stdio.h>
    1617
    17 #include <stdio.h>
     18#include <GL/glew.h>
     19#include <GL/glu.h>
     20
     21#include "NvCamera.h"
    1822#include "Trace.h"
    19 #include <GL/glu.h>
    20 #include "NvCamera.h"
    2123
    2224NvCamera::NvCamera(int startx, int starty, int w, int h,
    2325                   float loc_x, float loc_y, float loc_z,
    2426                   float target_x, float target_y, float target_z,
    25                    float angle_x, float angle_y, float angle_z):
    26     location_(Vector3(loc_x, loc_y, loc_z)),
    27     target_(Vector3(target_x, target_y, target_z)),
    28     angle_(Vector3(angle_x, angle_y, angle_z)),
    29     width_(w),
    30     height_(h),
    31     startX_(startx),
    32     startY_(starty)
    33 {
    34     /*empty*/
     27                   float angle_x, float angle_y, float angle_z) :
     28    _location(loc_x, loc_y, loc_z),
     29    _target(target_x, target_y, target_z),
     30    _angle(angle_x, angle_y, angle_z),
     31    _width(w),
     32    _height(h),
     33    _startX(startx),
     34    _startY(starty)
     35{
    3536}
    36 
    3737
    3838void
    3939NvCamera::initialize()
    4040{
    41     TRACE("camera: %d, %d\n", width_, height_);
    42     glViewport(startX_, startY_, width_, height_);
     41    TRACE("camera: %d, %d\n", _width, _height);
     42    glViewport(_startX, _startY, _width, _height);
    4343    glMatrixMode(GL_PROJECTION);
    4444    glLoadIdentity();
    4545    gluPerspective(30,
    46                    (GLdouble)(width_ - startX_)/(GLdouble)(height_ - startY_),
     46                   (GLdouble)(_width - _startX)/(GLdouble)(_height - _startY),
    4747                   0.1, 50.0);
    4848
     
    5050    glLoadIdentity();
    5151
    52     gluLookAt(location_.x, location_.y, location_.z,
    53               target_.x, target_.y, target_.z,
     52    gluLookAt(_location.x, _location.y, _location.z,
     53              _target.x, _target.y, _target.z,
    5454              0., 1., 0.);
    5555
    56     glRotated(angle_.x, 1., 0., 0.);
    57     glRotated(angle_.y, 0., 1., 0.);
    58     glRotated(angle_.z, 0., 0., 1.);
     56    glRotated(_angle.x, 1., 0., 0.);
     57    glRotated(_angle.y, 0., 1., 0.);
     58    glRotated(_angle.z, 0., 0., 1.);
    5959}
    6060
  • trunk/packages/vizservers/nanovis/NvCamera.h

    r2798 r2836  
    1414 * ======================================================================
    1515 */
    16 
    17 #ifndef _CAMERA_H_
    18 #define _CAMERA_H_
     16#ifndef CAMERA_H
     17#define CAMERA_H
    1918
    2019#include "Vector3.h"
    2120
    22 class NvCamera {
    23 
    24     Vector3 location_;          //Location of the camera in the scene
    25     Vector3 target_;            //Location the camera is looking at. 
    26                                 //location and target: two points define the
    27                                 //line-of-sight
    28     Vector3 angle_;             //rotation angles of camera along x, y, z
    29     int width_;                 //screen width
    30     int height_;                //screen height
    31     int startX_;
    32     int startY_;
    33 
     21class NvCamera
     22{
    3423public:
    35     ~NvCamera(void) {
    36         /*empty*/
    37     }   
    3824    NvCamera(int startx, int starty, int w, int h,
    3925             float loc_x, float loc_y, float loc_z,
     
    4127             float angle_x, float angle_y, float angle_z);
    4228
     29    ~NvCamera()
     30    {}
     31
     32
    4333    //move location of camera
    44     void x(float loc_x) {
    45         location_.x = loc_x;
     34    void x(float loc_x)
     35    {
     36        _location.x = loc_x;
    4637    }
    47     float x(void) {
    48         return location_.x;
     38
     39    float x() const
     40    {
     41        return _location.x;
    4942    }
    50     void y(float loc_y) {
    51         location_.y = loc_y;
     43
     44    void y(float loc_y)
     45    {
     46        _location.y = loc_y;
    5247    }
    53     float y(void) {
    54         return location_.y;
     48
     49    float y() const
     50    {
     51        return _location.y;
    5552    }
    56     void z(float loc_z) {
    57         location_.z = loc_z;
     53
     54    void z(float loc_z)
     55    {
     56        _location.z = loc_z;
    5857    }
    59     float z(void) {
    60         return location_.z;
     58
     59    float z() const
     60    {
     61        return _location.z;
    6162    }
    6263
    6364    //move location of target
    64     void xAim(float x) {
    65         target_.x = x;
    66     }
    67     float xAim(void) {
    68         return target_.x;
    69     }
    70     void yAim(float y) {
    71         target_.y = y;
    72     }
    73     float yAim(void) {
    74         return target_.y;
    75     }
    76     void zAim(float z) {
    77         target_.z = z;
    78     }
    79     float zAim(void) {
    80         return target_.z;
     65    void xAim(float x)
     66    {
     67        _target.x = x;
    8168    }
    8269
    83     void rotate(float angle_x, float angle_y, float angle_z) {
    84         angle_ = Vector3(angle_x, angle_y, angle_z);
     70    float xAim() const
     71    {
     72        return _target.x;
    8573    }
    86     void rotate(Vector3 angle) {
    87         angle_ = angle;
     74
     75    void yAim(float y)
     76    {
     77        _target.y = y;
    8878    }
    89     Vector3 rotate(void) {
    90         return angle_;
     79
     80    float yAim() const
     81    {
     82        return _target.y;
    9183    }
    92     void set_screen_size(int sx, int sy, int w, int h) {
    93         width_ = w, height_ = h;
    94         startX_ = sx, startY_ = sy;
     84
     85    void zAim(float z)
     86    {
     87        _target.z = z;
    9588    }
    96     void initialize(void); //make the camera setting active, this has to be
    97                          //called before drawing things.
     89
     90    float zAim() const
     91    {
     92        return _target.z;
     93    }
     94
     95    void rotate(float angle_x, float angle_y, float angle_z)
     96    {
     97        _angle = Vector3(angle_x, angle_y, angle_z);
     98    }
     99
     100    void rotate(const Vector3& angle)
     101    {
     102        _angle = angle;
     103    }
     104
     105    Vector3 rotate() const
     106    {
     107        return _angle;
     108    }
     109
     110    void set_screen_size(int sx, int sy, int w, int h)
     111    {
     112        _width = w;
     113        _height = h;
     114        _startX = sx;
     115        _startY = sy;
     116    }
     117
     118    //make the camera setting active, this has to be
     119    //called before drawing things
     120    void initialize();
     121
     122private:
     123    Vector3 _location;          //Location of the camera in the scene
     124    Vector3 _target;            //Location the camera is looking at. 
     125                                //location and target: two points define the
     126                                //line-of-sight
     127    Vector3 _angle;             //rotation angles of camera along x, y, z
     128    int _width;                 //screen width
     129    int _height;                //screen height
     130    int _startX;
     131    int _startY;
    98132};
    99133
  • trunk/packages/vizservers/nanovis/NvColorTableRenderer.cpp

    r2798 r2836  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <R2/R2Fonts.h>
    3 #include "NvColorTableRenderer.h"
    42#include <stdlib.h>
    53
    6 NvColorTableRenderer::NvColorTableRenderer()
    7 : _fonts(NULL)
     4#include <R2/R2Fonts.h>
     5
     6#include "NvColorTableRenderer.h"
     7
     8NvColorTableRenderer::NvColorTableRenderer() :
     9    _fonts(NULL)
    810{
    911    _shader = new NvColorTableShader();   
     
    1517}
    1618
    17 void NvColorTableRenderer::render(int width, int height, Texture2D* texture, TransferFunction* tf, double rangeMin, double rangeMax)
     19void NvColorTableRenderer::render(int width, int height,
     20                                  Texture2D *texture, TransferFunction *tf,
     21                                  double rangeMin, double rangeMax)
    1822{
    1923    glEnable(GL_TEXTURE_2D);
     
    3135    glLoadIdentity();
    3236
    33     //glColor3f(1.,1.,1.);         //MUST HAVE THIS LINE!!!
     37    //glColor3f(1., 1., 1.);         //MUST HAVE THIS LINE!!!
    3438    _shader->bind(texture, tf);
    3539
     
    4347    _shader->unbind();
    4448
    45     if (_fonts)
    46     {
     49    if (_fonts) {
    4750        _fonts->resize(width, height);
    4851        _fonts->begin();
  • trunk/packages/vizservers/nanovis/NvColorTableRenderer.h

    r2798 r2836  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef __NV_COLORTABLE_RENDERER_H__
    3 #define __NV_COLORTABLE_RENDERER_H__
     2#ifndef NV_COLORTABLE_RENDERER_H
     3#define NV_COLORTABLE_RENDERER_H
     4
     5#include <R2/R2Fonts.h>
    46
    57#include "Texture2D.h"
     
    79#include "NvColorTableShader.h"
    810
    9 #include <R2/R2Fonts.h>
    10 
    11 class NvColorTableRenderer {
    12     NvColorTableShader* _shader;
    13     R2Fonts* _fonts;
     11class NvColorTableRenderer
     12{
    1413public :
    1514    NvColorTableRenderer();
    1615    ~NvColorTableRenderer();
    1716
    18 public :
    19     void render(int width, int height, Texture2D* texture, TransferFunction* tf, double rangeMin, double rageMax);
    20     void setFonts(R2Fonts* fonts);
     17    void render(int width, int height,
     18                Texture2D *texture, TransferFunction *tf,
     19                double rangeMin, double rageMax);
     20
     21    void setFonts(R2Fonts *fonts)
     22    {
     23        _fonts = fonts;
     24    }
     25
     26private:
     27    NvColorTableShader* _shader;
     28    R2Fonts* _fonts;
    2129};
    2230
    23 inline void NvColorTableRenderer::setFonts(R2Fonts* fonts)
    24 {
    25     _fonts = fonts;
    26 }
    27 
    2831#endif
    29 
  • trunk/packages/vizservers/nanovis/NvColorTableShader.cpp

    r2831 r2836  
    1818{
    1919    _cgFP = LoadCgSourceProgram(g_context, "one_plane.cg", CG_PROFILE_FP30,
    20         "main");
     20                                "main");
    2121    _dataParam = cgGetNamedParameter(_cgFP, "data");
    2222    _tfParam = cgGetNamedParameter(_cgFP, "tf");
    2323    _renderParam = cgGetNamedParameter(_cgFP, "render_param");
    2424}
    25 
    26 
    27 
  • trunk/packages/vizservers/nanovis/NvColorTableShader.h

    r2798 r2836  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef __NV_COLORTABLE_SHADER_H__
    3 #define __NV_COLORTABLE_SHADER_H__
     2#ifndef NV_COLORTABLE_SHADER_H
     3#define NV_COLORTABLE_SHADER_H
     4
     5#include <Cg/cg.h>
    46
    57#include "Texture2D.h"
     
    79#include "NvShader.h"
    810
    9 class NvColorTableShader : public NvShader {
     11class NvColorTableShader : public NvShader
     12{
     13public:
     14    NvColorTableShader();
     15
     16    ~NvColorTableShader();
     17
     18    void bind(Texture2D *plane, TransferFunction *tf);
     19
     20    void unbind();
     21
     22private :
     23    void init();
     24
    1025    CGparameter _dataParam;
    1126    CGparameter _tfParam;
    1227    CGparameter _renderParam;
    13 
    14 public :
    15     NvColorTableShader();
    16     ~NvColorTableShader();
    17 
    18 private :
    19     void init();
    20 public :
    21     void bind(Texture2D* plane, TransferFunction* tf);
    22     void unbind();
    2328};
    2429
    25 inline void NvColorTableShader::bind(Texture2D* plane, TransferFunction* tf)
     30inline void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf)
    2631{
    2732    cgGLSetTextureParameter(_dataParam, plane->id);
  • trunk/packages/vizservers/nanovis/NvEventLog.cpp

    r2798 r2836  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include "config.h"
    32#include <stdio.h>
    43#include <assert.h>
     
    98#include <stdlib.h>
    109#include <string.h>
     10
     11#include "config.h"
     12#include "nanovis.h"
    1113#include "NvEventLog.h"
    12 #include "nanovis.h"
    1314
    14 
    15 FILE* event_log;
    16 double cur_time;        //in seconds
     15static FILE *event_log;
     16static double cur_time; //in seconds
    1717
    1818#ifdef XINETD
     
    2525    if (user == NULL) {
    2626        logNameLen = 20+1;
    27         logName = (char*) calloc(logNameLen,sizeof(char));
    28         strncpy(logName,"/tmp/nanovis_log.txt",logNameLen);
     27        logName = (char *)calloc(logNameLen, sizeof(char));
     28        strncpy(logName, "/tmp/nanovis_log.txt", logNameLen);
    2929    } else {
    3030        logNameLen = 17+1+strlen(user);
    31         logName = (char*) calloc(logNameLen,sizeof(char));
    32         strncpy(logName,"/tmp/nanovis_log_",logNameLen);
     31        logName = (char *)calloc(logNameLen, sizeof(char));
     32        strncpy(logName, "/tmp/nanovis_log_", logNameLen);
    3333        strncat(logName, user, strlen(user));
    3434    }
     
    5858{
    5959    event_log = fopen("event.txt", "w");
    60     assert(event_log!=0);
     60    assert(event_log != NULL);
    6161
    6262    struct timeval time;
  • trunk/packages/vizservers/nanovis/NvEventLog.h

    r2798 r2836  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef __NV_EVENT_LOG_H__
    3 #define __NV_EVENT_LOG_H__
     2#ifndef NV_EVENT_LOG_H
     3#define NV_EVENT_LOG_H
    44
    55extern void NvInitEventLog();
     
    88extern void NvExitService();
    99
    10 #endif //
     10#endif
  • trunk/packages/vizservers/nanovis/NvFlowVisRenderer.cpp

    r2835 r2836  
    2828#define NV_32
    2929
    30 NvFlowVisRenderer::NvFlowVisRenderer(int w, int h, CGcontext context) :
     30NvFlowVisRenderer::NvFlowVisRenderer(int w, int h) :
    3131    _activated(true)
    3232{
    3333    _psys_width = w;
    3434    _psys_height = h;
    35 
    36 //     licRenderer[0] = new NvLIC(NMESH, NPIX, NPIX, 0,
    37 //                                Vector3(0, 0, 0), g_context);
    38 //     licRenderer[1] = new NvLIC(NMESH, NPIX, NPIX, 1,
    39 //                                Vector3(0, 0, 0), g_context);
    40 //     licRenderer[2] = new NvLIC(NMESH, NPIX, NPIX, 2,
    41 //                                Vector3(0, 0, 0), g_context);
    4235}
    4336
     
    4841        delete (*iter).second;
    4942    }
    50 
    51     /*
    52       for (int i = 0; i < 3; ++i) {
    53           delete licRenderer[i];
    54       }
    55     */
    5643}
    5744
  • trunk/packages/vizservers/nanovis/NvFlowVisRenderer.h

    r2833 r2836  
    2222class NvParticleRenderer;
    2323
    24 class NvFlowVisRenderer {
     24class NvFlowVisRenderer
     25{
    2526public:
    26     NvFlowVisRenderer(int w, int h, CGcontext context);
     27    NvFlowVisRenderer(int w, int h);
    2728
    2829    ~NvFlowVisRenderer();
     
    9899    int _psys_width;
    99100    int _psys_height;
    100     CGcontext context;
    101101
    102102    std::map<std::string, NvVectorField *> _vectorFieldMap;
  • trunk/packages/vizservers/nanovis/config.h

    r2831 r2836  
    3333#define PROTOTYPE               0
    3434
    35 #define NEW_FLOW_ENGINE         1
    36 
    3735//#define USE_POINTSET_RENDERER
    3836
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2835 r2836  
    130130NvColorTableRenderer *NanoVis::color_table_renderer = NULL;
    131131
    132 #ifndef NEW_FLOW_ENGINE
    133 NvParticleRenderer *NanoVis::flowVisRenderer = NULL;
    134 #else
    135132NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL;
    136 #endif
    137133VelocityArrowsSlice *NanoVis::velocityArrowsSlice = NULL;
    138134
     
    211207const float def_eye_y = -0.0f;
    212208const float def_eye_z = -2.5f;
    213 
    214209
    215210#ifndef XINETD
     
    755750    color_table_renderer = new NvColorTableRenderer();
    756751    color_table_renderer->setFonts(fonts);
    757 #ifndef NEW_FLOW_ENGINE
    758     flowVisRenderer = new NvParticleRenderer(NMESH, NMESH, g_context);
    759 #else
    760     flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH, g_context);
    761 #endif
     752    flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH);
    762753
    763754    NanoVis::velocityArrowsSlice = new VelocityArrowsSlice;
     
    17331724}
    17341725
    1735 #ifdef NEW_FLOW_ENGINE
    17361726void addVectorField(const char* filename, const char* vf_name,
    17371727                    const char* plane_name1, const char* plane_name2,
     
    17941784    //NanoVis::initParticle();
    17951785}
    1796 #endif
    17971786
    17981787void
     
    18111800#endif
    18121801
    1813 #ifdef NEW_FLOW_ENGINE
    18141802    switch (key) {
    18151803    case 'a' :
     
    19971985        break;
    19981986    }
    1999 #endif
    20001987}
    20011988
  • trunk/packages/vizservers/nanovis/nanovis.h

    r2835 r2836  
    108108
    109109    static VolumeRenderer *vol_renderer;
    110 #ifndef NEW_FLOW_ENGINE
    111     static NvParticleRenderer *flowVisRenderer;
    112 #else
    113110    static NvFlowVisRenderer *flowVisRenderer;
    114 #endif
    115111    static VelocityArrowsSlice *velocityArrowsSlice;
    116112    static NvLIC *licRenderer;
Note: See TracChangeset for help on using the changeset viewer.