summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmvectorlistedit.h
blob: 8064b778caa90a74e7872f29f862407670d2e35b (plain)
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2002 by Andreas Zehender
    email                : zehender@kde.org
**************************************************************************

**************************************************************************
*                                                                        *
*  This program is free software; you can redistribute it and/or modify  *
*  it under the terms of the GNU General Public License as published by  *
*  the Free Software Foundation; either version 2 of the License, or     *
*  (at your option) any later version.                                   *
*                                                                        *
**************************************************************************/

#ifndef PMVECTORLISTEDIT_H
#define PMVECTORLISTEDIT_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqtable.h>
#include <tqvaluelist.h>
#include <tqmemarray.h>

#include "pmvector.h"

/*
const int c_pmTableRTTI = 14352;

class PMTableItem : public TQTableItem
{
public:
   PMTableItem( TQTable* table );

   virtual void paint( TQPainter* p, const TQColorGroup& cg,
                       const TQRect& cr, bool selected );

   int rtti( ) const { return c_pmTableRTTI; }

   void setReadOnly( bool r ) { m_readOnly = r; }
   bool isReadOnly( ) const { return m_readOnly; }

private:
   bool m_readOnly;
};
*/


/**
 * Widget that displays a list of vectors, based on @ref TQTable.
 */
class PMVectorListEdit : public TQTable
{
   TQ_OBJECT
  
public:
   /**
    * Constructor for 3d vectors (x, y, z)
    */
   PMVectorListEdit( TQWidget* parent, const char* name = 0 );
   /**
    * Constructor for 3d vectors
    */
   PMVectorListEdit( const TQString& c1, const TQString& c2, const TQString& c3,
                    TQWidget* parent, const char* name = 0 );
   /**
    * Constructor for 2d vectors
    */
   PMVectorListEdit( const TQString& c1, const TQString& c2,
                    TQWidget* parent, const char* name = 0 );

   /**
    * Constructor for 4d vectors
    */
   PMVectorListEdit( const TQString& c1, const TQString& c2, const TQString& c3,
                     const TQString& c4, TQWidget* parent, const char* name = 0 );
   /**
    * Sets and displays the vectors. The widget will automatically
    * resize if no link is set and resize is true.
    */
   void setVectors( const TQValueList<PMVector>& v, bool resize = false,
                    int precision = 5 );
   /**
    * Returns the vectors
    */
   TQValueList<PMVector> vectors( ) const;
   /**
    * Sets the i-th vector
    */
   void setVector( int i, const PMVector& v, int precision = 5 );
   /**
    * Returns the i-th vector
    */
   PMVector vector( int i ) const;
   /**
    * Sets the number of vectors
    */
   void setSize( int s );
   /**
    * Returns the number of vectors
    */
   int size( ) const { return m_size; }

   /**
    * Adds a linked point. The point p2 will be disabled and synchronized
    * with p1.
    *
    * Call this method before displaying vectors and remove the point
    * p2 from the vector list before you call @ref setVectors( ).
    * The list returned by @ref vectors( ) will not return this point.
    *
    * Set p2 to -1 to remove a link.
    */
   void setLink( int p1, int p2 );
   /**
    * Removes all links. The widget is not updated. You have to resize
    * the widget and redisplay the points.
    */
   void clearLinks( );

   /**
    * Returns the selection status of vector i
    */
   bool isSelected( int i ) const;
   /**
    * Selects vector i
    */
   void select( int i );
   /**
    * Selects vector i to j
    */
   void select( int i, int j );
   /**
    * Blocks/unblocks selection updates. If block is false, the
    * selection is repainted.
    */
   void blockSelectionUpdates( bool block );

   /**
    * Returns true if the edited data is valid.
    */
   bool isDataValid( );

   /** */
   virtual TQSize sizeHint( ) const;
   /** */
   bool eventFilter( TQObject* o, TQEvent* e );

protected slots:
   void slotTextChanged( int, int );

signals:
   /**
    * Emitted when the used edits a field
    */
   void dataChanged( );
   /**
    * Emitted after a right mouse button click
    */
   void showContextMenu( );
private:
   void init( int dimensions );

   int m_dimension, m_size;
   TQMemArray<int> m_links;
   TQMemArray<bool> m_disabled;
};


#endif