Updated with the new logarithmplotter internal resolution of objects.

Ad5001 2021-08-14 17:06:43 +00:00
parent 269eb9acf7
commit 5a20346cfe

@ -5,11 +5,42 @@ In LogarithmPlotter, mathematical expressions are handled by the Expression clas
Below "plot" coordinates are the one based on the plot, so (0,0) is at the center of the axis.
On the other hand, "canvas" coordinate are the coordinate on the canvas, so (0,0) is at the top-left of the canvas.
To create an object, open the file at `LogarithmPlotter/qml/js/objects.js`.
To create an object, create a new file javascript files in `LogarithmPlotter/qml/js/objs/` with a base like this:
```js
/**
* LogarithmPlotter - Create graphs with logarithm scales.
* Copyright (C) 2021 Ad5001
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
.pragma library
.import "common.js" as Common
.import "../mathlib.js" as MathLib
.import "../parameters.js" as P
```
You can also import other libraries like this:
- `.import "../utils.js" as Utils` for string manipulation.
- `.import "../objects.js" as Objects` to interact with other objects.
- `.import "../historylib.js" as HistoryLib` to create and manipulate history entries.
There exists two kinds of objects:
- Drawable (extending the DrawableObject class, the most primitive kind of object)
- Drawable (extending the `Common.DrawableObject` class, the most primitive kind of object)
- Examples: Point, Text, XCursor
- Executable (extending the ExecutableObject class, like Drawable, but allows the constant computation of an y coordinate for an x one)
- Executable (extending the `Common.ExecutableObject` class, like Drawable, but allows the constant computation of an y coordinate for an x one)
- Examples: Function, Gain Bode, Phase Bode, Sequence, Repartition Function
Executable objects can be targeted by XCursors to calculate their value at a given x coordinate.
@ -47,7 +78,7 @@ So to create a new object, choose one of the two to extend, and then create a cl
```js
if(typeof om_0 == "string") {
// Point name or create one
om_0 = getObjectByName(om_0, 'Point')
om_0 = Objects.getObjectByName(om_0, 'Point')
if(om_0 == null) {
// Create new point
om_0 = createNewRegisteredObject('Point')
@ -123,10 +154,9 @@ So to create a new object, choose one of the two to extend, and then create a cl
### Registering your object
Add your object type to the `types` dictionary at the bottom of the file.
- E.g: `'Point': Point`
- Upon saving and restoring a save, objects are saved/restored in the same order as the list.
- So to avoid dependance issues, when you add your object type to list, make sure it's below the ones required for it's construction.
1. Open the `autoload.js` file.
2. Add the import for your object like ```.import "yourobject.js" as YO`
3. Call the common method `C.registerObject` on your object like `C.registerObject(YO.YourObject)`
And that's it!