public class Main extends java.lang.Object implements DriverInterface, ComponentChangeListener
Modifier and Type | Class and Description |
---|---|
static class |
Main.LookAndFeel |
static class |
Main.ManipulatorFrameSpec
Describes different ways to determine the frame for a manipulator.
|
static class |
Main.SelectionMode |
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ALIGN_DRAGGERS_TO_POINTS |
static boolean |
DEFAULT_ARTICULATED_TRANSFORMS |
static double |
DEFAULT_FRAME_RATE |
static boolean |
DEFAULT_INIT_DRAGGERS_IN_WORLD |
static boolean |
DEFAULT_JYTHON_FRAME_VISIBLE |
static GuiUtils.RelativeLocation |
DEFAULT_JYTHON_LOCATION |
static Logger.LogLevel |
DEFAULT_LOG_LEVEL |
static int |
DEFAULT_SCREEN_LOC_X |
static int |
DEFAULT_SCREEN_LOC_Y |
static int |
DEFAULT_TIMELINE_HEIGHT |
static GuiUtils.RelativeLocation |
DEFAULT_TIMELINE_LOCATION |
static double |
DEFAULT_TIMELINE_RANGE |
static boolean |
DEFAULT_TIMELINE_VISIBLE |
static int |
DEFAULT_TIMELINE_WIDTH |
static int |
DEFAULT_VIEWER_HEIGHT |
static int |
DEFAULT_VIEWER_WIDTH |
static boolean |
myUseConfigDir |
static boolean |
myUseRootModelManager |
Constructor and Description |
---|
Main() |
Main(java.lang.String windowName,
boolean createGui)
Creates a new Main instance
|
Modifier and Type | Method and Description |
---|---|
WayPoint |
addBreakPoint(double t) |
void |
addSelected(java.util.LinkedList<ModelComponent> items) |
void |
addSelectionListener(SelectionListener l)
add the selection listener
|
WayPoint |
addWayPoint(double t) |
void |
arrangeControlPanels(RootModel root) |
void |
clearDraggerFrameInfo() |
void |
clearErrorMessage() |
void |
clearRootModel() |
void |
clearWayPoints() |
boolean |
closeMatlabConnection() |
void |
componentChanged(ComponentChangeEvent e) |
void |
createPreferencesManager() |
GLViewerFrame |
createViewerFrame() |
void |
createWorkspace() |
void |
delay(double sec) |
void |
deregisterWindow(PropertyWindow w) |
void |
dispose() |
static void |
exit(int code)
Have our own exit method so that if we're running under matlab, we don't
actually exit.
|
void |
flipDraggerAxesForward() |
boolean |
forward() |
boolean |
getAlignDraggersToPoints() |
java.util.ArrayList<MouseBindings> |
getAllMouseBindings() |
boolean |
getArticulatedTransformsEnabled() |
java.lang.String |
getDemoClassName(java.lang.String classNameOrAlias) |
EditorManager |
getEditorManager()
Get the EditorManager
|
MouseBindings |
getEffectiveMouseBindings() |
java.lang.String |
getErrorMessage() |
javax.swing.JFrame |
getFrame() |
double |
getFrameRate() |
GraphicsInterface |
getGraphics() |
java.lang.String |
getHomeDir() |
boolean |
getInitDraggersInWorldCoords() |
double[][] |
getInputProbeData(java.lang.String nameOrNumber)
Gets the data associated with a numeric input probe and returns it as a
2-dimensional array of doubles.
|
ArtisynthJythonConsole |
getJythonConsole() |
java.lang.String |
getKeyBindings()
get the key bindings from a file
|
Logger |
getLogger()
Returns a logger to be used by this main application.
|
Logger.LogLevel |
getLogLevel() |
Main.LookAndFeel |
getLookAndFeel() |
static Main |
getMain() |
MainFrame |
getMainFrame() |
MatlabInterface |
getMatlabConnection() |
double |
getMaxStep() |
java.io.File |
getModelDirectory() |
java.io.File |
getModelFile() |
java.lang.String |
getModelName()
Returns the current model name.
|
java.lang.String |
getModelSaveFormat() |
ModelScriptHistory |
getModelScriptHistory() |
MouseBindings |
getMouseBindings() |
double |
getMouseWheelZoomScale() |
MovieMaker |
getMovieMaker() |
double[][] |
getOutputProbeData(java.lang.String nameOrNumber)
Gets the data associated with a numeric output probe and returns it as a
2-dimensional array of doubles.
|
PreferencesManager |
getPreferencesManager() |
java.io.File |
getProbeDirectory() |
java.io.File |
getProbesFile()
get the file with probes
|
java.util.LinkedList<PropertyWindow> |
getPropertyWindows()
For diagnostic purposes.
|
PullController |
getPullController() |
boolean |
getRealTimeAdvance()
Queries whether real-time model advancement is enabled.
|
double |
getRealTimeScaling()
Returns the scale factor used to control the visualized simulation
speed in the viewer.
|
RootModel |
getRootModel() |
RootModelManager |
getRootModelManager()
Get the RootModelManager
|
boolean |
getSaveCoreOnly() |
boolean |
getSaveWayPointData() |
Scheduler |
getScheduler()
Get the Scheduler
|
java.io.File |
getScriptFile()
Returns a file handle for any Jythin script file that is currently
executing.
|
SelectionManager |
getSelectionManager() |
Main.SelectionMode |
getSelectionMode() |
java.lang.Exception |
getSimulationException() |
double |
getTime() |
Timeline |
getTimeline()
get the timeline controller
|
UndoManager |
getUndoManager() |
boolean |
getUndoTransformsWithInverse() |
Vector3d |
getVector() |
GLViewer |
getViewer() |
ViewerManager |
getViewerManager() |
java.awt.Dimension |
getViewerSize() |
WayPoint |
getWayPoint(double t) |
java.io.File |
getWayPointsFile()
get the file for the wayPoints, if any
|
Workspace |
getWorkspace()
get the root model, static method for the entire program to reference to,
so do not pass root model around, because its stored in main and could be
accessed using this method
|
boolean |
hasMatlabConnection() |
void |
initializeViewer(GLViewer viewer) |
boolean |
isDisposed() |
static boolean |
isRunningUnderMatlab() |
boolean |
isSimulating() |
boolean |
loadModel(ModelScriptInfo info) |
boolean |
loadModel(ModelScriptInfo info,
boolean saveToHistory) |
boolean |
loadModel(java.lang.String className,
java.lang.String modelName,
java.lang.String[] modelArgs) |
boolean |
loadModelFile(java.io.File file) |
boolean |
loadProbesFile(java.io.File file)
load the probes into the model
|
void |
loadWayPoints(java.io.File file)
Loads waypoints from the specified file.
|
static void |
main(java.lang.String[] args)
the main entry point
|
void |
maskFocusStealing(boolean enable)
Attempts to prevent artisynth form stealing focus when it
pops up windows, etc, especially while running a script.
|
MatlabInterface |
openMatlabConnection() |
void |
pause() |
void |
play() |
void |
play(double time) |
void |
playAndWait(double time) |
void |
printAllThreads() |
void |
printClassPath() |
void |
quit() |
void |
registerWindow(PropertyWindow w)
Register a property window with the main program.
|
void |
reloadModel() |
void |
removeSelected(java.util.LinkedList<ModelComponent> items) |
void |
removeSelectionListener(SelectionListener l)
remove the selection listener
|
boolean |
removeWayPoint(double t) |
boolean |
removeWayPoint(WayPoint way) |
void |
rerender()
rerender all viewers and update all widgets
|
void |
reset() |
void |
resetDraggerFrame(Main.ManipulatorFrameSpec mode) |
void |
rewidgetUpdate()
update all widgets
|
boolean |
rewind() |
int |
saveComponent(java.io.File file,
java.lang.String fmtStr,
ModelComponent comp,
boolean coreCompsOnly,
ModelComponent ancestor)
Saves a component (and its subcomponents, if any) to a file.
|
int |
saveModelFile(java.io.File file) |
int |
saveModelFile(java.io.File file,
java.lang.String fmtStr,
boolean saveWayPointData,
boolean coreCompsOnly)
Saves the current root model to a file.
|
boolean |
saveProbesFile(java.io.File file)
to save the probes file
|
int |
saveRootModel(java.io.File file,
java.lang.String fmtStr,
RootModel root,
boolean saveWayPointData,
boolean coreCompsOnly) |
void |
saveWayPoints(java.io.File file)
Save the waypoints, in binary form, to the specified file.
|
void |
scaleDraggerSize(double s) |
void |
screenShot(java.lang.String filename) |
void |
setAlignDraggersToPoints(boolean enable) |
void |
setArticulatedTransformsEnabled(boolean enable) |
void |
setErrorMessage(java.lang.String msg) |
void |
setFrameRate(double val) |
void |
setInitDraggersInWorldCoords(boolean enable) |
boolean |
setInputProbeData(java.lang.String nameOrNumber,
double[][] data)
Sets the data associated with a numeric input probe.
|
void |
setLogger(Logger logger)
Sets an application-specific logger
|
void |
setLogLevel(Logger.LogLevel level)
Sets the current log level for this application.
|
static void |
setMain(Main main)
For internal use only; be careful!!
|
void |
setMaxStep(double sec) |
void |
setModelDirectory(java.io.File dir) |
void |
setModelSaveFormat(java.lang.String fmtStr) |
void |
setMouseBindings(MouseBindings bindings) |
void |
setMouseBindings(java.lang.String bindingsName)
set the mouse bindings
|
void |
setMouseWheelZoomScale(double scale) |
boolean |
setOutputProbeData(java.lang.String nameOrNumber,
double[][] data)
Sets the data associated with a numeric output probe.
|
void |
setProbeDirectory(java.io.File dir) |
void |
setProbesFile(java.io.File file)
set the file with probes
|
void |
setRealTimeAdvance(boolean enable)
Enables or disables real-time model advancement.
|
void |
setRealTimeScaling(double scaling)
Sets the scale factor used to control the visualized simulation speed in
the viewer, subject to computational constraints.
|
void |
setRootModel(RootModel newRoot,
java.lang.String modelName) |
static void |
setRunningUnderMatlab(boolean underMatlab) |
void |
setSaveCoreOnly(boolean save) |
void |
setSaveWayPointData(boolean save) |
void |
setSelectionMode(Main.SelectionMode selectionMode)
Set the current selection mode.
|
void |
setTimelineVisible(boolean visible)
to set the timeline visible or not
|
void |
setUndoTransformsWithInverse(boolean enable) |
void |
setVector(Vector3d v) |
void |
setViewerSize(int w,
int h) |
void |
start(java.util.ArrayList<java.lang.String> modelArgs) |
void |
step() |
void |
stopAll() |
void |
updateDragger()
Called to update the current dragger position.
|
void |
waitForStart() |
void |
waitForStop() |
public static boolean myUseConfigDir
public static boolean myUseRootModelManager
public static Logger.LogLevel DEFAULT_LOG_LEVEL
public static int DEFAULT_VIEWER_WIDTH
public static int DEFAULT_VIEWER_HEIGHT
public static int DEFAULT_SCREEN_LOC_X
public static int DEFAULT_SCREEN_LOC_Y
public static boolean DEFAULT_TIMELINE_VISIBLE
public static int DEFAULT_TIMELINE_WIDTH
public static int DEFAULT_TIMELINE_HEIGHT
public static double DEFAULT_TIMELINE_RANGE
public static GuiUtils.RelativeLocation DEFAULT_TIMELINE_LOCATION
public static double DEFAULT_FRAME_RATE
public static boolean DEFAULT_JYTHON_FRAME_VISIBLE
public static GuiUtils.RelativeLocation DEFAULT_JYTHON_LOCATION
public static boolean DEFAULT_ARTICULATED_TRANSFORMS
public static boolean DEFAULT_INIT_DRAGGERS_IN_WORLD
public static boolean DEFAULT_ALIGN_DRAGGERS_TO_POINTS
public Main()
public Main(java.lang.String windowName, boolean createGui)
windowName
- name of window framecreateGui
- whether or not to create the GUIpublic Vector3d getVector()
public void setVector(Vector3d v)
public static void setRunningUnderMatlab(boolean underMatlab)
public static boolean isRunningUnderMatlab()
public void setUndoTransformsWithInverse(boolean enable)
public boolean getUndoTransformsWithInverse()
public SelectionManager getSelectionManager()
public java.lang.String getKeyBindings()
public void setErrorMessage(java.lang.String msg)
public void clearErrorMessage()
public java.lang.String getErrorMessage()
public GLViewer getViewer()
getViewer
in interface DriverInterface
public MainFrame getMainFrame()
public javax.swing.JFrame getFrame()
getFrame
in interface DriverInterface
public PreferencesManager getPreferencesManager()
public void createPreferencesManager()
public java.lang.String getDemoClassName(java.lang.String classNameOrAlias)
public GraphicsInterface getGraphics()
public Main.LookAndFeel getLookAndFeel()
public java.lang.String getModelName()
public ModelScriptHistory getModelScriptHistory()
public void setViewerSize(int w, int h)
public java.awt.Dimension getViewerSize()
public Logger getLogger()
public void setLogger(Logger logger)
logger
- logger to use in this main applicationpublic Logger.LogLevel getLogLevel()
public void setLogLevel(Logger.LogLevel level)
setLogger(Logger)
, then the system logger is
cloned and assigned in order to set the log level.level
- log levelpublic void setTimelineVisible(boolean visible)
visible
- -
boolean set the timeline visiblepublic double getRealTimeScaling()
setRealTimeScaling
.public void setRealTimeScaling(double scaling)
>
1 will speed up the simulation, while values
<
1 will slow it down. A value <=
0 will cause the
simulation to be displayed as fast as possible.public boolean getRealTimeAdvance()
true
if real-time model advancement is enabledsetRealTimeAdvance(boolean)
public void setRealTimeAdvance(boolean enable)
enable
- if true
, enables real-time model advancementpublic void setFrameRate(double val)
public double getFrameRate()
public GLViewerFrame createViewerFrame()
public void initializeViewer(GLViewer viewer)
public ArtisynthJythonConsole getJythonConsole()
public java.io.File getScriptFile()
public boolean isSimulating()
public void reset()
public boolean rewind()
public void play()
public void play(double time)
public void playAndWait(double time)
public void pause()
public void waitForStop()
public void waitForStart()
public java.lang.Exception getSimulationException()
public void step()
public void stopAll()
public boolean forward()
public double getTime()
public WayPoint addWayPoint(double t)
public WayPoint addBreakPoint(double t)
public WayPoint getWayPoint(double t)
public void setMaxStep(double sec)
public double getMaxStep()
public boolean removeWayPoint(WayPoint way)
public boolean removeWayPoint(double t)
public void clearWayPoints()
public void delay(double sec)
public void start(java.util.ArrayList<java.lang.String> modelArgs)
public RootModel getRootModel()
public void clearRootModel()
public double[][] getInputProbeData(java.lang.String nameOrNumber)
This is primarily intended as a convenience method for extracting probe data into other applications (such as Matlab).
nameOrNumber
- name or number of the probe in questionnull
if the probe is not
foundpublic boolean setInputProbeData(java.lang.String nameOrNumber, double[][] data)
This is primarily intended as a convenience method for setting probe data from other applications (such as Matlab).
nameOrNumber
- name or number of the probe in questiondata
- new data to set inside the probefalse
if the probe is not foundpublic double[][] getOutputProbeData(java.lang.String nameOrNumber)
This is primarily intended as a convenience method for extracting probe data into other applications (such as Matlab).
nameOrNumber
- name or number of the probe in questionnull
if the probe is not
foundpublic boolean setOutputProbeData(java.lang.String nameOrNumber, double[][] data)
This is primarily intended as a convenience method for setting probe data from other applications (such as Matlab).
nameOrNumber
- name or number of the probe in questiondata
- new data to set inside the probefalse
if the probe is not foundpublic void setRootModel(RootModel newRoot, java.lang.String modelName)
public boolean loadModelFile(java.io.File file)
public boolean loadModel(java.lang.String className, java.lang.String modelName, java.lang.String[] modelArgs)
public boolean loadModel(ModelScriptInfo info)
public boolean loadModel(ModelScriptInfo info, boolean saveToHistory)
public ViewerManager getViewerManager()
getViewerManager
in interface DriverInterface
public java.util.ArrayList<MouseBindings> getAllMouseBindings()
public void setMouseBindings(java.lang.String bindingsName)
bindingsName
- name of the preferred mouse bindingspublic void setMouseBindings(MouseBindings bindings)
public MouseBindings getMouseBindings()
public MouseBindings getEffectiveMouseBindings()
public double getMouseWheelZoomScale()
public void setMouseWheelZoomScale(double scale)
public void rerender()
public void rewidgetUpdate()
public static void main(java.lang.String[] args)
args
- command line argumentspublic Workspace getWorkspace()
public void createWorkspace()
public static Main getMain()
public static void setMain(Main main)
public Scheduler getScheduler()
public EditorManager getEditorManager()
public RootModelManager getRootModelManager()
public UndoManager getUndoManager()
public Timeline getTimeline()
public java.io.File getModelFile()
public boolean getSaveWayPointData()
public void setSaveWayPointData(boolean save)
public boolean getSaveCoreOnly()
public void setSaveCoreOnly(boolean save)
public void reloadModel() throws java.io.IOException
java.io.IOException
public java.lang.String getModelSaveFormat()
public void setModelSaveFormat(java.lang.String fmtStr)
public int saveModelFile(java.io.File file) throws java.io.IOException
java.io.IOException
public int saveModelFile(java.io.File file, java.lang.String fmtStr, boolean saveWayPointData, boolean coreCompsOnly) throws java.io.IOException
saveWayPointData
is
true
, then waypoint data is saved as well (otherwise, waypoints
are still saved but without their data). If coreCompsOnly
is true
, then only components which are part
of artisynth_core
are saved (with the root model itself being
saved simply as an instance of RootModel
). Such models can then
be loaded by any ArtiSynth installation, without requiring access to the
original application code.file
- file to which the model should be savedfmtStr
- format for floating point data. If null
,
then the default format returned by getModelSaveFormat()
is
used instead.saveWayPointData
- save waypoint data along with any waypointscoreCompsOnly
- save only components which are part of
artisynth_core
coreCompsOnly
is true
, returns the
number of components which were not saved; otherwise, returns 0.java.io.IOException
- if an I/O error is encounteredpublic int saveRootModel(java.io.File file, java.lang.String fmtStr, RootModel root, boolean saveWayPointData, boolean coreCompsOnly) throws java.io.IOException
java.io.IOException
public int saveComponent(java.io.File file, java.lang.String fmtStr, ModelComponent comp, boolean coreCompsOnly, ModelComponent ancestor) throws java.io.IOException
If coreCompsOnly
is true
, then only subcomponents
which are part of artisynth_core
are saved. The resulting file
can then be loaded by any ArtiSynth installation, without requiring
access to the original application code. If coreCompsOnly
is
true
and the comp
itself is not part of artisynth_core
, then no action is taken and the method returns -1.
file
- file to which the component should be savedfmtStr
- format for floating point data.If null
,
then the default format returned by getModelSaveFormat()
is
used instead.comp
- component to savecoreCompsOnly
- save only subcomponents which are part of artisynth_core
coreCompsOnly
is true
, returns
the number of subcomponents which were not saved, or -1 if
comp
itself was not saved; otherwise, returns 0.java.io.IOException
- if an I/O error is encounteredpublic java.io.File getProbesFile()
public void setProbesFile(java.io.File file)
file
- with probe datapublic boolean loadProbesFile(java.io.File file) throws java.io.IOException
file
- file containing probe informationjava.io.IOException
- if an I/O or syntax error occurredpublic boolean saveProbesFile(java.io.File file) throws java.io.IOException
file
- probe information filejava.io.IOException
- if an I/O error occurredpublic java.io.File getWayPointsFile()
public void saveWayPoints(java.io.File file) throws java.io.IOException
file
- file to which waypoints should be savedjava.io.IOException
public void loadWayPoints(java.io.File file) throws java.io.IOException
clearWayPoints()
first.file
- file from which additional waypoints should be loadedjava.io.IOException
public void dispose()
public boolean isDisposed()
public void quit()
public void addSelectionListener(SelectionListener l)
addSelectionListener
in interface DriverInterface
public void removeSelectionListener(SelectionListener l)
removeSelectionListener
in interface DriverInterface
public void addSelected(java.util.LinkedList<ModelComponent> items)
public void removeSelected(java.util.LinkedList<ModelComponent> items)
public void componentChanged(ComponentChangeEvent e)
componentChanged
in interface ComponentChangeListener
public boolean getInitDraggersInWorldCoords()
public void setInitDraggersInWorldCoords(boolean enable)
public boolean getAlignDraggersToPoints()
public void setAlignDraggersToPoints(boolean enable)
public boolean getArticulatedTransformsEnabled()
public void setArticulatedTransformsEnabled(boolean enable)
public Main.SelectionMode getSelectionMode()
public PullController getPullController()
public void setSelectionMode(Main.SelectionMode selectionMode)
selectionMode
- selection modepublic void updateDragger()
public void resetDraggerFrame(Main.ManipulatorFrameSpec mode)
public void clearDraggerFrameInfo()
public void scaleDraggerSize(double s)
public void flipDraggerAxesForward()
public void registerWindow(PropertyWindow w)
If the window is a render props dialog, handlers will be added to ensure that viewer selection coloring is disabled while the dialog is open.
registerWindow
in interface DriverInterface
public void deregisterWindow(PropertyWindow w)
deregisterWindow
in interface DriverInterface
public java.util.LinkedList<PropertyWindow> getPropertyWindows()
public MovieMaker getMovieMaker()
public void setModelDirectory(java.io.File dir)
public java.io.File getModelDirectory()
public void setProbeDirectory(java.io.File dir)
public java.io.File getProbeDirectory()
public void arrangeControlPanels(RootModel root)
public void screenShot(java.lang.String filename)
public void maskFocusStealing(boolean enable)
public static void exit(int code)
public boolean closeMatlabConnection()
public MatlabInterface openMatlabConnection()
public MatlabInterface getMatlabConnection()
public boolean hasMatlabConnection()
public void printAllThreads()
public void printClassPath()
public java.lang.String getHomeDir()