Normand Briere
2019-09-10 a7e7618fb914f8b919a17daf6c020b860c5d11c9
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
 
import grafeme.ui.*;
 
class MocapEditor extends ObjEditor implements //ItemListener,
        ChangeListener, ObjectUI, ActionListener
{
        cGridBag firstPanel;
        cGridBag framePanel;
        cGridBag lastPanel;
    MocapEditor(Mocap inBP, GroupEditor callee)
    {
        super(inBP,callee);
        
        objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
 
        mocap = (Mocap) inBP;
   //    parent = p;
       
   //SetupUI2(callee.objEditor);
   SetupUI2(objEditor);
    }
   
   // TEMP
   MocapEditor(Mocap inClient, Object3D localCopy, GroupEditor callee)
   {
       this(inClient, localCopy, null, callee);
   }
   
    MocapEditor(Mocap inBP, ObjectUI p, GroupEditor callee)
    {
        super(inBP,callee);
        
        objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
 
        mocap = (Mocap) inBP;
       parent = p;
       
   SetupUI2(callee.objEditor);
    }
   
    MocapEditor(Mocap inBP, Object3D copy, ObjectUI p, GroupEditor callee) // boolean ends)
    {
        //super(inBP, copy, callee);
        super(inBP, copy, p, callee);
        objEditor = this;
        
        //objEditor = new ObjEditor(inBP, copy, this, callee);
       // ?? super.parent = p;
        mocap = (Mocap) copy;
       parent = p;
       
       //objEditor.SetupUI(false); // ?
       //objEditor.SetupViews(); // ?
       SetupUI2(objEditor);
   }
   
    String GetSupportText()
    {
        return "Hip pos";
    }
    
   void SetupUI2(ObjEditor oe)
   {
            /*
       oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
       oe.aConstraints.gridx = 0;
       oe.aConstraints.weighty = 0;
       oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH+1;
       oe.ctrlPanel.add(nameField = new JTextField(biparam.name), oe.aConstraints);
                nameField.addActionListener(this);
       oe.aConstraints.gridy += 1;
       oe.aConstraints.gridwidth = 1;
             */
            super.SetupUI2(oe);
                framePanel = AddSlider(oe.ctrlPanel, "Frame:", 0, mocap.bvh.animation.getNumFrames()-1, mocap.frame);
                
            frameField = (cNumberSlider)framePanel.getComponent(1);
        oe.ctrlPanel.Return();
                firstPanel = AddSlider(oe.ctrlPanel, "First:", 0, mocap.bvh.animation.getNumFrames()-1, mocap.firstframe);
            firstField = (cNumberSlider)firstPanel.getComponent(1);
        oe.ctrlPanel.Return();
                lastPanel = AddSlider(oe.ctrlPanel, "Last:", 0, mocap.bvh.animation.getNumFrames()-1, mocap.lastframe);
            lastField = (cNumberSlider)lastPanel.getComponent(1);
        oe.ctrlPanel.Return();
            
//        oe.aConstraints.gridx = 0;
//        oe.aConstraints.gridwidth = 1;
//        oe.aConstraints.fill = GridBagConstraints.VERTICAL;
//        oe.ctrlPanel.add(frameLabel = new JLabel("Frame: "), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
//        oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
//        oe.aConstraints.gridx += 1;
//        oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
//        oe.ctrlPanel.add(frameField = new NumberSlider(0, mocap.bvh.animation.getNumFrames()-1), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
//        
//        frameField.setInteger(mocap.frame);
//        oe.aConstraints.gridy += 1;
//        
////        oe.aConstraints.gridx = 0;
////        oe.aConstraints.gridwidth = 1;
////        oe.aConstraints.fill = GridBagConstraints.VERTICAL;
////        oe.ctrlPanel.add(speedLabel = new JLabel("Damp: "), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
////        oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
////        oe.aConstraints.gridx += 1;
////        oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
////        oe.ctrlPanel.add(speedField = new NumberSlider(0, 500), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
////        
////        speedField.setInteger(frameselect.speed);
//        
//        oe.aConstraints.gridy += 1;
//        oe.aConstraints.gridwidth = 1;
//        oe.aConstraints.fill = 0;
//        oe.aConstraints.gridx -= 1;
//        oe.aConstraints.fill = GridBagConstraints.VERTICAL;
//        oe.aConstraints.gridy += 1;
//        oe.aConstraints.gridx = 0;
//        frameField.addChangeListener(this);
//        //speedField.addChangeListener(this);
    }
   
   void Clear()
   {
       objEditor.Clear();
 
       mocap = null;
   }
   
   
//    public void itemStateChanged(ItemEvent e)
//    {
//        if (//e.getSource() == nameField ||
//                e.getSource() == endcaps)
//        {
//                    //System.out.println(e);
//            frameselect.endcaps = (e.getStateChange() == ItemEvent.SELECTED);
//                    //Refresh();
//                    frameselect.retile();
//                    applySelf();
//                    //super.applySelf();
//                    objEditor.refreshContents();
//                }
//                else
//                {
//                    super.itemStateChanged(e);
//                }
//    }
   
//    public void actionPerformed(ActionEvent e)
//    {
//        if (//e.getSource() == nameField ||
//                e.getSource() == endcaps)
//        {
//            //System.out.println(e);
//            applySelf();
//            //super.applySelf();
//            refreshContents();
//            //Refresh();
//        }
//        else
//        {
//            super.actionPerformed(e);
//                }
//    }
   
   public void stateChanged(ChangeEvent e)
   {
       //System.out.println("Biparam :: stateChanged");
       if (e.getSource() == frameField || e.getSource() == firstField || e.getSource() == lastField) // || e.getSource() == offsetField)
       {
       //System.out.println("#U = " + biparam.uDivs);
       //System.out.println("#V = " + biparam.vDivs);
       //new Exception().printStackTrace();
           //System.out.println(e);
           applySelf();
           //super.applySelf();
           objEditor.refreshContents();
           //Refresh();
       }
       else
           super.stateChanged(e);
   }
   
   void Refresh()
   {
            assert(false);
//        System.out.println("Biparam :: Refresh");
        mocap.frame = frameField.getInteger(); // biparam.minUDivs, 99);
        mocap.firstframe = firstField.getInteger(); // biparam.minUDivs, 99);
        mocap.lastframe = lastField.getInteger(); // biparam.minUDivs, 99);
       new Exception().printStackTrace();
       refreshContents();
   }
   
   /*
    public void doLayout()
    {
        super.doLayout();
        labelAndField(uDivsLabel, uDivsField);
        labelAndField(vDivsLabel, vDivsField);
        if (endcaps != null)
        {
            int h = endcaps.getPreferredSize().height;
            int w = endcaps.getPreferredSize().width;
            endcaps.setBounds(5, widgetPos, w, h);
            widgetPos += h;
        }
        widgetPos += 5;
    }
    */
    
    /**/
    public void applySelf()
    {
       //System.out.println("Biparam :: applySelf");
        //super.applySelf();
        mocap.baseframe = frameField.getInteger(); // biparam.minUDivs, 99);
        
        int frame = mocap.firstframe;
        mocap.firstframe = firstField.getInteger(); // biparam.minUDivs, 99);
        if (mocap.firstframe != frame)
            mocap.baseframe = frame;
        
        frame = mocap.lastframe;
        mocap.lastframe = lastField.getInteger(); // biparam.minUDivs, 99);
        if (mocap.lastframe != frame)
            mocap.baseframe = frame;
        
        if (mocap.firstframe + mocap.lastframe > 0)
            System.out.println("First: " + mocap.firstframe + ", last: " + mocap.lastframe);
   //     frameselect.speed = speedField.getInteger(); // biparam.minUDivs, 99);
        //biparam.name = nameField.getText();
        if (!mocap.random)
        {
            mocap.frame = mocap.baseframe;
        
            // nov 2013
            boolean keeplive = mocap.live;
            mocap.live = true;
            mocap.setPose(mocap.frame);
            mocap.live = keeplive;
        }
        
// june 2013        super.applySelf();
    }
    /**/
    
   public void closeUI()
   {
       ObjEditor oe = objEditor;
   
//                Remove(frameField);
//                Remove(firstField);
//                Remove(lastField);
   //    frameField.removeChangeListener(this);
   //    oe.ctrlPanel.remove(frameField);
   //    oe.ctrlPanel.remove(frameLabel);
   //    oe.ctrlPanel.remove(speedField);
   //    oe.ctrlPanel.remove(speedLabel);
       //oe.ctrlPanel.repaint();
       oe.ctrlPanel.remove(framePanel);
       oe.ctrlPanel.remove(firstPanel);
       oe.ctrlPanel.remove(lastPanel);
                
                super.closeUI();
   }
   
   public ObjEditor GetEditor()
   {
       return objEditor;
   }
 
   void refreshContents2()
   {
       objEditor.refreshContents();
   }
   
    Mocap mocap;
    //JLabel frameLabel;
    cNumberSlider frameField;
    cNumberSlider firstField;
    cNumberSlider lastField;
    //JLabel speedLabel;
    //NumberSlider offsetField;
 
   ObjectUI parent;
   
   //ObjEditor objEditor;
}