Introduced very basic c++ coding style for the class Schematic and it's
parent-class QucsDoc based on https://google.github.io/styleguide/cppguide.html:
-Prefix class attributes with a_ (much more better readability!)
-Class member initialization via constructor member initialization list
-No public class attributes (where possible with small effort)
Signed-off-by: ThomasZecha <zecha@ihp-microelectronics.com>
The function is called only in one place, and the variable which
receives its return value is later reassigned new value without
being used, i.e. function return value is discarded. All this
renders Schematic::textCorr useless.
- Remove dependency on Q3PtrList (most important)
- Hide implementation details (in particular make private
container used to actually store connected elements)
- New class API
- Formatting and code structuring
'drawn' is some obscure flag which is scattered all around
the codebase, it's mostly set to 'false' and only occasionally
to 'true'. It controls blocks of code which are described as
"erase old symbol".
Honestly, I tried to grasp it's meaning and purpose, and I failed.
I believe this flag is just a legacy no one can remember of, and
it's OK to remove it.
Removing 'MouseActions::drawn' completely doesn't seem to change
something, at least at first sight everything looks the same as
usual.
I cram everything in a single large commit for the sake of easier
reverting if it will be needed later.
After switching everything to drawing using bare QPainter, a lot
of ViewPainter-based stuff became unused and basically obsolete,
including the ViewPainter itself.
Schematic::drawContents is the root of the "drawing" call stack:
starting from this function the QPainter is passed down to diagrams,
components, paintings, etc., using the QPainter-base "paint" methods
prepared in previous commits. So, in this commit we're basically
connect everyhing together to make the new drawing subsystem.
Detached ports are ports which were inserted manually, i.e. they
don't have a corresponding port in schematic.
Inside Schematic::undo the Schematic::adjustPortNumbers is called.
The latter removes detached ports and because of that you lose
all of your ports if use "undo" once.
But Schematic::adjustPortNumbers is also called every time the
editing mode is switched and when the file is saved. So I think
it wouldn't be harm to not adjust port numbers every time you
undoing.
"Insert port" tool is reused it. When in symbol editing mode,
left mouse button click with this tool activated spawns a dialog
asking for port name, then insert a port.
I hope there is no breaking changes and everything is backwards
compatible as I strived to add workarounds everywhere it's needed.
The sad part is that code is not elegant, it increases overall
codebase entropy, doesn't follow any general strategy. It's just
a set of patches.
"Schematic" object already can edit symbols, this commit makes
it able to save and load them.
Implementation is actually quite ugly in terms of code beauty
and industry standards, it's very "hacky". It consists of two
parts:
1. Teach "Save" and "Open" dialogs to deal with "*.sym" files
2. Modify "Schematic" object and some other parts of codebase
so that when a schematic is saved and the filename ends with
"*.sym", then only symbol parts are saved. And vice versa:
when a file with a name ending in "*.sym" is opened, then
skip the path for usual schematic, and load only symbol parts.
The "symbol file" is actually a stripped "schematic file" — no
properties, no components, etc.
Passing Used.* members to 'sizeOfAll' function is clumsy, it
requires the reader to know the purpose of Used.* variables and
that 'sizeOfAll' function updates its arguments in-place. Then
both of facts must be summed up to understand that the line
Doc->sizeOfAll(Doc->UsedX1, Doc->UsedY1, Doc->UsedX2, Doc->UsedY2)
means 'update the bounds of the area occupied by elements'
On the other hand, the newly added 'updateAllBoundingRect' clearly
states what it does, it hides access to Used.* members and it's
easier to read and understand.
Schematic::sizeOfSelection returns values back to the client
via four reference variables passed to it as arguments. This
is not very elegant and most important it doesn't convey return
values semantics.
This commit makes 'sizeOfSelection' return QRect as usual return
value of function.
Schematic::sizeOfSelection have a set of variables declared in
the beginning of function body. These variables are used as loop
variables further down in function body, which is bad because:
- variable declarations are far from their actual usage
- variables have unnecessary large scope
This commit replaces them with `auto` variables declared directly
in loops.