|
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;
|
}
|