pax_global_header 0000666 0000000 0000000 00000000064 13530327553 0014520 g ustar 00root root 0000000 0000000 52 comment=6d15d4452236cab4821918b722fac38f5d00133d
boats-201908/ 0000775 0000000 0000000 00000000000 13530327553 0012735 5 ustar 00root root 0000000 0000000 boats-201908/.gitignore 0000664 0000000 0000000 00000000277 13530327553 0014733 0 ustar 00root root 0000000 0000000 # kdevelop
*kdev*
# qt-creator
qtc-*
# windows
*.dll
# qt
.moc
qrc_*
*qm
#products
Makefile*
Doxyfile
doxygen/*
tags
.obj
# release
Changelog*
diffstat*
# project
boats
boats.exe
*xbs
boats-201908/COPYING 0000664 0000000 0000000 00000104374 13530327553 0014001 0 ustar 00root root 0000000 0000000
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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 .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
boats-201908/TODO 0000664 0000000 0000000 00000000661 13530327553 0013430 0 ustar 00root root 0000000 0000000 Important:
- fix printing document
- statechart
Normal:
- toggle number display
- arrows
- more boat shapes
- open in new tab
- more flags
- fix shortcut clashes
- save default series
- save default mark color
- spin trim
Wishlist:
- gpx import
- backtrack edit
- insert between boats
- starting a boat at a later number
- timing for the start boat
- animate spin hoist and drop
- create track in a series different from scenario
boats-201908/animation/ 0000775 0000000 0000000 00000000000 13530327553 0014714 5 ustar 00root root 0000000 0000000 boats-201908/animation/angleanimation.cpp 0000664 0000000 0000000 00000003317 13530327553 0020412 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: AngleAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "angleanimation.h"
AngleAnimation::AngleAnimation(QObject *target, const QByteArray &propertyName, QObject *parent)
: PropertyAnimation(target, propertyName, parent)
{
}
QVariant AngleAnimation::interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const
{
qreal valueBefore = from.toReal();
qreal valueAfter = to.toReal();
qreal minValue = qMin(valueBefore,valueAfter);
qreal maxValue = qMax(valueBefore,valueAfter);
if (maxValue - minValue <= 360 + minValue - maxValue) {
// Do a simple linear interpolation.
return valueBefore + (valueAfter - valueBefore) * progress;
} else {
// Do a reverse linear interpolation.
if (valueBefore > valueAfter)
return valueBefore + (360 + valueAfter - valueBefore) * progress;
else
return valueBefore + (valueAfter - valueBefore - 360) * progress;
}
}
boats-201908/animation/angleanimation.h 0000664 0000000 0000000 00000003052 13530327553 0020053 0 ustar 00root root 0000000 0000000 //
// C++ Interface: AngleAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef ANGLEANIMATION_H
#define ANGLEANIMATION_H
#include "propertyanimation.h"
/**
\class AngleAnimation
\brief Animation for angles with correct rotation
The class is the animation helper for an angle, according to the
Animation Framework.
It inherits QVariantAnimation and provides proper angle animation
to BoatGraphicsItem elements, like heading or sail position, so that
the shortest angle is taken between two options
\sa BoatGraphicsItem
*/
class AngleAnimation : public PropertyAnimation
{
public:
AngleAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0);
virtual QVariant interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const;
};
#endif // ANGLEANIMATION_H
boats-201908/animation/animation.pri 0000664 0000000 0000000 00000000763 13530327553 0017415 0 ustar 00root root 0000000 0000000 INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += \
$$PWD/angleanimation.h \
$$PWD/boatanimation.h \
$$PWD/headinganimation.h \
$$PWD/propertyanimation.h \
$$PWD/splineanimation.h \
$$PWD/scenarioanimation.h \
$$PWD/trackanimation.h
SOURCES += \
$$PWD/angleanimation.cpp \
$$PWD/boatanimation.cpp \
$$PWD/headinganimation.cpp \
$$PWD/propertyanimation.cpp \
$$PWD/splineanimation.cpp \
$$PWD/scenarioanimation.cpp \
$$PWD/trackanimation.cpp
boats-201908/animation/boatanimation.cpp 0000664 0000000 0000000 00000014140 13530327553 0020245 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: BoatAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include "boatanimation.h"
#include "boats.h"
#include "angleanimation.h"
#include "headinganimation.h"
#include "splineanimation.h"
#include "trackmodel.h"
#include "boatmodel.h"
/**
Populates the animation items for position, Headings and other attributes.
This method parses the path of the \a track, does some stalling
analysis and determines specific position animation.
*/
BoatAnimation::BoatAnimation(TrackModel *track, BoatModel *boat, int index, QObject *parent)
: QParallelAnimationGroup(parent),
m_track(track),
m_boat(boat)
{
BoatModel *model = track->boats()[index];
QPainterPath curve = model->path();
QPointF point = curve.elementAt(0);
QPointF c1 = curve.elementAt(1);
QPointF c2 = curve.elementAt(2);
QPointF end = curve.elementAt(3);
bool stalled = ((point == c1) || (c2 == end));
// position
SplineAnimation *splineAnimation = new SplineAnimation(m_boat, "pos", model->path());
splineAnimation->setDuration(2000);
splineAnimation->setStartValue(point);
splineAnimation->setEndValue(end);
addAnimation(splineAnimation);
// text
PropertyAnimation *textAnimation = new PropertyAnimation(boat, "text");
textAnimation->setDuration(2000);
textAnimation->setStartValue(model->text());
textAnimation->setEndValue(model->text());
addAnimation(textAnimation);
// text position
PropertyAnimation *textPosAnimation = new PropertyAnimation(boat, "textPos");
textPosAnimation->setDuration(2000);
textPosAnimation->setStartValue(model->textPosition());
textPosAnimation->setEndValue(model->textPosition());
addAnimation(textPosAnimation);
// laylines
PropertyAnimation *laylinesAnimation = new PropertyAnimation(boat, "laylines");
laylinesAnimation->setDuration(2000);
laylinesAnimation->setStartValue(model->laylines());
laylinesAnimation->setEndValue(model->laylines());
addAnimation(laylinesAnimation);
// heading
QVariantAnimation *headingAnimation;
if (stalled) {
headingAnimation = new AngleAnimation(boat, "heading");
} else {
headingAnimation = new HeadingAnimation(boat, "heading", model->path());
}
headingAnimation->setDuration(2000);
headingAnimation->setStartValue(model->heading());
addAnimation(headingAnimation);
AngleAnimation *windAnimation = new AngleAnimation(boat, "wind");
windAnimation->setDuration(2000);
windAnimation->setStartValue(model->wind());
addAnimation(windAnimation);
// sail angle
AngleAnimation *sailAngleAnimation = new AngleAnimation(boat, "trimSailAngle");
sailAngleAnimation->setDuration(2000);
sailAngleAnimation->setStartValue(model->trimmedSailAngle());
addAnimation(sailAngleAnimation);
// jib angle
AngleAnimation *jibAngleAnimation = new AngleAnimation(boat, "trimJibAngle");
jibAngleAnimation->setDuration(2000);
jibAngleAnimation->setStartValue(model->trimmedJibAngle());
addAnimation(jibAngleAnimation);
// spin
PropertyAnimation *spinAnimation = new PropertyAnimation(boat, "spin");
spinAnimation->setDuration(2000);
spinAnimation->setStartValue(model->spin());
addAnimation(spinAnimation);
// spin angle
AngleAnimation *spinAngleAnimation = new AngleAnimation(boat, "trimSpinAngle");
spinAngleAnimation->setDuration(2000);
spinAngleAnimation->setStartValue(model->trimmedSpinAngle());
addAnimation(spinAngleAnimation);
// gen angle
AngleAnimation *genAngleAnimation = new AngleAnimation(boat, "trimGennAngle");
genAngleAnimation->setDuration(2000);
genAngleAnimation->setStartValue(model->trimmedGennAngle());
addAnimation(genAngleAnimation);
// overlap
PropertyAnimation *overlapAnimation = new PropertyAnimation(boat, "overlap");
overlapAnimation->setDuration(2000);
overlapAnimation->setStartValue(QVariant(model->overlap()));
overlapAnimation->setEndValue(QVariant(model->overlap()));
addAnimation(overlapAnimation);
// flag
PropertyAnimation *flagAnimation = new PropertyAnimation(boat, "flag");
flagAnimation->setDuration(2000);
flagAnimation->setStartValue(model->flag());
flagAnimation->setEndValue(model->flag());
addAnimation(flagAnimation);
// acceleration
switch(model->acceleration()) {
case Boats::accelerating:
setEasingCurve(QEasingCurve::InSine);
break;
case Boats::decelerating:
setEasingCurve(QEasingCurve::OutSine);
break;
default:
break;
}
// end values that need next boat position
model = m_track->boats()[index+1];
headingAnimation->setEndValue(model->heading());
windAnimation->setEndValue(model->wind());
sailAngleAnimation->setEndValue(model->trimmedSailAngle());
jibAngleAnimation->setEndValue(model->trimmedJibAngle());
spinAnimation->setEndValue(model->spin());
spinAngleAnimation->setEndValue(model->trimmedSpinAngle());
genAngleAnimation->setEndValue(model->trimmedGennAngle());
}
BoatAnimation::~BoatAnimation() {
}
void BoatAnimation::setEasingCurve(const QEasingCurve &easing) {
for (int i=0; i< animationCount(); ++i) {
QVariantAnimation *animation = dynamic_cast(animationAt(i));
if(animation) {
animation->setEasingCurve(easing);
}
}
}
boats-201908/animation/boatanimation.h 0000664 0000000 0000000 00000003371 13530327553 0017716 0 ustar 00root root 0000000 0000000 //
// C++ Interface: BoatAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BOATANIMATION_H
#define BOATANIMATION_H
#include
#include
class TrackModel;
class BoatModel;
/**
\class BoatAnimation
\brief The animation Item for a boat in its track
The class is the animation group for a boat, according
to the Animation Framework.
It inherits QParallelAnimationGroup and provides all animation features,
like position and heading given a time step.
\sa SituationScene, SituationModel
*/
class BoatAnimation : public QParallelAnimationGroup {
public:
BoatAnimation(TrackModel *track, BoatModel *boat, int index, QObject *parent = 0);
~BoatAnimation();
BoatModel *boat() const {return m_boat; }
void setEasingCurve ( const QEasingCurve & easing );
private:
/// \a m_track holds the reference to the track
TrackModel *m_track;
/// \a m_boat holds the reference to the boat
BoatModel *m_boat;
};
#endif
boats-201908/animation/headinganimation.cpp 0000664 0000000 0000000 00000002577 13530327553 0020732 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: HeadingAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include "headinganimation.h"
#include "angleanimation.h"
HeadingAnimation::HeadingAnimation(QObject *target, const QByteArray &propertyName, const QPainterPath &path, QObject *parent)
: PropertyAnimation(target, propertyName, parent),
m_path(path)
{
}
QVariant HeadingAnimation::interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const
{
Q_UNUSED(from)
Q_UNUSED(to)
qreal length = m_path.length();
qreal percent = m_path.percentAtLength(length * progress);
return fmod(360+90-m_path.angleAtPercent(percent),360.0);
}
boats-201908/animation/headinganimation.h 0000664 0000000 0000000 00000003203 13530327553 0020362 0 ustar 00root root 0000000 0000000 //
// C++ Interface: HeadingAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef HEADINGANIMATION_H
#define HEADINGANIMATION_H
#include
#include "propertyanimation.h"
/**
\class HeadingAnimation
\brief Animation for angles with correct rotation
The class is the animation helper for an angle, according to the
Animation Framework.
It inherits QVariantAnimation and provides proper animation
to BoatGraphicsItem elements along a QPainterPath, like the boat heading, so
that the heading follows the path
\sa BoatGraphicsItem
*/
class HeadingAnimation : public PropertyAnimation
{
public:
HeadingAnimation(QObject *target, const QByteArray &propertyName, const QPainterPath &path, QObject *parent = 0);
virtual QVariant interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const;
private:
QPainterPath m_path;
};
#endif // HEADINGANIMATION_H
boats-201908/animation/propertyanimation.cpp 0000664 0000000 0000000 00000004222 13530327553 0021204 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: PropertyAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include "propertyanimation.h"
#include "boats.h"
PropertyAnimation::PropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent)
: QPropertyAnimation(target, propertyName, parent)
{
}
void PropertyAnimation::updateCurrentValue ( const QVariant & value )
{
// doesn't work because QPropertyAnimationPrivate::updateProperty checks for not Stopped
// QPropertyAnimation::updateCurrentValue(value);
targetObject()->setProperty(propertyName(), value);
}
QVariant boolInterpolator(const bool &start, const bool &end, qreal progress)
{
Q_UNUSED(end)
Q_UNUSED(progress)
return start;
}
//qRegisterAnimationInterpolator(boolInterpolator);
QVariant qstringInterpolator(const QString &start, const QString &end, qreal progress)
{
Q_UNUSED(end)
Q_UNUSED(progress)
return start;
}
//qRegisterAnimationInterpolator( qstringInterpolator );
QVariant PropertyAnimation::interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const
{
if (strcmp(from.typeName(), "bool") == 0) {
return boolInterpolator(from.toBool(), to.toBool(), progress);
}
else if (strcmp(from.typeName(), "QString") == 0) {
return qstringInterpolator(from.toString(), to.toString(), progress);
}
return QVariantAnimation::interpolated(from, to, progress);
}
boats-201908/animation/propertyanimation.h 0000664 0000000 0000000 00000003132 13530327553 0020650 0 ustar 00root root 0000000 0000000 //
// C++ Interface: PropertyAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef PROPERTYANIMATION_H
#define PROPERTYANIMATION_H
#include
/**
\class PropertyAnimation
\brief Animation for properties irrelevant of state
The class is the animation helper for a property, according to the
Animation Framework.
It inherits QVariantAnimation and provides proper property animation
so that the property is updated whatever the state, unlike QPropertyAnimation
\sa QPropertyAnimation
*/
class PropertyAnimation : public QPropertyAnimation
{
public:
PropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0);
virtual void updateCurrentValue ( const QVariant & value );
virtual QVariant interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const;
};
#endif // PROPERTYANIMATION_H
boats-201908/animation/scenarioanimation.cpp 0000664 0000000 0000000 00000007737 13530327553 0021141 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: ScenarioAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include "scenarioanimation.h"
#include "situationmodel.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include "statemachine.h"
#include "trackanimation.h"
#include "angleanimation.h"
#include
ScenarioAnimation::ScenarioAnimation(SituationModel *situation, QObject *parent)
: QParallelAnimationGroup(parent),
m_situation(situation),
m_windAnimation(new QSequentialAnimationGroup(this)) {
addAnimation(m_windAnimation);
connect(m_situation->stateMachine()->playState(), SIGNAL(entered()),
this, SLOT(start()));
connect(m_situation->stateMachine()->pauseState(), SIGNAL(entered()),
this, SLOT(pause()));
connect(m_situation->stateMachine()->stopState(), SIGNAL(entered()),
this, SLOT(stop()));
}
ScenarioAnimation::~ScenarioAnimation() {
delete m_windAnimation;
}
void ScenarioAnimation::setAnimation() {
foreach(TrackModel *track, m_situation->tracks()) {
BoatModel *boat = track->boats()[0];
BoatModel *animationBoat = new BoatModel(track);
animationBoat->setOrder(0);
animationBoat->setPosition(boat->position());
animationBoat->setHeading(boat->heading());
animationBoat->setWind(m_situation->wind().windAt(0));
animationBoat->setLaylines(boat->laylines());
connect(&m_situation->wind(), SIGNAL(directionChanged(qreal)),
animationBoat, SLOT(setWind(qreal)));
TrackAnimation *animation = new TrackAnimation(track, animationBoat, this);
addAnimation(animation);
m_animationItems.push_back(animation);
emit trackAnimationsChanged();
}
for (int i = 0; i < m_situation->wind().size()-1; ++i) {
AngleAnimation *wind = new AngleAnimation(&m_situation->wind(), "direction");
wind->setDuration(2000);
wind->setStartValue(m_situation->wind().windAt(i));
wind->setEndValue(m_situation->wind().windAt(i+1));
m_windAnimation->addAnimation(wind);
}
setCurrentTime(0);
}
void ScenarioAnimation::unsetAnimation() {
foreach(TrackAnimation *animation, m_animationItems) {
// the boat was never really part of the track, we use situation signal
// directly to have the graphicsitem removed
m_situation->removingBoat(animation->boat());
removeAnimation(animation);
m_animationItems.removeOne(animation);
emit trackAnimationsChanged();
delete animation->boat();
delete animation;
}
for (int i = 0; i < m_situation->wind().size()-1; ++i) {
QAbstractAnimation *animation = m_windAnimation->animationAt(0);
m_windAnimation->removeAnimation(animation);
delete animation;
}
m_situation->wind().setDirection(m_situation->wind().windAt(0));
}
void ScenarioAnimation::updateCurrentTime(int currentTime)
{
QParallelAnimationGroup::updateCurrentTime(currentTime);
emit timeChanged(currentTime);
}
QList ScenarioAnimation::animationItems() {
return m_animationItems;
}
#ifdef QML
QQmlListProperty ScenarioAnimation::trackAnimationList() {
return QQmlListProperty(this, m_animationItems);
}
#endif
boats-201908/animation/scenarioanimation.h 0000664 0000000 0000000 00000004735 13530327553 0020601 0 ustar 00root root 0000000 0000000 //
// C++ Interface: ScenarioAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef SCENARIOANIMATION_H
#define SCENARIOANIMATION_H
#include
#ifdef QML
#include
#endif
class TrackAnimation;
class SituationModel;
class TrackModel;
/**
\class ScenarioAnimation
\brief Animation for the whole scenario
The class is the animation group for a scenario, according
to the Animation Framework.
It inherits QParallelAnimationGroup and contains TrackAnimations
for the different tracks of the scenario
\sa TrackAnimation
*/
class ScenarioAnimation: public QParallelAnimationGroup
{
Q_OBJECT
Q_PROPERTY(int time READ currentTime WRITE setCurrentTime NOTIFY timeChanged)
Q_PROPERTY(int scenarioDuration READ duration NOTIFY trackAnimationsChanged)
#ifdef QML
Q_PROPERTY(QQmlListProperty trackAnimationList READ trackAnimationList NOTIFY trackAnimationsChanged)
#endif
public:
ScenarioAnimation(SituationModel *situation = 0, QObject *parent = 0);
~ScenarioAnimation();
virtual void updateCurrentTime(int currentTime);
QList animationItems();
#ifdef QML
QQmlListProperty trackAnimationList();
#endif
signals:
void timeChanged(int time);
void trackAnimationsChanged();
public slots:
void setAnimation();
void unsetAnimation();
private:
/// \a m_animationItems holds the list of TrackAnimation items
/// created for animation mode
QList m_animationItems;
SituationModel *m_situation;
/// \a m_windAnimation holds the animation for wind
QAnimationGroup *m_windAnimation;
};
#endif // SCENARIOANIMATION_H
boats-201908/animation/splineanimation.cpp 0000664 0000000 0000000 00000002527 13530327553 0020620 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: SplineAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "splineanimation.h"
SplineAnimation::SplineAnimation(QObject *target, const QByteArray &propertyName,
const QPainterPath &path, QObject *parent)
: PropertyAnimation(target, propertyName, parent),
m_path(path)
{
}
QVariant SplineAnimation::interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const
{
Q_UNUSED(from)
Q_UNUSED(to)
qreal length = m_path.length();
qreal percent = m_path.percentAtLength(length * progress);
return m_path.pointAtPercent(percent);
}
boats-201908/animation/splineanimation.h 0000664 0000000 0000000 00000003236 13530327553 0020263 0 ustar 00root root 0000000 0000000 //
// C++ Interface: SplineAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef SPLINEANIMATION_H
#define SPLINEANIMATION_H
#include
#include "propertyanimation.h"
/**
\class SplineAnimation
\brief Animation for the position along a spline
The class is the animation helper for a position along a spline, according
to the Animation Framework.
It inherits QPropertyAnimation and provides animation for a QPointF
to BoatGraphicsItem elements, like boat position along its track, so that
the boat moves on its track
\sa BoatGraphicsItem
*/
class SplineAnimation : public PropertyAnimation
{
public:
SplineAnimation(QObject *target, const QByteArray &propertyName, const QPainterPath &path, QObject *parent = 0);
virtual QVariant interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const;
private:
QPainterPath m_path;
};
#endif // SPLINEANIMATION_H
boats-201908/animation/trackanimation.cpp 0000664 0000000 0000000 00000005361 13530327553 0020431 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: TrackAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include
#include "trackanimation.h"
#include "boatmodel.h"
#include "trackmodel.h"
#include "boatanimation.h"
#include "propertyanimation.h"
TrackAnimation::TrackAnimation(TrackModel *track, BoatModel *boat, QObject *parent)
: QParallelAnimationGroup(parent),
m_track(track),
m_boat(boat)
{
int size = m_track->size();
if (size < 0) {
return;
}
QSequentialAnimationGroup *boatsAnimation = new QSequentialAnimationGroup(this);
// through all boats of the track
for (int i=0; i< size; i++) {
if (iaddAnimation(boatAnimation);
}
QSequentialAnimationGroup *visibilityAnimation = new QSequentialAnimationGroup(this);
PropertyAnimation *invisibletAnimation = new PropertyAnimation(m_track->boats()[i],"dim", this);
invisibletAnimation->setDuration(2000*i);
invisibletAnimation->setStartValue(0);
invisibletAnimation->setEndValue(0);
visibilityAnimation->addAnimation(invisibletAnimation);
PropertyAnimation *dimAnimation = new PropertyAnimation(m_track->boats()[i],"dim", this);
if (isetDuration(2000);
} else {
dimAnimation->setDuration(0);
}
dimAnimation->setStartValue(255);
dimAnimation->setEndValue(64);
visibilityAnimation->addAnimation(dimAnimation);
addAnimation(visibilityAnimation);
}
addAnimation(boatsAnimation);
// dim all track boats
foreach(BoatModel *boat, m_track->boats()) {
boat->setDim(0);
}
}
/**
Resets the color and List of BoatModels in the track
*/
TrackAnimation::~TrackAnimation() {
// undim all track boats
foreach(BoatModel *boat, m_track->boats()) {
boat->setDim(255);
}
m_track->changingTrack(m_track);
}
boats-201908/animation/trackanimation.h 0000664 0000000 0000000 00000003513 13530327553 0020073 0 ustar 00root root 0000000 0000000 //
// C++ Interface: TrackAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2010-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef TRACKANIMATION_H
#define TRACKANIMATION_H
#include
class BoatModel;
class TrackModel;
/**
\class TrackAnimation
\brief Animation for the whole track of a boat
The class is the animation group for a track, according
to the Animation Framework.
It inherits QParallelAnimationGroup and contains various animation class
for the different properties of a boat to animate along the track
\sa BoatAnimation
*/
class TrackAnimation: public QParallelAnimationGroup
{
Q_OBJECT
Q_PROPERTY(BoatModel* boat READ boat CONSTANT)
Q_PROPERTY(TrackModel* track READ track CONSTANT)
public:
TrackAnimation(TrackModel *track = 0, BoatModel *boat = 0, QObject *parent = 0);
~TrackAnimation();
BoatModel *boat() const {return m_boat; }
TrackModel *track() const {return m_track; }
private:
/// \a m_track holds the reference to the track
TrackModel *m_track;
/// \a m_track holds the reference to the animated boat
BoatModel *m_boat;
};
#endif // TRACKANIMATION_H
boats-201908/boatapplication.cpp 0000664 0000000 0000000 00000002324 13530327553 0016613 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: BoatApplication
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#include "boatapplication.h"
#include "mainwindow.h"
bool BoatApplication::event(QEvent *event) {
switch (event->type()) {
case QEvent::FileOpen:
if (m_window) {
m_window->openFile(static_cast(event)->file());
return true;
}
break;
default:
break;
}
return QApplication::event(event);
}
boats-201908/boatapplication.h 0000664 0000000 0000000 00000002360 13530327553 0016260 0 ustar 00root root 0000000 0000000 //
// C++ Interface: BoatApplication
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BOATAPPLICATION_H
#define BOATAPPLICATION_H
#include
#include
class MainWindow;
class BoatApplication : public QApplication {
Q_OBJECT
public:
BoatApplication(int & argc, char ** argv) :
QApplication(argc, argv) {}
~BoatApplication() {}
void setWindow(MainWindow *window) { m_window = window; }
protected:
bool event(QEvent *event);
private:
MainWindow *m_window;
};
#endif // BOATAPPLICATION_H
boats-201908/boats.cpp 0000664 0000000 0000000 00000005660 13530327553 0014560 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: boats
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#include "boats.h"
QList Boats::m_seriesList;
QList Boats::seriesList() {
if (!m_seriesList.size()) {
for (int i=0; i< ENUM_SIZE(Boats, Series)-1; i++) {
m_seriesList << ENUM_NAME(Boats, Series, i);
}
}
// By doing it this way guarantee that labels align correctly with enum tags irrespective of order
m_seriesList[keelboat] = QObject::tr("Spin Keelboat");
m_seriesList[keelboatwithgenn] = QObject::tr("Gennaker Keelboat");
m_seriesList[int49er] = QObject::tr("49er");
m_seriesList[rsfeva] = QObject::tr("RS Feva");
m_seriesList[int470] = QObject::tr("470");
m_seriesList[int420] = QObject::tr("420");
m_seriesList[int29er] = QObject::tr("29er");
m_seriesList[finn] = QObject::tr("Finn");
m_seriesList[laser] = QObject::tr("Laser");
m_seriesList[firefly] = QObject::tr("Firefly");
m_seriesList[topper] = QObject::tr("Topper");
m_seriesList[optimist] = QObject::tr("Optimist");
m_seriesList[tornado] = QObject::tr("Tornado");
m_seriesList[nacra17] = QObject::tr("Nacra 17");
m_seriesList[diam24] = QObject::tr("Diam 24");
m_seriesList[startboat] = QObject::tr("Committee boat");
m_seriesList[rib] = QObject::tr("RIB");
return m_seriesList;
}
QList Boats::m_seriesSizeList;
QList Boats::seriesSizeList() {
if (!m_seriesSizeList.size()) {
for (int i=0; i< ENUM_SIZE(Boats, Series)-1; i++) {
m_seriesSizeList << 100; // default size of 100
}
m_seriesSizeList[keelboat] = 100;
m_seriesSizeList[keelboatwithgenn] = 100;
m_seriesSizeList[int49er] = 48;
m_seriesSizeList[rsfeva] = 36.4;
m_seriesSizeList[int470] = 47;
m_seriesSizeList[int420] = 42;
m_seriesSizeList[int29er] = 41;
m_seriesSizeList[finn] = 45;
m_seriesSizeList[laser] = 40;
m_seriesSizeList[firefly] = 36.6;
m_seriesSizeList[topper] = 34;
m_seriesSizeList[optimist] = 23;
m_seriesSizeList[tornado] = 61;
m_seriesSizeList[nacra17] = 52.5;
m_seriesSizeList[diam24] = 72.5;
m_seriesSizeList[rib] = 60;
}
return m_seriesSizeList;
}
boats-201908/boats.h 0000664 0000000 0000000 00000004672 13530327553 0014227 0 ustar 00root root 0000000 0000000 //
// C++ Interface: boats
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BOATS_H
#define BOATS_H
#include
#include
#include
#define ENUM_NAME(o,e,v) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).valueToKey((v)))
#define ENUM_VALUE(o,e,n) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).keyToValue((n)))
#define ENUM_SIZE(o,e) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).keyCount())
#define FLAG_NAME(o,e,v) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).valueToKeys((v)))
#define FLAG_VALUE(o,e,n) (o::staticMetaObject.enumerator(o::staticMetaObject.indexOfEnumerator(#e)).keysToValue((n)))
class Boats {
Q_GADGET
public:
enum Series {
keelboat,
keelboatwithgenn,
int49er,
rsfeva,
int470,
int420,
int29er,
finn,
laser,
firefly,
topper,
optimist,
tornado,
nacra17,
diam24,
startboat,
rib,
unknown
};
Q_ENUMS (Series);
static QList seriesList();
static QList seriesSizeList();
enum Overlap {
none = 0x0,
starboard = 0x1,
port = 0x2
};
Q_FLAGS( Overlap Overlaps)
Q_DECLARE_FLAGS(Overlaps, Overlap)
enum Flag {
noFlag,
Y,
Red,
Green,
Yellow,
Blue
};
Q_ENUMS (Flag);
enum Acceleration {
constant,
accelerating,
decelerating
};
Q_ENUMS (Acceleration);
private:
static QList m_seriesList;
static QList m_seriesSizeList;
};
Q_DECLARE_METATYPE(Boats::Overlaps)
#endif
boats-201908/boats.pro 0000664 0000000 0000000 00000005070 13530327553 0014571 0 ustar 00root root 0000000 0000000 TEMPLATE = app
CONFIG += qt warn_on
HEADERS += \
boats.h \
boatsengine.h \
commontypes.h \
enablestate.h \
statemachine.h \
trace.h \
undocommands.h \
xmlsituationreader.h \
xmlsituationwriter.h
SOURCES += \
boats.cpp \
boatsengine.cpp \
enablestate.cpp \
statemachine.cpp \
trace.cpp \
undocommands.cpp \
xmlsituationreader.cpp \
xmlsituationwriter.cpp
qml {
TARGET = boats-qml
QT += quick qml widgets
DEFINES += QML
SOURCES += \
main_qml.cpp
qml_files.files = boats.qml
INSTALL += qml_files
}
else {
TARGET = boats
QT += widgets printsupport
include(graphicsview/graphicsview.pri)
include(itemviews/itemviews.pri)
include(locale/locale.pri)
HEADERS += \
boatapplication.h \
mainwindow.h \
situationprint.h \
situationwidget.h
SOURCES += \
boatapplication.cpp \
main.cpp \
mainwindow.cpp \
situationprint.cpp \
situationwidget.cpp
contains(GIF_EXPORT,1) {
DEFINES += GIF_EXPORT
HEADERS += gifwriter.h
SOURCES += gifwriter.cpp
LIBS += -lgif
}
PRE_TARGETDEPS += compiler_updateqm_make_all
QMAKE_CFLAGS_RELEASE += -fvisibility=hidden
QMAKE_CXXFLAGS_RELEASE += -fvisibility=hidden -fvisibility-inlines-hidden
}
include(animation/animation.pri)
include(model/model.pri)
INCLUDEPATH += $$PWD
RESOURCES += images.qrc
mac {
QMAKE_LFLAGS += -static
QMAKE_INFO_PLIST = resources/Info.plist
ICON = resources/boats.icns
mime.path = boats.app/Contents/Resources
mime.files = resources/xbs.icns
INSTALLS += mime
}
win32 {
RC_FILE = resources/boats.rc
QMAKE_LFLAGS += -static
}
unix_deploy {
isEmpty(PREFIX):PREFIX = /usr/local
target.path = $${PREFIX}/bin
INSTALLS += target
desktop.path = $${PREFIX}/share/applications
desktop.files = resources/boats.desktop
INSTALLS += desktop
icons.path = $${PREFIX}/share/icons
icons.files = images/icons/*
INSTALLS += icons
mimetype.path = $${PREFIX}/share/mime/packages
mimetype.files = resources/boats.xml
INSTALLS += mimetype
TRANSLATEDIR = $${PREFIX}/share/boats
translations.path = $${TRANSLATEDIR}
translations.files = locale/boats_*.qm
INSTALLS += translations
}
else {
!qml {
RESOURCES += locales.qrc
TRANSLATEDIR = ":/locale"
}
}
DEFINES += TRANSLATEDIR=\\\"$${TRANSLATEDIR}\\\"
MOC_DIR = .moc/
OBJECTS_DIR = .obj/
boats-201908/boats.qml 0000664 0000000 0000000 00000000127 13530327553 0014560 0 ustar 00root root 0000000 0000000 import QtQuick 2.0
Rectangle {
width: 962
height: 553
Canvas {
}
}
boats-201908/boatsengine.cpp 0000664 0000000 0000000 00000024056 13530327553 0015746 0 ustar 00root root 0000000 0000000
// C++ Implementation: boatsengine
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2014 Thibaut GRIDEL
//
// 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 .
//
//
#include "boatsengine.h"
#include "commontypes.h"
#include "boats.h"
#include "situationmodel.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include "markmodel.h"
#include "polylinemodel.h"
#include "pointmodel.h"
#include "statemachine.h"
#include "scenarioanimation.h"
#include "xmlsituationreader.h"
#include "xmlsituationwriter.h"
#include
extern int debugLevel;
BoatsEngine::BoatsEngine(QObject *parent) :
QObject(parent),
m_currentSituation(0)
{
}
void BoatsEngine::newFile() {
SituationModel *situation = new SituationModel(this);
m_situationList.append(situation);
setIndex(m_situationList.size()-1);
emit sizeChanged();
}
void BoatsEngine::setIndex(int index) {
m_currentSituation = index;
emit indexChanged();
}
void BoatsEngine::removeFile(int index) {
SituationModel *situation = m_situationList.at(index);
m_situationList.removeAt(index);
situation->deleteLater();
emit sizeChanged();
}
void BoatsEngine::resetFile() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->undoStack()->setIndex(0);
setCurrentFile(situation, "");
situation->undoStack()->clear();
situation->wind().clearWind();
}
bool BoatsEngine::openFile(const QString &fileName) {
SituationModel *situation = m_situationList.at(m_currentSituation);
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// QMessageBox::warning(this, tr("Open Scenario File"),
// tr("Cannot read file %1:\n%2.")
// .arg(fileName)
// .arg(file.errorString()));
return false;
}
XmlSituationReader reader(situation);
if (!reader.read(&file)) {
// QMessageBox::warning(this, tr("Open Scenario file"),
// tr("Parse error in file %1 at line %2, column %3:\n%4")
// .arg(fileName)
// .arg(reader.lineNumber())
// .arg(reader.columnNumber())
// .arg(reader.errorString()));
return false;
}
setCurrentFile(situation, fileName);
return true;
}
bool BoatsEngine::saveSituation(QString fileName) {
SituationModel *situation = m_situationList.at(m_currentSituation);
QString name = fileName;
if (name.isEmpty()) {
QString defaultFile;
if (situation->fileName().isEmpty()) {
defaultFile = QDateTime::currentDateTime().toString("yyMMdd") + ".xbs";
} else {
defaultFile = situation->fileName();
}
if (QFileInfo(name).suffix().isEmpty())
name.append(".xbs");
if (QFile::exists(name)) {
// if (QMessageBox::warning(this, tr("Save Scenario"),
// tr("%1 already exists.\nDo you want to replace it?")
// .arg(QFileInfo(name).baseName()),
// QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
// == QMessageBox::No) {
// return false;
// }
}
}
QFile file(name);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
// QMessageBox::warning(this, tr("Save Scenario"),
// tr("Cannot write file %1:\n%2.")
// .arg(fileName)
// .arg(file.errorString()));
return false;
}
XmlSituationWriter writer(situation);
writer.writeFile(&file);
setCurrentFile(situation, name);
return true;
}
void BoatsEngine::setCurrentFile(SituationModel *situation, const QString &fileName) {
situation->setFileName(fileName);
situation->undoStack()->setClean();
}
QStringList BoatsEngine::fileList() {
QStringList fileList;
foreach(SituationModel *situation, m_situationList) {
if (!situation->fileName().isEmpty()) {
fileList.append(situation->fileName());
}
}
return fileList;
}
void BoatsEngine::addTrack() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->createTrack();
}
void BoatsEngine::deleteTrack() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->deleteTrack();
}
void BoatsEngine::addBoat() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->createBoat();
}
void BoatsEngine::deleteModels() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->deleteModels();
}
void BoatsEngine::addMark() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->createMark();
}
void BoatsEngine::addPolyLine() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->createLine();
}
void BoatsEngine::addPoint() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->createPoint();
}
void BoatsEngine::animate() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->animate();
}
void BoatsEngine::play() {
if (debugLevel & 1 << ANIMATION) std::cout << "playing" << std::endl;
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->play();
}
void BoatsEngine::pause() {
if (debugLevel & 1 << ANIMATION) std::cout << "pausing" << std::endl;
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->pause();
}
void BoatsEngine::stop() {
if (debugLevel & 1 << ANIMATION) std::cout << "stopping" << std::endl;
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->stateMachine()->stop();
situation->animation()->setCurrentTime(0);
}
void BoatsEngine::trimSail() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->trimSail();
}
void BoatsEngine::autotrimSail() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->autotrimSail();
}
void BoatsEngine::untrimSail() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->untrimSail();
}
void BoatsEngine::trimJib() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->trimJib();
}
void BoatsEngine::autotrimJib() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->autotrimJib();
}
void BoatsEngine::untrimJib() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->untrimJib();
}
void BoatsEngine::trimSpin() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->trimSpin();
}
void BoatsEngine::autotrimSpin() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->autotrimSpin();
}
void BoatsEngine::untrimSpin() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->untrimSpin();
}
void BoatsEngine::togglePortOverlap() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->togglePortOverlap();
}
void BoatsEngine::toggleStarboardOverlap() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleStarboardOverlap();
}
void BoatsEngine::toggleHidden() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleHidden();
}
void BoatsEngine::toggleText() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleText();
}
void BoatsEngine::toggleFlag(Boats::Flag flag) {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleFlag(flag);
}
void BoatsEngine::toggleAcceleration(Boats::Acceleration acceleration) {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleAcceleration(acceleration);
}
void BoatsEngine::toggleSpin() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleSpin();
}
void BoatsEngine::toggleMarkSide() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleMarkSide();
}
void BoatsEngine::toggleMarkArrow() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleMarkArrow();
}
void BoatsEngine::toggleMarkZone() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleMarkZone();
}
void BoatsEngine::setMarkColor(QColor color) {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->setMarkColor(color);
}
void BoatsEngine::toggleMarkLabel() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleMarkLabel();
}
void BoatsEngine::editMarkLabel(QString text) {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->editMarkLabel(text);
}
void BoatsEngine::toggleLaylines() {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->toggleLaylines();
}
void BoatsEngine::setLookAt(int direction, int tilt) {
SituationModel *situation = m_situationList.at(m_currentSituation);
situation->setLookAt(direction, tilt);
}
boats-201908/boatsengine.h 0000664 0000000 0000000 00000006145 13530327553 0015412 0 ustar 00root root 0000000 0000000 //
// C++ Interface: boatsengine
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2014 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BOATSENGINE_H
#define BOATSENGINE_H
#include "boats.h"
#include
#include
#include
#include
class SituationModel;
class BoatsEngine : public QObject
{
Q_OBJECT
public:
Q_PROPERTY(int index READ currentIndex WRITE setIndex NOTIFY indexChanged)
Q_PROPERTY(int size READ situationSize NOTIFY sizeChanged)
Q_PROPERTY(SituationModel* scenario READ currentModel NOTIFY indexChanged)
explicit BoatsEngine(QObject *parent = 0);
SituationModel *currentModel() {
if(m_situationList.size()) {
return m_situationList.at(m_currentSituation);
} else return 0;
}
int situationSize() { return m_situationList.size(); }
int currentIndex() { return m_currentSituation; }
Q_INVOKABLE QStringList fileList();
Q_INVOKABLE bool saveSituation(QString name = QString());
public slots:
// File actions
void newFile();
void setIndex(int index);
void removeFile(int index);
void resetFile();
bool openFile(const QString &fileName);
// State actions
void addTrack();
void addBoat();
void addMark();
void addPolyLine();
void addPoint();
void animate();
void play();
void pause();
void stop();
// Boat actions
void trimSail();
void autotrimSail();
void untrimSail();
void trimJib();
void autotrimJib();
void untrimJib();
void trimSpin();
void autotrimSpin();
void untrimSpin();
void togglePortOverlap();
void toggleStarboardOverlap();
void toggleFlag(Boats::Flag flag);
void toggleAcceleration(Boats::Acceleration acceleration);
void toggleHidden();
void toggleText();
void toggleSpin();
// Mark actions
void toggleMarkSide();
void toggleMarkArrow();
void toggleMarkZone();
void setMarkColor(QColor color);
void toggleLaylines();
void toggleMarkLabel();
void editMarkLabel(QString text);
// Situation actions
void deleteTrack();
void deleteModels();
void setLookAt(int direction, int tilt);
signals:
void indexChanged();
void sizeChanged();
private:
// File methods
void setCurrentFile(SituationModel *situation, const QString &fileName);
// GraphicsView Framework
QList m_situationList;
int m_currentSituation;
};
#endif
boats-201908/commontypes.h 0000664 0000000 0000000 00000002205 13530327553 0015462 0 ustar 00root root 0000000 0000000 //
// C++ Interface: commontypes
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef COMMONTYPES_H
#define COMMONTYPES_H
enum DebugTraces {
MODEL,
VIEW,
COMMAND,
ANIMATION,
DELEGATE,
XML,
EXPORT,
STATE
};
typedef enum {
TRACK_COLOR,
TRACK_PATH,
TRACK_SERIES,
TRACK_FOLLOW
} TrackTableItem;
typedef enum {
WIND_INDEX,
WIND_DIRECTION,
WIND_DELETE
} WindTableItem;
#endif
boats-201908/doc/ 0000775 0000000 0000000 00000000000 13530327553 0013502 5 ustar 00root root 0000000 0000000 boats-201908/doc/boats.1 0000664 0000000 0000000 00000000773 13530327553 0014703 0 ustar 00root root 0000000 0000000 .\" Process this file with
.\" groff -man -Tascii foo.1
.\"
.TH BOATS 1 "APRIL 2009"
.SH NAME
boats \- a race scenario drawing tool
.SH SYNOPSIS
.B boats [-debug n]
.I file
.B ...
.SH DESCRIPTION
.B boats
Boat Scenario is a drawing tool. It is your ideal
companion for training sessions, rule learning, strategy
explanations and more.
All files provided in the command line will be opened
on different tabs.
.SH OPTIONS
.IP -debug
Provide debugging output
.SH AUTHOR
Thibaut GRIDEL
boats-201908/enablestate.cpp 0000664 0000000 0000000 00000005142 13530327553 0015732 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: enablestate
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2014 Thibaut GRIDEL
//
// 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 .
//
//
#include "enablestate.h"
#include "commontypes.h"
#include
#include
#include
#include
extern int debugLevel;
EnableState::EnableState(QState *parent) :
QState(parent),
m_active(false),
m_enabled(false)
{
}
bool EnableState::isActive() {
return m_active;
}
bool EnableState::isEnabled() {
return m_enabled;
}
bool EnableState::isToggable() {
return m_toggable;
}
void EnableState::onEntry(QEvent *event) {
Q_UNUSED(event);
if(!m_active) {
m_active = true;
if (debugLevel & 1 << STATE) std::cout << "State Entry " << this->objectName().toStdString() << std::endl;
emit activeChanged(m_active);
foreach (QAbstractTransition* transition, transitions()) {
EnableState *state = static_cast (transition->targetState());
state->setEnabled(true);
}
if (m_toggable) {
setEnabled(true);
}
}
}
void EnableState::onExit(QEvent *event) {
Q_UNUSED(event);
if(m_active) {
m_active = false;
if (debugLevel & 1 << STATE) std::cout << "State Exit " << this->objectName().toStdString() << std::endl;
emit activeChanged(m_active);
foreach (QAbstractTransition* transition, transitions()) {
EnableState *state = static_cast (transition->targetState());
state->setEnabled(false);
}
if (m_toggable) {
setEnabled(false);
}
}
}
void EnableState::setEnabled(bool enabled) {
if (m_enabled != enabled) {
m_enabled = enabled;
emit enabledChanged(m_enabled);
}
}
void EnableState::setToggable(bool toggable) {
if (m_toggable != toggable) {
m_toggable = toggable;
emit toggableChanged(m_toggable);
}
}
boats-201908/enablestate.h 0000664 0000000 0000000 00000003076 13530327553 0015403 0 ustar 00root root 0000000 0000000 //
// C++ Interface: state
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2014 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef ENABLESTATE_H
#define ENABLESTATE_H
#include
class EnableState : public QState
{
Q_OBJECT
Q_PROPERTY(bool isActive READ isActive NOTIFY activeChanged)
Q_PROPERTY(bool isEnabled READ isEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool isToggable READ isToggable WRITE setToggable NOTIFY toggableChanged)
public:
explicit EnableState(QState *parent = 0);
bool isActive();
bool isEnabled();
bool isToggable();
void setEnabled(bool enabled);
void setToggable(bool toggable);
signals:
void activeChanged(bool);
void enabledChanged(bool);
void toggableChanged(bool);
protected:
void onEntry(QEvent *event);
void onExit(QEvent *event);
private:
bool m_active;
bool m_enabled;
bool m_toggable;
};
#endif // ENABLESTATE_H
boats-201908/gifwriter.cpp 0000664 0000000 0000000 00000005534 13530327553 0015452 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: gifwriter
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#include "gifwriter.h"
#include
#include
#include
GifWriter::GifWriter() {
}
int GifWriter::writeData(const GifByteType *bytes, int size) {
return device()->write((char *)bytes, size);
}
static int myOutputFunc(GifFileType * fileType, const GifByteType * bytes, int size) {
GifWriter *writer = reinterpret_cast(fileType->UserData);
return writer->writeData(bytes, size);
}
bool GifWriter::write(QList imageList) {
GifFileType *fileType;
int retrn;
QImage *image = imageList.first();
fileType = EGifOpen((void*) this, myOutputFunc, &retrn);
EGifSetGifVersion(fileType, true);
int colors = 256;
ColorMapObject * cmap = GifMakeMapObject(colors, NULL);
for (int i = 0; i< qMin(colors, m_colormap.size()); i++) {
QRgb color = m_colormap[i];
cmap->Colors[i].Blue = qBlue(color);
cmap->Colors[i].Green = qGreen(color);
cmap->Colors[i].Red = qRed(color);
}
retrn = EGifPutScreenDesc(fileType, image->width(), image->height(), 8, 0, cmap);
GifFreeMapObject(cmap);
char nameExtension[11] = { 'N','E','T','S','C','A','P','E','2','.','0' };
char loopExtension[3] = { 1, 0, 0 };
retrn = EGifPutExtensionLeader(fileType, 0xFF);
retrn = EGifPutExtensionBlock(fileType, 11, &nameExtension);
retrn = EGifPutExtensionBlock(fileType, 3, &loopExtension);
retrn = EGifPutExtensionTrailer(fileType);
retrn = EGifPutComment(fileType, "Boat Scenario http://boats.berlios.de");
char gifExtension[4] = { 0, 8, 0, 0 };
foreach (image, imageList) {
if (image == imageList.last()) {
gifExtension[1] = 0;
gifExtension[2] = 2;
}
retrn = EGifPutExtension(fileType, 0xF9, 4, &gifExtension);
retrn = EGifPutImageDesc(fileType, 0, 0, image->width(), image->height(), 0, NULL);
for (int i = 0; i < image->height(); i++) {
retrn &= EGifPutLine(fileType, (GifPixelType*)image->scanLine(i), image->width());
}
}
retrn = EGifCloseFile(fileType, &retrn);
return true;
}
boats-201908/gifwriter.h 0000664 0000000 0000000 00000002540 13530327553 0015111 0 ustar 00root root 0000000 0000000 //
// C++ Interface: gifwriter
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef GIFWRITER_H
#define GIFWRITER_H
#include
#include
#include
class GifWriter {
public:
GifWriter();
void setDevice (QIODevice *device) { m_device = device; }
QIODevice *device() const { return m_device; }
void setColorMap(QImage &image) { m_colormap = image.colorTable(); }
QVector colormap() const { return m_colormap; }
bool write(QList imageList);
int writeData(const GifByteType *bytes, int size);
private:
QIODevice *m_device;
QVector m_colormap;
};
#endif // GIFWRITER_H
boats-201908/graphicsview/ 0000775 0000000 0000000 00000000000 13530327553 0015430 5 ustar 00root root 0000000 0000000 boats-201908/graphicsview/arrow.cpp 0000664 0000000 0000000 00000006300 13530327553 0017265 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: ArrowGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "arrow.h"
#include "commontypes.h"
#include "situationscene.h"
#include "windmodel.h"
#include
#include
#include
#include
extern int debugLevel;
ArrowGraphicsItem::ArrowGraphicsItem(WindModel *wind, QGraphicsItem *parent)
: QGraphicsItem(parent),
m_wind(wind) {
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setVisible(wind->visible());
setPosition(wind->position());
setZValue(0);
m_path.moveTo(-15,-15);
m_path.lineTo(15,-15);
m_path.lineTo(15,0);
m_path.lineTo(25,0);
m_path.lineTo(0,17);
m_path.lineTo(-25,0);
m_path.lineTo(-15,0);
m_path.lineTo(-15,-15);
connect(wind, SIGNAL(windVisibleChanged(bool)),
this, SLOT(deleteItem(bool)));
connect(wind, SIGNAL(positionChanged(QPointF)),
this, SLOT(setPosition(QPointF)));
connect(wind, SIGNAL(directionChanged(qreal)),
this, SLOT(setHeading(qreal)));
connect(wind, SIGNAL(windReset()),
this, SLOT(resetArrow()));
}
ArrowGraphicsItem::~ArrowGraphicsItem() {}
void ArrowGraphicsItem::resetArrow() {
setHeading(m_wind->windAt(0));
}
void ArrowGraphicsItem::setHeading(qreal value) {
m_angle = value;
prepareGeometryChange();
setRotation(m_angle);
update();
}
void ArrowGraphicsItem::setPosition(QPointF position) {
prepareGeometryChange();
setPos(position);
update();
}
void ArrowGraphicsItem::deleteItem(bool visible) {
if(!visible) {
if (debugLevel & 1 << VIEW) std::cout << "deleting ArrowGraphicsItem for model" << m_wind << std::endl;
scene()->removeItem(this);
delete this;
}
}
QRectF ArrowGraphicsItem::boundingRect() const {
return QRectF(-25,-15,50,32);
}
QPainterPath ArrowGraphicsItem::shape() const {
return m_path;
}
void ArrowGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Q_UNUSED(option);
Q_UNUSED(widget);
if (isSelected())
painter->setPen(Qt::red);
else
painter->setPen(Qt::black);
painter->setBrush(QColor(191,191,255,255));
painter->drawPath(m_path);
QString label = tr("Wind");
painter->setPen(Qt::black);
painter->drawText(QRectF(-15,-15,30,15),Qt::AlignCenter,label);
}
int ArrowGraphicsItem::type() const {
return ARROW_TYPE;
}
boats-201908/graphicsview/arrow.h 0000664 0000000 0000000 00000004074 13530327553 0016740 0 ustar 00root root 0000000 0000000 //
// C++ Interface: ArrowGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef ARROW_H
#define ARROW_H
#include
#include
#include
class WindModel;
/**
\class ArrowGraphicsItem
\brief the QGraphicsItem for a wind Arrow
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the representation of an arrow on a
SituationView.
\sa SituationView, SituationScene, SituationModel, WindModel
*/
class ArrowGraphicsItem : public QObject, public QGraphicsItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
public:
ArrowGraphicsItem(WindModel *wind = 0, QGraphicsItem *parent = 0);
~ArrowGraphicsItem();
virtual QRectF boundingRect() const;
virtual QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
virtual int type() const;
public slots:
void resetArrow();
void setHeading(qreal value);
void setPosition(QPointF position);
void deleteItem(bool visible);
private:
WindModel *m_wind;
/// \a m_angle holds the angle of the Arrow
qreal m_angle;
QPainterPath m_path;
};
#endif
boats-201908/graphicsview/boat.cpp 0000664 0000000 0000000 00000065104 13530327553 0017067 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: BoatGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "boat.h"
#include "commontypes.h"
#include "situationscene.h"
#include "situationmodel.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include
#include
#include
#include
extern int debugLevel;
BoatGraphicsItem::BoatGraphicsItem(BoatModel *boat, QGraphicsItem *parent)
: QGraphicsItem(parent),
m_boat(boat),
m_angle(0),
m_sail(new SailGraphicsItem(boat, this)),
m_jib(new SailGraphicsItem(boat, this)),
m_spin(new SpinnakerGraphicsItem(boat, this)),
m_genn(new GennakerGraphicsItem(boat, this)),
m_hasSpin(false),
m_hasGenn(false),
m_overlap(Boats::none),
m_overlapLine(new QGraphicsLineItem(this)),
m_color(boat->track()->color()),
m_flag(Boats::noFlag),
m_flagRect(new FlagGraphicsItem(this)),
m_hidden(false),
m_bubble(new BubbleGraphicsItem(m_boat, this)),
m_series(Boats::unknown),
m_order(0),
m_numberPath(new QGraphicsPathItem(this)),
m_laylines(new LaylinesGraphicsItem(boat, this)) {
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setBoundingRegionGranularity(1);
m_numberPath->setZValue(1);
m_flagRect->setZValue(2);
m_sail->setZValue(3);
m_jib->setZValue(4);
m_spin->setZValue(5);
m_genn->setZValue(5); // Make this same as for spinnaker on basis that a boat will have one or other of these, not both
m_bubble->setZValue(6);
m_numberPath->setBrush(QBrush(Qt::black));
QPen dashPen(Qt::CustomDashLine);
QVector dashes;
dashes << 5 << 5;
dashPen.setDashPattern(dashes);
m_overlapLine->setPen(dashPen);
setSeries(boat->track()->series());
setHeading(boat->heading());
setPos(boat->position());
setOrder(boat->order());
setDim(boat->dim());
m_sail->setSailAngle(m_boat->trimmedSailAngle());
m_jib->setSailAngle(m_boat->trimmedJibAngle());
m_spin->setHeading(m_boat->heading());
m_spin->setSailAngle(m_boat->trimmedSpinAngle());
m_genn->setSailAngle(m_boat->trimmedGennAngle()); // Use spinTrim() for both spinnaker and gennaker
setSpin(boat->spin());
setOverlap(boat->overlap());
setDisplayFlag(boat->flag());
setHidden(boat->hidden());
connect(boat, SIGNAL(headingChanged(qreal)),
this, SLOT(setHeading(qreal)));
connect(boat, SIGNAL(headingChanged(qreal)),
m_spin, SLOT(setHeading(qreal)));
connect(boat, SIGNAL(positionChanged(QPointF)),
this, SLOT(setPosition(QPointF)));
connect(boat, SIGNAL(trimmedSailAngleChanged(qreal)),
m_sail, SLOT(setSailAngle(qreal)));
connect(boat, SIGNAL(trimmedJibAngleChanged(qreal)),
m_jib, SLOT(setSailAngle(qreal)));
connect(boat, SIGNAL(spinChanged(bool)),
this, SLOT(setSpin(bool)));
connect(boat, SIGNAL(trimmedSpinAngleChanged(qreal)),
m_spin, SLOT(setSailAngle(qreal)));
connect(boat, SIGNAL(trimmedGennAngleChanged(qreal)),
m_genn, SLOT(setSailAngle(qreal)));
connect(boat, SIGNAL(orderChanged(int)),
this, SLOT(setOrder(int)));
connect(boat, SIGNAL(overlapChanged(Boats::Overlaps)),
this, SLOT(setOverlap(Boats::Overlaps)));
connect(boat, SIGNAL(flagChanged(Boats::Flag)),
this, SLOT(setDisplayFlag(Boats::Flag)));
connect(boat, SIGNAL(hiddenChanged(bool)),
this, SLOT(setHidden(bool)));
connect(boat, SIGNAL(dimChanged(int)),
this, SLOT(setDim(int)));
connect(boat->track(), SIGNAL(colorChanged(QColor)),
this, SLOT(setColor(QColor)));
connect(boat->track(), SIGNAL(seriesChanged(Boats::Series)),
this, SLOT(setSeries(Boats::Series)));
connect(boat->situation(), SIGNAL(boatRemoved(BoatModel*)),
this, SLOT(deleteItem(BoatModel*)));
connect(boat->track(), SIGNAL(trackSelected(bool)),
this, SLOT(setSelected(bool)));
}
BoatGraphicsItem::~BoatGraphicsItem() {}
void BoatGraphicsItem::setHeading(qreal value) {
if (m_angle != value) {
m_angle = value;
QTransform rotation;
rotation.rotate(m_angle),
setTransform(rotation, false);
}
}
void BoatGraphicsItem::setPosition(QPointF position) {
if (pos() != position) {
setPos(position);
update();
}
}
void BoatGraphicsItem::setSpin(bool value) {
m_spin->setVisible(m_hasSpin && value);
m_genn->setVisible(m_hasGenn && value);
}
void BoatGraphicsItem::setOrder(int value) {
m_order = value;
if (m_order && m_numberSize) {
QString number = QString::number(m_order);
QFont numberFont;
numberFont.setPointSize(m_numberSize);
QFontMetrics fm(numberFont);
QPainterPath fpath;
fpath.addText(-fm.width(number)/2.0, 0, numberFont, number);
m_numberPath->setPath(fpath);
setZValue(m_order);
} else {
m_numberPath->setPath(QPainterPath());
setZValue(boat()->track()->size()+1);
}
update();
}
void BoatGraphicsItem::setOverlap(Boats::Overlaps value) {
if (m_overlap != value) {
m_overlap = value;
setOverlapLine();
}
}
void BoatGraphicsItem::setOverlapLine() {
qreal size = Boats::seriesSizeList()[m_series];
QLineF line;
line.setP1(QPointF(m_border, size/2));
line.setP2(QPointF(-m_border, size/2));
if (m_overlap == Boats::none) {
m_overlapLine->setVisible(false);
} else {
if (m_overlap & Boats::starboard) {
line.setP2(QPointF(m_border + size, size/2));
}
if (m_overlap & Boats::port) {
line.setP1(QPointF(-m_border - size, size/2));
}
m_overlapLine->setVisible(!m_hidden && true);
m_overlapLine->setLine(line);
}
}
void BoatGraphicsItem::setDisplayFlag(Boats::Flag value) {
m_flag = value;
m_flagRect->setDisplayFlag(m_flag);
if (m_flag == Boats::noFlag) {
m_flagRect->setVisible(false);
} else {
m_flagRect->setVisible(!m_hidden && true);
}
}
void BoatGraphicsItem::setHidden(bool value) {
prepareGeometryChange();
m_hidden = value;
if (m_hidden) {
m_sail->setVisible(false);
m_jib->setVisible(false);
m_spin->setVisible(false);
m_genn->setVisible(false);
m_overlapLine->setVisible(false);
m_flagRect->setVisible(false);
m_bubble->setVisible(false);
m_numberPath->setVisible(false);
m_laylines->setVisible(false);
} else {
m_sail->setVisible(true);
m_jib->setVisible(true);
m_spin->setVisible(boat()->spin());
m_genn->setVisible(boat()->spin());
m_overlapLine->setVisible(m_overlap != Boats::none);
m_flagRect->setVisible(m_flag != Boats::noFlag);
m_bubble->setVisible(!boat()->text().isEmpty());
m_numberPath->setVisible(true);
m_laylines->setVisible(boat()->laylines());
}
}
void BoatGraphicsItem::setColor(QColor value) {
if (m_color != value) {
int alpha = m_color.alpha();
m_color = value;
m_color.setAlpha(alpha);
update();
}
}
void BoatGraphicsItem::setDim(int value) {
m_color.setAlpha(value);
if (value == 0 ) {
setVisible(false);
}
else {
setVisible(true);
if (value != 255) {
int maxSize = 0;
foreach (const TrackModel *track, boat()->situation()->tracks()) {
if (track->boats().size() > maxSize)
maxSize = track->boats().size() - 1;
}
setZValue(maxSize+1);
} else {
setZValue(boat()->order());
}
}
update();
}
void BoatGraphicsItem::setVisible(bool value) {
QGraphicsItem::setVisible(value);
}
void BoatGraphicsItem::setSeries(Boats::Series value) {
if (m_series != value) {
prepareGeometryChange();
m_series = value;
int posY = 0;
QRectF flagRect;
QPointF mast;
qreal sailSize = 0;
QPointF jibTackPos;
qreal jibSize = 0;
qreal spinSize = 0;
QPointF gennTackPos;
qreal gennPoleLength = 0;
qreal gennSize = 0;
qreal maxNormalSailAngle = 90;
qreal maxNormalJibAngle = 45;
qreal maxWithSpinSailAngle = 65;
qreal maxWithSpinJibAngle = 35;
QPainterPath path;
QRectF boundingRect = QRectF(-50, -50, 100, 100);
qreal border = 0;
switch (m_series) {
case Boats::keelboat:
case Boats::keelboatwithgenn:
m_numberSize = 12;
posY = 25;
flagRect = QRectF(-7.5, 30 , 15, 10);
mast = QPointF(0, -8.7);
sailSize = 41.5;
jibTackPos = QPointF(0,-50);
jibSize = 40;
if (m_series == Boats::keelboat) {
spinSize = 1.1 * sailSize;
} else {
spinSize = 0;
}
if (m_series == Boats::keelboatwithgenn) {
gennTackPos = QPointF(0,-80);
gennPoleLength = 30;
gennSize = 70;
maxWithSpinSailAngle = 40;
maxWithSpinJibAngle = 35;
} else {
gennSize = 0;
}
path.moveTo(0,-50);
path.cubicTo(20, 0, 18, 13, 10, 50);
path.lineTo(-10, 50);
path.cubicTo(-18, 13, -20, 0, 0, -50);
boundingRect = QRectF(-20, -50, 40, 100);
border = 10;
break;
case Boats::int49er:
m_numberSize = 7;
posY = 9;
flagRect = QRectF(-3, 13, 6, 4);
mast = QPointF(0, -2.5);
sailSize = 27.0;
jibTackPos = QPointF(0,-22.5);
jibSize = 19.0;
gennTackPos = QPointF(0,-42.5);
gennPoleLength = 18.5;
gennSize = 38.0;
maxWithSpinSailAngle = 30;
maxWithSpinJibAngle = 25;
path.moveTo(0,-24.0);
path.lineTo(-0.5,-24.0);
path.cubicTo(-1.5,-23.0,-6.5,-5.5,-7.5,1.5);
path.lineTo(-13.5,2.4);
path.quadTo(-14.0,2.5,-14,3.0);
path.lineTo(-14.0,24.0);
path.lineTo(-13.5,24.0);
path.lineTo(-12.5,21.0);
path.lineTo(-7.5,19.0);
path.lineTo(-5.0,22.0);
path.lineTo(5.0,22.0);
path.lineTo(7.5,19.0);
path.lineTo(12.5,21.0);
path.lineTo(13.5,24.0);
path.lineTo(14.0,24.0);
path.lineTo(14.0,3.0);
path.quadTo(14.0,2.5,13.5,2.4);
path.lineTo(7.5,1.5);
path.cubicTo(6.5,-5.5,1.5,-23,0.5,-24.0);
path.lineTo(0,-24.0);
boundingRect = QRectF(-14.0, -24.0, 28.0, 48.0);
border = 14.5;
break;
case Boats::rsfeva:
m_numberSize = 7;
posY = 10;
flagRect = QRectF(-3, 12 , 6, 4);
mast = QPointF(0, -5.8);
sailSize = 23.8;
jibTackPos = QPointF(0,-16.0);
jibSize = 11.2;
gennTackPos = QPointF(0,-27.2);
gennPoleLength = 9.1;
gennSize = 17.0;
maxWithSpinSailAngle = 40;
maxWithSpinJibAngle = 35;
path.moveTo(0,-18.2);
path.quadTo(0.2,-18.2,0.4,-18.0);
path.quadTo(7.1,-6.8,7.1,4.8);
path.quadTo(7.1,10.4,5.3,18.2);
path.lineTo(-5.3,18.2);
path.quadTo(-7.1,10.4,-7.1,4.8);
path.quadTo(-7.1,-6.8,-0.4,-18.0);
path.quadTo(-0.2,-18.2,0,-18.2);
boundingRect = QRectF(-7.1,-18.2,14.2,36.4);
border = 5.3;
break;
case Boats::int470:
m_numberSize = 7;
posY = 9;
flagRect = QRectF(-3, 13, 6, 4);
mast = QPointF(0, -7.5);
sailSize = 26.5;
jibTackPos = QPointF(0,-23.5);
jibSize = 0.6*sailSize;
spinSize = 19.0;
path.moveTo(0,-23.5);
path.cubicTo(0.8, -23.5, 8.5, -15.0, 8.5, 3.5);
path.quadTo(8.5, 12.5, 5.8, 23.5);
path.lineTo(-5.8,23.5);
path.quadTo(-8.5, 12.5, -8.5, 3.5);
path.cubicTo(-8.5, -15.0, -0.8, -23.5, 0, -23.5);
boundingRect = QRectF(-8.5,-23.5,17.0,47.0);
border = 5.8;
break;
case Boats::int420:
m_numberSize = 7;
posY = 9;
flagRect = QRectF(-3, 13, 6, 4);
mast = QPointF(0, -7.1);
sailSize = 24.0;
jibTackPos = QPointF(0,-21);
jibSize = 0.6*sailSize;
spinSize = 17.5;
path.moveTo(0,-21);
path.cubicTo(1.5, -21, 8.15, -12.5, 8.15, 3.3);
path.quadTo(8.15, 11.5, 5.7, 20);
path.quadTo(2.8, 21, 0, 21);
path.quadTo(-2.8, 21, -5.7, 20);
path.quadTo(-8.15, 11.5, -8.15, 3.3);
path.cubicTo(-8.15, -12.5, -1.5, -21, 0, -21);
boundingRect = QRectF(-8.15,-21,16.3,42);
border = 5.7;
break;
case Boats::int29er:
m_numberSize = 7;
posY = 9;
flagRect = QRectF(-3, 13, 6, 4);
mast = QPointF(0, -3.4);
sailSize = 20.5;
jibTackPos = QPointF(0,-20.5);
jibSize = 17.0;
gennTackPos = QPointF(0,-34.2);
gennPoleLength = 13.7;
gennSize = 30.8;
maxWithSpinSailAngle = 40;
maxWithSpinJibAngle = 35;
path.moveTo(0,-20.5);
path.lineTo(-0.5,-20.5);
path.cubicTo(-3.5,-10.25,-6.6,-1.1,-8.3,-0.5);
path.lineTo(-8.8,18);
path.lineTo(-4.4,20.5);
path.lineTo(4.4,20.5);
path.lineTo(8.8,18);
path.lineTo(8.3,-0.5);
path.cubicTo(6.6,-1.1,3.5,-10.25,0.5,-20.5);
path.lineTo(0,-20.5);
boundingRect = QRectF(-8.8, -20.5, 17.6, 41.0);
border = 4.4;
break;
case Boats::finn:
m_numberSize = 8;
posY = 11;
flagRect = QRectF(-3, 13, 6, 4);
mast = QPointF(0, -15.0);
sailSize = 33.3;
path.moveTo(0,-22.5);
path.quadTo(-7.35,-9.1,-7.35,5.1);
path.quadTo(-7.35,14.9,-4.9,22.5);
path.lineTo(4.9,22.5);
path.quadTo(7.35,14.9,7.35,5.1);
path.quadTo(7.35,-9.1,0,-22.5);
boundingRect = QRectF(-7.35,-22.5,14.7,45.0);
border = 4.9;
break;
case Boats::laser:
m_numberSize = 7;
posY = 10;
flagRect = QRectF(-3, 12 , 6, 4);
mast = QPointF(0, -8.7);
sailSize = 28.5;
path.moveTo(0,-20);
path.cubicTo(0.3, -19.7, 0.3, -20.0, 0.7, -19.7);
path.cubicTo(3.3, -14.3, 6.7, -3.3, 6.7, 4.7);
path.cubicTo(6.7, 11.0, 6.7, 14.3, 5.0, 20.0);
path.lineTo(-5.0, 20.0);
path.cubicTo(-6.7, 14.3, -6.7, 11.0, -6.7, 4.7);
path.cubicTo(-6.7, -3.3, -3.3, -14.3, -0.7, -19.7);
path.cubicTo(-0.3, -20.0, -0.3, -19.7, 0, -20);
boundingRect = QRectF(-6.7, -20, 13.4, 40);
border = 5;
break;
case Boats::firefly:
m_numberSize = 7;
posY = 10;
flagRect = QRectF(-3, 12 , 6, 4);
mast = QPointF(0, -6.5);
sailSize = 21.8;
jibTackPos = QPointF(0, -18.3);
jibSize = 14;
path.moveTo(0,-18.3);
path.cubicTo(3.7, -14.0, 7.6, -8.0, 7.6, 1.8);
path.cubicTo(7.6, 4.2, 7.6, 9.2, 4.9, 18.3);
path.lineTo(-4.9, 18.3);
path.cubicTo(-7.6, 9.2, -7.6, 4.2, -7.6, 1.8);
path.cubicTo(-7.6, -8.0, -3.7, -14.0, 0, -18.3);
boundingRect = QRectF(-7.6, -18.3, 15.2, 36.6);
border = 4.9;
break;
case Boats::topper:
m_numberSize = 7;
posY = 8;
flagRect = QRectF(-3, 10 , 6, 4);
mast = QPointF(0, -6.5);
sailSize = 23.5;
path.moveTo(0,-17);
path.cubicTo(2.4, -17.0, 2.8, -16.0, 3.7, -14.0);
path.cubicTo(4.6, -12.0, 5.8, -6.0, 5.8, -1.0);
path.cubicTo(5.8, 1.0, 5.8, 8, 4.4, 17.0);
path.lineTo(-4.4, 17.0);
path.cubicTo(-5.8, 8, -5.8, 1.0, -5.8, -1.0);
path.cubicTo(-5.8, -6.0, -4.6, -12.0, -3.7, -14.0);
path.cubicTo(-2.8, -16.0, -2.4, -17.0, 0, -17);
boundingRect = QRectF(-5.8, -17, 11.6, 34);
border = 4.4;
break;
case Boats::optimist:
m_numberSize = 6;
posY = 3;
flagRect = QRectF(-2.25, 5 , 4.5, 3);
mast = QPointF(0,-6.9);
sailSize = 16.5;
path.moveTo(0,-11.5);
path.cubicTo(1.5, -11.5, 1.7, -11.3, 2.9, -11.1);
path.cubicTo(3.6, -9.4, 5.6, -4.0, 5.6, 1.5);
path.cubicTo(5.6, 5.4, 5.0, 9.0, 4.6, 11.5);
path.lineTo(-4.6, 11.5);
path.cubicTo(-5.0, 9.0, -5.6, 5.4, -5.6, 1.5);
path.cubicTo(-5.6, -4.0, -3.6, -9.4, -2.9, -11.1);
path.cubicTo(-1.7, -11.3, -1.5, -11.5, 0, -11.5);
boundingRect = QRectF(-5.6, -11.5, 11.2, 23);
border = 4.6;
break;
case Boats::tornado:
m_numberSize = 10;
posY = 17;
flagRect = QRectF(-4.5, 17.5 , 9, 6);
mast = QPointF(0,0);
sailSize = 25.5;
maxNormalSailAngle = 20;
gennTackPos = QPointF(0,-40);
gennPoleLength = 40;
gennSize = 42;
maxWithSpinSailAngle = 20;
path.moveTo(0,0);
path.lineTo(10.7, 0);
path.cubicTo(11.2, -11.7, 12.2, -19.8, 13.2, -30.5);
path.cubicTo(14.7, -20.3, 15.3, -6.1, 15.3, 6.1);
path.cubicTo(15.3, 13.7, 14.7, 20.8, 14.7, 30.0);
path.cubicTo(13.7, 30.5, 13.7, 30.5, 12.7, 30.5);
path.cubicTo(12.2, 30.5, 12.2, 30.5, 10.7, 30.0);
path.lineTo(10.7, 23.9);
path.lineTo(-10.7, 23.9);
path.lineTo(-10.7, 30.0);
path.cubicTo(-12.2, 30.5, -12.2, 30.5, -12.7, 30.5);
path.cubicTo(-13.7, 30.5, -13.7, 30.5, -14.7, 30);
path.cubicTo(-14.7, 20.8, -15.3, 13.7, -15.3, 6.1);
path.cubicTo(-15.3, -6.1, -14.7, -20.3, -13.2, -30.5);
path.cubicTo(-12.2, -19.8, -11.2, -11.7, -10.7, 0);
path.lineTo(0, 0);
boundingRect = QRectF(-15.3, -30.5, 30.6, 61);
border = 14.7;
break;
case Boats::nacra17:
m_numberSize = 7;
posY = 14;
flagRect = QRectF(-3, 16, 6, 4);
mast = QPointF(0, 0);
sailSize = 20.95;
jibTackPos = QPointF(0,-15.05);
jibSize = 14.15;
gennTackPos = QPointF(0,-33.35);
gennPoleLength = 0;
gennSize = 33.65;
maxNormalSailAngle = 20;
maxNormalJibAngle = 20;
maxWithSpinSailAngle = 20;
maxWithSpinJibAngle = 20;
path.moveTo(0,-0.65);
path.lineTo(-8.95,-0.65);
path.quadTo(-8.95,-16.75,-10.95,-25.90);
path.quadTo(-12.95,-16.75,-12.95,-0.65);
path.quadTo(-12.95,21.90,-12.70,26.60);
path.lineTo(-9.20,26.60);
path.lineTo(-9.00,21.45);
path.lineTo(9.00,21.45);
path.lineTo(9.20,26.60);
path.lineTo(12.7,26.60);
path.quadTo(12.95,21.90,12.95,-0.65);
path.quadTo(12.95,-16.75,10.95,-25.90);
path.quadTo(8.95,-16.75,8.95,-0.65);
path.lineTo(0,-0.65);
path.lineTo(0,-33.35);
boundingRect = QRectF(-12.95,-33.35,25.90,59.95);
border = 12.70;
break;
case Boats::diam24:
m_numberSize = 10;
posY = 17;
flagRect = QRectF(-7.5, 17.5 , 15, 10);
mast = QPointF(0,0);
sailSize = 29;
jibTackPos = QPointF(0,-25);
jibSize = 23;
gennTackPos = QPointF(0,-37.1);
gennPoleLength = 0;
gennSize = 57.5;
maxNormalSailAngle = 20;
maxNormalJibAngle = 20;
maxWithSpinSailAngle = 20;
maxWithSpinJibAngle = 20;
path.moveTo(0,-37.1);
path.cubicTo(1.3,-25.7,3.3,-14.0,3.3,-2.7);
path.lineTo(23.4,-1.7);
path.cubicTo(23.1,-18.4,24.1,-28.7,25.7,-36.8);
path.cubicTo(29.7,-12.7,27.7,10.7,28.1,35.4);
path.lineTo(23.7,35.4);
path.lineTo(23.7,30.7);
path.lineTo(2.7,30.7);
path.lineTo(2.7,35.4);
path.lineTo(-2.7,35.4);
path.lineTo(-2.7,30.7);
path.lineTo(-23.7,30.7);
path.lineTo(-23.7,35.4);
path.lineTo(-28.1,35.4);
path.cubicTo(-27.7,10.7,-29.7,-12.7,-25.7,-36.8);
path.cubicTo(-24.1,-28.7,-23.1,-18.4,-23.4,-1.7);
path.lineTo(-3.3,-2.7);
path.cubicTo(-3.3,-14.0,-1.3,-25.7,0,-37.1);
boundingRect = QRectF(-29.7,-37.0,59.4,72.5);
border = 28.10;
break;
case Boats::startboat:
m_numberSize = 0;
flagRect = QRectF(-7.5, 30 , 15, 10);
path.moveTo(0,-50);
path.cubicTo(30, -20, 20, 30, 17, 50);
path.lineTo(-17, 50);
path.cubicTo(-20, 30, -30, -20, 0, -50);
path.addEllipse(-1, -10, 2, 2);
boundingRect = QRectF(-30, -50, 60, 100);
border = 17;
break;
case Boats::rib:
m_numberSize = 10;
posY = 10;
flagRect = QRectF(-5, 15 , 10, 6.7);
path.moveTo(0,-30);
path.cubicTo(6, -26, 12.1, -22.9, 12.4, -10.3);
path.lineTo(12.4, 23.5);
path.lineTo(8.9, 30);
path.lineTo(5.5, 23.5);
path.lineTo(-5.5, 23.5);
path.lineTo(-8.9, 30);
path.lineTo(-12.4, 23.5);
path.lineTo(-12.4, -10.3);
path.cubicTo(-12.1, -22.9, -6, -26, 0, -30);
boundingRect = QRectF(-12.4, -30, 24.8, 60);
border = 8.9;
default:
break;
}
m_hullPath = path;
m_boundingRect = boundingRect;
m_numberPath->setPos(0, posY);
m_flagRect->setRect(flagRect);
if (sailSize) {
m_boat->setMaxNormalSailAngle(maxNormalSailAngle);
m_boat->setMaxWithSpinSailAngle(maxWithSpinSailAngle);
m_sail->setPosition(mast);
m_sail->setSailSize(sailSize);
m_sail->setVisible(true);
} else {
m_sail->setVisible(false);
}
if (jibSize) {
m_boat->setMaxNormalJibAngle(maxNormalJibAngle);
m_boat->setMaxWithSpinJibAngle(maxWithSpinJibAngle);
m_jib->setPosition(jibTackPos);
m_jib->setSailSize(jibSize);
m_jib->setVisible(true);
} else {
m_jib->setVisible(false);
}
m_hasSpin = false;
m_hasGenn = false;
if (spinSize) {
m_hasSpin = true;
m_spin->setPosition(mast);
m_spin->setSailSize(spinSize);
m_spin->setVisible(m_boat->spin());
} else {
m_spin->setVisible(false);
}
if (gennSize) {
m_hasGenn = true;
m_genn->setPosition(gennTackPos);
m_genn->setPoleLength(gennPoleLength);
m_genn->setSailSize(gennSize);
m_genn->setVisible(m_boat->spin());
} else {
m_genn->setVisible(false);
}
m_boat->setHasSpin(m_hasSpin || m_hasGenn); // set setHasSpin true irrespective of type of spinnaker (is just used to control whether Toggle Spinnaker menu item is active)
m_border = border;
setOverlapLine();
setOrder(m_order);
update();
}
}
void BoatGraphicsItem::deleteItem(BoatModel *boat) {
if (boat == m_boat) {
if (debugLevel & 1 << VIEW) std::cout << "deleting boatGraphics for model" << m_boat << std::endl;
scene()->removeItem(this);
delete this;
}
}
void BoatGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
m_multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
m_trackSelect = (event->modifiers() & Qt::ShiftModifier) != 0;
bool selection = true;
if (m_multiSelect) {
selection = !isSelected();
}
if (m_trackSelect) {
m_boat->track()->setSelected(selection);
} else {
if (selection) {
m_boat->situation()->addSelectedBoat(m_boat);
} else {
m_boat->situation()->removeSelectedModel(m_boat);
}
setSelected(selection);
}
update();
}
void BoatGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
}
void BoatGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
}
void BoatGraphicsItem::setSelected(bool selected) {
QGraphicsItem::setSelected(selected);
}
QRectF BoatGraphicsItem::boundingRect() const {
if (m_hidden)
return QRectF(-3, -3, 6, 6);
else
return m_boundingRect;
}
QPainterPath BoatGraphicsItem::shape() const {
QPainterPath path;
path.addRegion(boundingRegion(QTransform()));
return path;
}
void BoatGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Q_UNUSED(option);
Q_UNUSED(widget);
if (isSelected())
painter->setPen(Qt::red);
else
painter->setPen(Qt::black);
painter->setBrush(m_color);
if (m_hidden)
painter->drawEllipse(-3, -3, 6, 6);
else
painter->drawPath(m_hullPath);
}
int BoatGraphicsItem::type() const {
return BOAT_TYPE;
}
boats-201908/graphicsview/boat.h 0000664 0000000 0000000 00000011662 13530327553 0016534 0 ustar 00root root 0000000 0000000 //
// C++ Interface: BoatGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BOAT_H
#define BOAT_H
#include "boats.h"
#include "sail.h"
#include "spinnaker.h"
#include "gennaker.h"
#include "flag.h"
#include "bubble.h"
#include "laylines.h"
#include
#include
#include
class BoatModel;
/**
\class BoatGraphicsItem
\brief the QGraphicsItem for a boat
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the representation of a BoatModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, BoatModel
*/
class BoatGraphicsItem : public QObject, public QGraphicsItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
public:
BoatGraphicsItem(BoatModel *boat, QGraphicsItem *parent = 0);
virtual ~BoatGraphicsItem();
BoatModel* boat() const { return m_boat; }
BubbleGraphicsItem* bubble() const { return m_bubble; }
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
virtual int type() const;
public slots:
void setHeading(qreal value);
void setPosition(QPointF position);
void setOrder(int value);
void setSpin(bool value);
void setOverlap(Boats::Overlaps value);
void setDisplayFlag(Boats::Flag value);
void setHidden(bool value);
void setColor(QColor value);
void setDim(int value);
void setVisible(bool value);
void setSeries(Boats::Series value);
void deleteItem(BoatModel *boat);
void setSelected(bool selected);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
void setOverlapLine();
/// \a m_boat holds the BoatModel being represented
BoatModel *m_boat;
/// \a m_hullPath holds the path for the hull
QPainterPath m_hullPath;
/// \a m_boundingRect holds the bounding rectangle for the boat
QRectF m_boundingRect;
/// \a m_angle holds the heading of the boat
qreal m_angle;
/// \a m_sail holds the sail that will be drawn
SailGraphicsItem *m_sail;
/// \a m_jib holds the jib
SailGraphicsItem *m_jib;
/// \a m_spin holds the spinnaker
SpinnakerGraphicsItem *m_spin;
/// \a m_genn holds the gennaker
GennakerGraphicsItem *m_genn;
/// \a m_hasSpin is true if boat has a spinnaker
bool m_hasSpin;
/// \a m_hasGenn is true if boat has a gennaker
bool m_hasGenn;
/// \a m_overlap holds whether an overlap line should be displayed
Boats::Overlaps m_overlap;
QGraphicsLineItem *m_overlapLine;
/// \a m_border holds the half-width of the boat at the transom
qreal m_border;
/// \a m_color holds the color of the TrackModel
QColor m_color;
/// \a m_flag holds the flag to display
Boats::Flag m_flag;
FlagGraphicsItem *m_flagRect;
/// \a m_hidden holds whether the hidden symbol should be displayed
bool m_hidden;
/// \a m_bubble holds the bubble to display
BubbleGraphicsItem *m_bubble;
/// \a m_series holds the series of the TrackModel
Boats::Series m_series;
/// \a m_order holds the stacking order in the TrackModel
int m_order;
/// \a m_numberPath holds the number path that will be drawn on the hull
QGraphicsPathItem *m_numberPath;
/// \a m_numberSize holds the font size of the number
int m_numberSize;
/// \a m_laylines holds the laylines for the boat
LaylinesGraphicsItem *m_laylines;
/// \a m_multiSelect is true if Ctrl-modified was in effect when mousePressEvent happened
bool m_multiSelect;
/// \a m_trackSelect is true if mousePressEvent is Shift-modified
bool m_trackSelect;
};
#endif
boats-201908/graphicsview/boatanimation.cpp 0000664 0000000 0000000 00000012377 13530327553 0020773 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: BoatAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2010 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include
#include
#include "boatanimation.h"
#include "headinganimation.h"
#include "situationmodel.h"
#include "splineanimation.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include "boat.h"
/**
Populates the internal lists of Positions and Headings function
of time
This method parses the path of the \a track, does some stalling
analysis and determines position and heading as a function of time.
It also gives the pale color to \a track boats, while keeping
original color for animation \a boat.
*/
BoatAnimation::BoatAnimation(TrackModel *track, BoatGraphicsItem *boat, int maxSize, QObject *parent)
: QParallelAnimationGroup(parent),
m_track(track),
m_boat(boat),
m_headingAnimation(new HeadingAnimation(boat->boat(), "heading")),
m_sailAngleAnimation(new HeadingAnimation(boat->boat(), "trimSailAngle")),
m_posAnimation(new QSequentialAnimationGroup),
m_maxSize(maxSize),
m_time(QTime::currentTime()) {
QPainterPath path = m_track->path();
int size = m_track->size() - 1;
if (size < 0) {
return;
}
m_boat->setOrder(0);
QPointF point = path.elementAt(0);
// setPosAt(0,point);
BoatModel *model = m_track->boats()[0];
m_headingAnimation->setDuration(2000*m_maxSize);
m_headingAnimation->setStartValue(model->heading());
m_sailAngleAnimation->setDuration(2000*m_maxSize);
m_sailAngleAnimation->setStartValue(model->trimmedSailAngle());
// through all boats of the track
for (int i=0; i< size; i++) {
qreal index = 0;
QPointF c1 = path.elementAt(i*3+1);
QPointF c2 = path.elementAt(i*3+2);
QPointF end = path.elementAt(i*3+3);
bool stalled = ((point == c1) || (c2 == end));
QPainterPath curve(point);
curve.cubicTo(c1,c2,end);
qreal length = curve.length();
float e = 8;
// through 8 intermediary points between 2 boats
for (int j=1; j<=e; j++) {
qreal percent = curve.percentAtLength(length*j/e);
index = (i*e+j)/(maxSize*e);
if (!stalled) {
m_headingAnimation->setKeyValueAt(index, fmod(360+90-curve.angleAtPercent(percent),360.0));
}
}
model = m_track->boats()[i+1];
if (stalled) {
m_headingAnimation->setKeyValueAt(index, model->heading());
}
m_sailAngleAnimation->setKeyValueAt(index, model->trimmedSailAngle());
SplineAnimation *splineAnimation = new SplineAnimation(m_boat->boat(), "pos", m_track->boats()[i]->path());
splineAnimation->setStartValue(point);
splineAnimation->setEndValue(end);
splineAnimation->setDuration(2000);
m_posAnimation->addAnimation(splineAnimation);
point = end;
}
// dim all track boats
foreach(BoatModel *boat, m_track->boats()) {
boat->setDim(true);
}
}
/**
Resets the color and List of BoatModels in the track
*/
BoatAnimation::~BoatAnimation() {
while (!m_boats.isEmpty()) {
m_track->addBoat(m_boats.last());
m_boats.pop_back();
}
// undim all track boats
foreach(BoatModel *boat, m_track->boats()) {
boat->setDim(false);
}
}
/**
Updates TrackModel and animation boat position and heading
at \a step time, with a rate limit of one refresh every 40ms
*/
void BoatAnimation::afterAnimationStep(qreal step) {
// limit update rate to 40ms
if ((m_time.elapsed() < 40) && (step != 0) && (step != 1)) {
return;
}
m_headingAnimation->setCurrentTime(step*2000*m_maxSize);
m_sailAngleAnimation->setCurrentTime(step*2000*m_maxSize);
m_posAnimation->setCurrentTime(step*2000*m_maxSize);
int index = floor(step * m_maxSize);
BoatModel *boat;
for (int i=m_track->size()-1; i > index; i--) {
boat = m_track->boats()[i];
m_boats.push_back(boat);
m_track->deleteBoat(boat);
}
if (!m_boats.isEmpty()) {
for (int i = m_track->size()-1; i < index; i++) {
m_track->addBoat(m_boats.last());
m_boats.pop_back();
}
}
if (index > m_track->size() - 1) {
return;
}
boat = m_track->boats()[index];
m_boat->boat()->setOverlap(boat->overlap());
m_boat->boat()->setFlag(boat->flag());
m_boat->boat()->setText(boat->text());
m_boat->boat()->setTextPosition(boat->textPosition());
m_boat->boat()->setSpin(boat->spin());
// trigger next update rate calculation
m_time.start();
}
boats-201908/graphicsview/boatanimation.h 0000664 0000000 0000000 00000004652 13530327553 0020435 0 ustar 00root root 0000000 0000000 //
// C++ Interface: BoatAnimation
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2010 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BOATANIMATION_H
#define BOATANIMATION_H
#include
#include
#include
class BoatGraphicsItem;
class TrackModel;
class BoatModel;
class HeadingAnimation;
/**
\class BoatAnimation
\brief The animation Item for a scenario
The class is the animation helper for a Scenario, according to the
Graphics View Framework.
It inherits QGraphicsItemAnimation and provides BoatGraphicsItem
specific animation features, like position and heading given a
time step.
It also does a rate limiting update for drawing as Windows platforms
suffer from that.
\sa SituationScene, SituationModel
*/
class BoatAnimation : public QParallelAnimationGroup {
public:
BoatAnimation(TrackModel *track, BoatGraphicsItem *boat, int maxSize, QObject *parent = 0);
~BoatAnimation();
BoatGraphicsItem *boat() const {return m_boat; }
protected:
virtual void afterAnimationStep(qreal step);
private:
/// \a m_track holds the reference to the track
TrackModel *m_track;
/// \a m_boats holds the List of boats hidden during animation
QList m_boats;
/// \a m_boat holds the reference to the animation BoatGraphicsItem
BoatGraphicsItem *m_boat;
HeadingAnimation *m_headingAnimation;
HeadingAnimation *m_sailAngleAnimation;
QSequentialAnimationGroup *m_posAnimation;
/// \a m_maxSize holds the maximum track size of the scenario
int m_maxSize;
/// \a m_time holds the timer used for movement filtering
QTime m_time;
};
#endif
boats-201908/graphicsview/bubble.cpp 0000664 0000000 0000000 00000012601 13530327553 0017367 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: BubbleGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2010 Thibaut GRIDEL
//
// 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 .
//
//
#include "bubble.h"
#include "commontypes.h"
#include "situationmodel.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include
#include
#include
#include
extern int debugLevel;
BubbleGraphicsItem::BubbleGraphicsItem(PositionModel *model, QGraphicsItem *parent)
: QGraphicsTextItem(parent),
m_model(model),
m_tail(new QGraphicsPolygonItem(parent)) {
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
m_tail->setZValue(0);
m_tail->setBrush(Qt::white);
updateText(model->text());
setPosition(model->textPosition());
connect(document(), SIGNAL(contentsChanged()),
this, SLOT(setText()));
if (m_model->inherits("BoatModel")) {
BoatModel *boat = static_cast (m_model);
connect(boat, SIGNAL(headingChanged(qreal)),
this, SLOT(setTail()));
}
connect(model, SIGNAL(textChanged(QString)),
this, SLOT(updateText(QString)));
connect(model, SIGNAL(textPositionChanged(QPointF)),
this, SLOT(setPosition(QPointF)));
}
BubbleGraphicsItem::~BubbleGraphicsItem() {}
/// update view from model changes
void BubbleGraphicsItem::updateText(QString value) {
setVisible(!value.isEmpty());
if (document()->toPlainText() != value)
setPlainText(value);
setTail();
}
/// set model from control changes
void BubbleGraphicsItem::setText() {
if (m_model->situation()) {
if (document()->toPlainText() != m_model->text()) {
m_model->situation()->addSelectedModel(m_model);
m_model->situation()->setText(document()->toPlainText());
setVisible(!document()->toPlainText().isEmpty());
setTail();
}
}
}
/// update view from model changes
void BubbleGraphicsItem::setPosition(QPointF position) {
setPos(position);
setTail();
update();
}
void BubbleGraphicsItem::setTail() {
//centerx,y is the centre of the text relative to pos()
double centerx = boundingRect().width()/2 - 4;
double centery = boundingRect().height()/2 - 4;
double a = 0;
if (BoatModel *boat = dynamic_cast (m_model)) {
a = -boat->heading();
// set the transform to have horizontal text
setTransformOriginPoint(centerx, centery); // Rotate about centre of text rather than top left corner
setRotation(a);
}
// x,y is the center of the text
double x = pos().x() + centerx;
double y = pos().y() + centery;
// t is a factor for the width of the tail
double t = boundingRect().height()/5;
// q is the angle of the tail
double q = atan2(y, x);
QPolygonF polygon;
polygon << QPointF(x,y) << QPointF(x - t*sin(q), y + t*cos(q))
<< QPointF(x/4, y/4) << QPointF(x + t*sin(q), y - t*cos(q));
m_tail->setPolygon(polygon);
}
QRectF BubbleGraphicsItem::boundingRect() const {
return QGraphicsTextItem::boundingRect().adjusted(-4, -4, 4, 4);
}
void BubbleGraphicsItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
QPainterPath path;
path.addRoundedRect(QGraphicsTextItem::boundingRect().adjusted(-2, -2, 2, 2),
15.0, 15.0, Qt::RelativeSize);
painter->save();
painter->setBrush(Qt::white);
painter->drawPath(path);
painter->restore();
QGraphicsTextItem::paint(painter, option, widget);
}
void BubbleGraphicsItem::setVisible(bool visible) {
QGraphicsItem::setVisible(visible);
m_tail->setVisible(visible);
}
void BubbleGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
m_clickTime.start();
QGraphicsTextItem::mousePressEvent(event);
m_fromPosition = m_model->textPosition();
}
void BubbleGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QGraphicsTextItem::mouseMoveEvent(event);
setTail();
}
void BubbleGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
bool click = (m_clickTime.elapsed() < 250);
if (click) {
setTextInteractionFlags(Qt::TextEditorInteraction);
setFocus(Qt::MouseFocusReason);
} else {
setTextInteractionFlags(Qt::NoTextInteraction);
}
QGraphicsTextItem::mouseReleaseEvent(event);
if (pos() != m_fromPosition) {
m_model->situation()->addSelectedModel(m_model);
m_model->situation()->moveText(pos());
}
}
void BubbleGraphicsItem::focusOutEvent(QFocusEvent *event) {
setTextInteractionFlags(Qt::NoTextInteraction);
QGraphicsTextItem::focusOutEvent(event);
}
boats-201908/graphicsview/bubble.h 0000664 0000000 0000000 00000005064 13530327553 0017041 0 ustar 00root root 0000000 0000000 //
// C++ Interface: BubbleGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009-2010 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef BUBBLE_H
#define BUBBLE_H
#include "boats.h"
#include
#include
#include
class PositionModel;
/**
\class BubbleGraphicsItem
\brief the QGraphicsItem for a bubble
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the text representation of a PositionModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, BoatModel
*/
class BubbleGraphicsItem : public QGraphicsTextItem {
Q_OBJECT
public:
BubbleGraphicsItem(PositionModel *model, QGraphicsItem *parent = 0);
virtual ~BubbleGraphicsItem();
PositionModel* model() const { return m_model; }
QRectF boundingRect() const;
void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setVisible(bool visible);
public slots:
void updateText(QString value);
void setText();
void setPosition(QPointF position);
void setTail();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void focusOutEvent (QFocusEvent *event);
private:
/// \a m_model holds the PositionModel being represented
PositionModel *m_model;
/// \a m_fromPosition holds the position of the mousePress
QPointF m_fromPosition;
/// \a m_tail holds the leader line to the boat
QGraphicsPolygonItem *m_tail;
QTime m_clickTime;
};
#endif // BUBBLE_H
boats-201908/graphicsview/flag.cpp 0000664 0000000 0000000 00000006140 13530327553 0017046 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: FlagGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#include "flag.h"
#include "commontypes.h"
#include
FlagGraphicsItem::FlagGraphicsItem(QGraphicsItem *parent)
: QGraphicsItem(parent) {
}
FlagGraphicsItem::~FlagGraphicsItem() {}
QRectF FlagGraphicsItem::boundingRect() const {
return m_rect;
}
QPainterPath FlagGraphicsItem::shape() const {
QPainterPath path;
path.addRect(m_rect);
return path;
}
void FlagGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Q_UNUSED(option);
Q_UNUSED(widget);
switch (m_flag) {
case Boats::Y: {
painter->setBrush(Qt::red);
painter->drawRect(m_rect);
painter->translate(m_rect.left(), m_rect.top());
QPolygonF polygon;
qreal sixth = m_rect.width() / 6;
qreal height = m_rect.height();
polygon << QPointF(0, 0) << QPointF(sixth, 0) << QPointF(-3*sixth, height) << QPointF(-4*sixth, height);
painter->setPen(Qt::transparent);
painter->setBrush(Qt::yellow);
for (int i=0; i<5; i++) {
painter->drawPolygon(polygon.intersected(QPolygonF(QRectF(0, 0, m_rect.width(), m_rect.height()))));
polygon.translate(2*sixth, 0);
}
break;
}
case Boats::Red:
painter->setBrush(Qt::red);
painter->drawRect(m_rect);
break;
case Boats::Yellow:
painter->setBrush(Qt::yellow);
painter->drawRect(m_rect);
break;
case Boats::Blue:
painter->setBrush(Qt::blue);
painter->drawRect(m_rect);
break;
case Boats::Green: {
painter->setBrush(Qt::white);
painter->drawRect(m_rect);
painter->translate(m_rect.left(), m_rect.top());
QPolygonF polygon;
qreal halfw = m_rect.width() / 2;
qreal halfh = m_rect.height() / 2;
polygon << QPointF(0, 0) << QPointF(halfw, 0) << QPointF(halfw, halfh) << QPointF(0, halfh);
painter->setBrush(Qt::green);
painter->drawPolygon(polygon);
polygon.translate(halfw, halfh);
painter->drawPolygon(polygon);
break;
}
default:
break;
}
}
boats-201908/graphicsview/flag.h 0000664 0000000 0000000 00000003447 13530327553 0016522 0 ustar 00root root 0000000 0000000 //
// C++ Interface: FlagGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef FLAG_H
#define FLAG_H
#include "boats.h"
#include
/**
\class FlagGraphicsItem
\brief the QGraphicsItem for a flag
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework. It displays the
representation of a Flag on a SituationView.
\sa SituationView, SituationScene,
*/
class FlagGraphicsItem : public QGraphicsItem {
public:
FlagGraphicsItem(QGraphicsItem *parent = 0);
virtual ~FlagGraphicsItem();
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setDisplayFlag(Boats::Flag value) {m_flag = value; update();}
void setRect(QRectF value) { prepareGeometryChange(); m_rect = value; update();}
private:
/// \a m_flag holds the flag to display
Boats::Flag m_flag;
QRectF m_rect;
};
#endif // FLAG_H
boats-201908/graphicsview/gennaker.cpp 0000664 0000000 0000000 00000007472 13530327553 0017740 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: GennakerGraphicsItem
//
// Description:
//
//
// Author: Graham Louth
//
// Copyright (c) 2013 Graham Louth
//
// 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 .
//
//
#include "gennaker.h"
#include "commontypes.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include
#include
#include
extern int debugLevel;
GennakerGraphicsItem::GennakerGraphicsItem(BoatModel *boat, QGraphicsItem *parent)
: SailGraphicsItem(boat, parent),
m_pole(new QGraphicsLineItem(parent)) { //NB boat as parent to avoid need to offset sail rotatation for pole
}
GennakerGraphicsItem::~GennakerGraphicsItem() {}
void GennakerGraphicsItem::setSailSize(qreal sailSize) {
m_sailSize = sailSize;
QPainterPath sailPathStalled;
sailPathStalled.cubicTo(.1 * sailSize, .2 * sailSize, .1 * sailSize, .2 * sailSize, 0, .3 * sailSize);
sailPathStalled.cubicTo(-.1 * sailSize, .4 * sailSize, -.1 * sailSize, .4 * sailSize, 0, .5 * sailSize);
sailPathStalled.cubicTo(.1 * sailSize, .6 * sailSize, .1 * sailSize, .6 * sailSize, 0, .7 * sailSize);
sailPathStalled.cubicTo(-.1 * sailSize, .8 * sailSize, -.1 * sailSize, .8 * sailSize, 0, sailSize);
sailPathStalled.lineTo(0, 0);
m_sailPathStalled = sailPathStalled;
QPainterPath sailPathStarboard;
sailPathStarboard.cubicTo(.35 * sailSize, .3 * sailSize, .28 * sailSize, .6 * sailSize, 0, sailSize);
sailPathStarboard.cubicTo(.2 * sailSize, .6 * sailSize, .25 * sailSize, .3 * sailSize, 0, 0);
m_sailPathStarboard = sailPathStarboard;
QPainterPath sailPathPort;
sailPathPort.cubicTo(-.35 * sailSize, .3 * sailSize, -.28 * sailSize, .6 * sailSize, 0, sailSize);
sailPathPort.cubicTo(-.2 * sailSize, .6 * sailSize, -.25 * sailSize, .3 * sailSize, 0, 0);
m_sailPathPort = sailPathPort;
setSailAngle(m_sailAngle);
}
void GennakerGraphicsItem::setPoleLength(qreal length) {
m_pole->setLine(0,0,0,length);
QPen polePen;
polePen.setWidthF(0.5);
polePen.setCapStyle(Qt::FlatCap);
m_pole->setPen(polePen);
}
void GennakerGraphicsItem::setPosition(QPointF position) {
if (pos() != position) {
setPos(position);
m_pole->setPos(position);
update();
}
}
void GennakerGraphicsItem::setVisible(bool visibility) {
if (isVisible() != visibility) {
SailGraphicsItem::setVisible(visibility);
m_pole->setVisible(visibility);
update();
}
}
/// calculate a sail incidence angle, corrected with user trimming
void GennakerGraphicsItem::setSailAngle(qreal value) {
m_sailAngle = value;
qreal angle = fmod(m_boat->heading() - m_boat->wind() - m_sailAngle +360, 360);
if(angle < 0) angle +=360;
if ((angle < 55 || angle > 305 || (angle > 170 && angle < 190)) && path() != m_sailPathStalled) {
setPath(m_sailPathStalled);
} else if (angle >= 55 && angle <= 170 && path() != m_sailPathStarboard) {
setPath(m_sailPathStarboard);
} else if (angle >= 190 && angle <= 305 && path() != m_sailPathPort) {
setPath(m_sailPathPort);
}
QTransform transform;
transform.rotate(- m_sailAngle);
setTransform(transform, false);
}
boats-201908/graphicsview/gennaker.h 0000664 0000000 0000000 00000003507 13530327553 0017400 0 ustar 00root root 0000000 0000000 //
// C++ Interface: GennakerGraphicsItem
//
// Description:
//
//
// Author: Graham Louth
//
// Copyright (c) 2013 Graham Louth
//
// 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 .
//
//
#ifndef GENNAKER_H
#define GENNAKER_H
#include "boats.h"
#include "sail.h"
#include
#include
class BoatModel;
/**
\class GennakerGraphicsItem
\brief the QGraphicsItem for a gennaker
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsPathItem for Item framework and QObject for slot and
signal framework. It displays the sail representation of a BoatModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, BoatModel
*/
class GennakerGraphicsItem : public SailGraphicsItem {
Q_OBJECT
public:
GennakerGraphicsItem(BoatModel *boat, QGraphicsItem *parent = 0);
virtual ~GennakerGraphicsItem();
void setSailSize(qreal size);
void setPoleLength(qreal length);
void setPosition(QPointF position);
void setVisible(bool visibility);
public slots:
void setSailAngle(qreal value);
private:
QGraphicsLineItem *m_pole;
};
#endif // GENNAKER_H
boats-201908/graphicsview/graphicsview.pri 0000664 0000000 0000000 00000001303 13530327553 0020634 0 ustar 00root root 0000000 0000000 INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += \
$$PWD/arrow.h \
$$PWD/boat.h \
$$PWD/bubble.h \
$$PWD/flag.h \
$$PWD/laylines.h \
$$PWD/mark.h \
$$PWD/point.h \
$$PWD/polyline.h \
$$PWD/sail.h \
$$PWD/situationscene.h \
$$PWD/situationview.h \
$$PWD/spinnaker.h \
$$PWD/gennaker.h \
$$PWD/track.h
SOURCES += \
$$PWD/arrow.cpp \
$$PWD/boat.cpp \
$$PWD/bubble.cpp \
$$PWD/flag.cpp \
$$PWD/laylines.cpp \
$$PWD/mark.cpp \
$$PWD/point.cpp \
$$PWD/polyline.cpp \
$$PWD/sail.cpp \
$$PWD/situationscene.cpp \
$$PWD/situationview.cpp \
$$PWD/spinnaker.cpp \
$$PWD/gennaker.cpp \
$$PWD/track.cpp
boats-201908/graphicsview/laylines.cpp 0000664 0000000 0000000 00000007332 13530327553 0017761 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: LaylinesGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "laylines.h"
#include "commontypes.h"
#include "situationmodel.h"
#include
#include
#include
extern int debugLevel;
LaylinesGraphicsItem::LaylinesGraphicsItem(PositionModel *model, QGraphicsItem *parent)
: QGraphicsPathItem(parent),
m_model(model),
m_length(model->situation()->situationLength()),
m_boatLength(Boats::seriesSizeList()[model->situation()->situationSeries()]),
m_laylineAngle(model->situation()->laylineAngle()),
m_heading(model->heading()) {
setFlag(QGraphicsItem::ItemStacksBehindParent);
setPen(Qt::DashLine);
updatePath();
setVisible(m_model->laylines());
setWind(model->wind());
connect(m_model, SIGNAL(laylinesChanged(bool)),
this, SLOT(setVisible(bool)));
connect(m_model, SIGNAL(headingChanged(qreal)),
this, SLOT(setHeading(qreal)));
connect(m_model, SIGNAL(windChanged(qreal)),
this, SLOT(setWind(qreal)));
connect(m_model->situation(), SIGNAL(lengthChanged(int)),
this, SLOT(setLength(int)));
connect(m_model->situation(), SIGNAL(laylineChanged(int)),
this, SLOT(setLaylineAngle(int)));
connect(m_model->situation(), SIGNAL(seriesChanged(int)),
this, SLOT(setSeries(int)));
}
LaylinesGraphicsItem::~LaylinesGraphicsItem() {}
void LaylinesGraphicsItem::setLength(int value) {
if (m_length != value) {
prepareGeometryChange();
m_length = value;
updatePath();
}
}
void LaylinesGraphicsItem::setSeries(int value) {
int boatLength = Boats::seriesSizeList()[value];
if (m_boatLength != boatLength) {
m_boatLength = boatLength;
updatePath();
}
}
void LaylinesGraphicsItem::setLaylineAngle(int value) {
if (m_laylineAngle != value) {
m_laylineAngle = value;
updatePath();
}
}
void LaylinesGraphicsItem::setHeading(qreal value) {
if(m_heading != value) {
m_heading = value;
QTransform transform;
transform.rotate(m_wind - m_heading);
setTransform(transform, false);
}
}
void LaylinesGraphicsItem::setWind(qreal value) {
if(m_wind != value) {
m_wind = value;
QTransform transform;
transform.rotate(m_wind - m_heading);
setTransform(transform, false);
}
}
void LaylinesGraphicsItem::setVisible(bool visible) {
QGraphicsItem::setVisible(visible);
// hack for performance issues. It seems an invisible path costs much
if(m_visible != visible) {
m_visible = visible;
updatePath();
}
}
void LaylinesGraphicsItem::updatePath() {
QPainterPath path;
int r = 1.25 * m_length * m_boatLength;
qreal theta = m_laylineAngle * M_PI /180;
if(m_visible) {
path.lineTo(r*sin(theta), r*cos(theta)); // starboard layline
path.moveTo(0, 0);
path.lineTo(-r*sin(theta), r*cos(theta)); // port layline
}
setPath(path);
}
boats-201908/graphicsview/laylines.h 0000664 0000000 0000000 00000004460 13530327553 0017425 0 ustar 00root root 0000000 0000000 //
// C++ Interface: LaylinesGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef LAYLINES_H
#define LAYLINES_H
#include "boats.h"
#include
#include
class PositionModel;
/**
\class LaylinesGraphicsItem
\brief the QGraphicsItem for laylines
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsPathItem for Item framework and QObject for slot and
signal framework. It displays the laylines of a PositionModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, PositionModel
*/
class LaylinesGraphicsItem : public QObject, public QGraphicsPathItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
public:
LaylinesGraphicsItem(PositionModel *model, QGraphicsItem *parent = 0);
virtual ~LaylinesGraphicsItem();
void updatePath();
public slots:
void setLength(int length);
void setSeries(int value);
void setLaylineAngle(int value);
void setHeading(qreal value);
void setWind(qreal value);
void setVisible(bool visible);
protected:
/// \a m_model holds the PositionModel being represented
PositionModel *m_model;
/// \a m_length holds the number of boat lengths for zone
int m_length;
/// \a m_boatLength holds the size in scene coordinates for main series
int m_boatLength;
/// \a m_laylineAngle holds the layline angle
int m_laylineAngle;
qreal m_heading;
qreal m_wind;
bool m_visible;
};
#endif // LAYLINES_H
boats-201908/graphicsview/mark.cpp 0000664 0000000 0000000 00000017414 13530327553 0017075 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: MarkGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "mark.h"
#include "commontypes.h"
#include "situationscene.h"
#include "situationmodel.h"
#include "markmodel.h"
#include "bubble.h"
#include
#include
#include
#include
extern int debugLevel;
MarkGraphicsItem::MarkGraphicsItem(MarkModel *mark, QGraphicsItem *parent)
: QGraphicsItem(parent),
m_mark(mark),
m_color(mark->color()),
m_zone(mark->zone()),
m_length(mark->length()),
m_boatLength(Boats::seriesSizeList()[m_mark->situation()->situationSeries()]),
m_bubble(new BubbleGraphicsItem(m_mark, this)),
m_order(mark->order()),
m_laylines(new LaylinesGraphicsItem(m_mark, this)),
m_heading(mark->heading()),
m_arrowVisible(mark->arrowVisible()),
m_leaveToPort(mark->leaveToPort()),
m_labelVisible(mark->labelVisible()),
m_labelText(mark->labelText()) {
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setPos(mark->position());
setZValue(m_order);
m_bubble->setZValue(1);
connect(mark, SIGNAL(positionChanged(QPointF)),
this, SLOT(setPosition(QPointF)));
connect(mark, SIGNAL(orderChanged(int)),
this, SLOT(setOrder(int)));
connect(mark, SIGNAL(colorChanged(QColor)),
this, SLOT(setColor(QColor)));
connect(mark, SIGNAL(zoneChanged(bool)),
this, SLOT(setZone(bool)));
connect(mark, SIGNAL(lengthChanged(int)),
this, SLOT(setLength(int)));
connect(mark->situation(), SIGNAL(seriesChanged(int)),
this, SLOT(setSeries(int)));
connect(mark->situation(), SIGNAL(markRemoved(MarkModel*)),
this, SLOT(deleteItem(MarkModel*)));
connect(mark, SIGNAL(headingChanged(qreal)),
this, SLOT(setHeading(qreal)));
connect(mark, SIGNAL(arrowVisibilityChanged(bool)),
this, SLOT(setArrowVisible(bool)));
connect(mark, SIGNAL(leaveToPortChanged(bool)),
this, SLOT(setLeaveToPort(bool)));
connect(mark, SIGNAL(labelVisibilityChanged(bool)),
this, SLOT(setLabelVisible(bool)));
connect(mark, SIGNAL(labelTextChanged(QString)),
this, SLOT(setLabelText(QString)));
}
MarkGraphicsItem::~MarkGraphicsItem() {}
void MarkGraphicsItem::setPosition(QPointF position) {
if (pos() != position) {
setPos(position);
update();
}
}
void MarkGraphicsItem::setOrder(int value) {
if (m_order != value) {
m_order = value;
update();
}
}
void MarkGraphicsItem::setColor(QColor value) {
if (m_color != value) {
m_color = value;
update();
}
}
void MarkGraphicsItem::setZone(bool value) {
if (m_zone != value) {
prepareGeometryChange();
m_zone = value;
update();
}
}
void MarkGraphicsItem::setLength(int value) {
if (m_length != value) {
prepareGeometryChange();
m_length = value;
update();
}
}
void MarkGraphicsItem::setSeries(int value) {
int boatLength = Boats::seriesSizeList()[value];
if (m_boatLength != boatLength) {
prepareGeometryChange();
m_boatLength = boatLength;
update();
}
}
void MarkGraphicsItem::deleteItem(MarkModel *mark) {
if (mark == m_mark) {
if (debugLevel & 1 << VIEW) std::cout << "deleting markGraphics for model" << m_mark << std::endl;
scene()->removeItem(this);
delete this;
}
}
void MarkGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
m_multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
bool selection = true;
if (m_multiSelect) {
selection = !isSelected();
}
setSelected(selection);
if (selection) {
m_mark->situation()->addSelectedMark(m_mark);
} else {
m_mark->situation()->removeSelectedModel(m_mark);
}
update();
}
void MarkGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
}
void MarkGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
}
void MarkGraphicsItem::setHeading(qreal heading) {
if (m_heading != heading) {
m_heading = heading;
QTransform rotation;
rotation.rotate(m_heading),
setTransform(rotation, false);
}
}
void MarkGraphicsItem::setArrowVisible(bool visible) {
if (m_arrowVisible != visible) {
m_arrowVisible = visible;
update();
}
}
void MarkGraphicsItem::setLeaveToPort(bool leaveToPort) {
if (m_leaveToPort != leaveToPort) {
m_leaveToPort = leaveToPort;
update();
}
}
void MarkGraphicsItem::setLabelVisible(bool visible) {
if (m_labelVisible != visible) {
m_labelVisible = visible;
update();
}
}
void MarkGraphicsItem::setLabelText(QString text) {
if (m_labelText != text) {
m_labelText = text;
update();
}
}
QRectF MarkGraphicsItem::boundingRect() const {
int r = m_length * m_boatLength;
return QRectF(-r, -r, 2*r, 2*r);
}
QPainterPath MarkGraphicsItem::shape() const {
QPainterPath path;
// Need to increase size of shape to include mark arrow so that can click on it to rotate
path.addEllipse(QPointF(0,0),35,35);
return path;
}
void MarkGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Q_UNUSED(option);
Q_UNUSED(widget);
if (isSelected())
painter->setPen(Qt::red);
else
painter->setPen(Qt::black);
painter->setBrush(m_color);
QPointF point(0, 0);
painter->drawEllipse(point,10,10);
if (m_labelVisible) {
painter->rotate(-m_heading);
painter->drawText(QRectF(-35,-35,70,70),Qt::AlignCenter,m_labelText);
painter->rotate(m_heading);
}
if (m_zone) {
painter->setBrush(Qt::NoBrush);
painter->setPen(Qt::DashLine);
int r = m_length * m_boatLength;
painter->drawEllipse(point, r, r);
}
// Additional code to draw mark rounding arrow
if (m_arrowVisible) {
QPainterPath port_path, stbd_path;
port_path.moveTo(-25,0);
port_path.lineTo(-20,0);
port_path.lineTo(-30,10);
port_path.lineTo(-40,0);
port_path.lineTo(-35,0);
port_path.arcTo(-35,-35,70,70,180,-90);
port_path.arcTo(-25,-25,50,50,90,90);
stbd_path.moveTo(0,-25);
stbd_path.lineTo(0,-20);
stbd_path.lineTo(10,-30);
stbd_path.lineTo(0,-40);
stbd_path.lineTo(0,-35);
stbd_path.arcTo(-35,-35,70,70,90,90);
stbd_path.arcTo(-25,-25,50,50,180,-90);
QPen arrowpen;
arrowpen.setWidth(2);
arrowpen.setColor(Qt::lightGray);
painter->setPen(arrowpen);
painter->setBrush(Qt::NoBrush);
painter->rotate(45.0);
if (m_leaveToPort) {
painter->drawPath(port_path);
}
else {
painter->drawPath(stbd_path);
}
}
}
int MarkGraphicsItem::type() const {
return MARK_TYPE;
}
boats-201908/graphicsview/mark.h 0000664 0000000 0000000 00000007557 13530327553 0016551 0 ustar 00root root 0000000 0000000 //
// C++ Interface: MarkGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef MARK_H
#define MARK_H
#include "commontypes.h"
#include "bubble.h"
#include "laylines.h"
#include
#include
#include
class MarkModel;
/**
\class MarkGraphicsItem
\brief the QGraphicsItem for a mark
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the representation of a MarkModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, MarkModel
*/
class MarkGraphicsItem : public QObject, public QGraphicsItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
public:
MarkGraphicsItem(MarkModel *mark = 0, QGraphicsItem *parent = 0);
~MarkGraphicsItem();
MarkModel* mark() const { return m_mark; }
BubbleGraphicsItem* bubble() const { return m_bubble; }
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
int type() const;
public slots:
void setPosition(QPointF position);
void setOrder(int value);
void setColor(QColor value);
void setZone(bool zone);
void setLength(int length);
void setSeries(int value);
void deleteItem(MarkModel *mark);
void setHeading(qreal heading);
void setArrowVisible(bool visible);
void setLeaveToPort(bool leaveToPort);
void setLabelVisible(bool visible);
void setLabelText(QString text);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
/// \a m_mark holds the MarkModel being represented
MarkModel *m_mark;
/// \a m_color holds the color of the mark
QColor m_color;
/// \a m_zone holds wether zone is displayed
bool m_zone;
/// \a m_length holds the number of boat lengths for zone
int m_length;
/// \a m_boatLength holds the size in scene coordinates for main series
int m_boatLength;
/// \a m_bubble holds the bubble to display
BubbleGraphicsItem *m_bubble;
/// \a m_order holds the stacking order in the mark list
int m_order;
/// \a m_laylines holds the laylines for the mark
LaylinesGraphicsItem *m_laylines;
/// \a m_heading holds the orientation of the arrow
qreal m_heading;
/// \a m_arrowVisible holds wether the mark arrow is visible
bool m_arrowVisible;
/// \a m_leaveToPort holds the orientation of the arrow
bool m_leaveToPort;
/// \a m_multiSelect is true if Ctrl-modified was in effect when mousePressEvent happened
/// Need to save this state until receive mouseReleaseEvent to determine what to do
bool m_multiSelect;
bool m_labelVisible;
QString m_labelText;
};
#endif
boats-201908/graphicsview/point.cpp 0000664 0000000 0000000 00000007033 13530327553 0017270 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: PointGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "point.h"
#include "commontypes.h"
#include "situationscene.h"
#include "situationmodel.h"
#include "polylinemodel.h"
#include "pointmodel.h"
#include
#include
#include
#include
extern int debugLevel;
const int size = 3;
PointGraphicsItem::PointGraphicsItem(PointModel *point, QGraphicsItem *parent)
: QGraphicsItem(parent),
m_point(point),
m_bubble(new BubbleGraphicsItem(m_point, this)),
m_laylines(new LaylinesGraphicsItem(m_point, this)) {
setZValue(1);
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setPos(point->position());
m_bubble->setZValue(1);
m_points << QPoint(0, -size)
<< QPoint(size, 0)
<< QPoint(0, size)
<< QPoint(-size, 0)
<< QPoint(0, -size);
connect(point, SIGNAL(positionChanged(QPointF)),
this, SLOT(setPosition(QPointF)));
connect(point->polyLine()->situation(), SIGNAL(pointRemoved(PointModel *)),
this, SLOT(deleteItem(PointModel*)));
}
PointGraphicsItem::~PointGraphicsItem() {}
void PointGraphicsItem::setPosition(QPointF position) {
if (pos() != position) {
setPos(position);
update();
}
}
void PointGraphicsItem::deleteItem(PointModel *point) {
if (point == m_point) {
if (debugLevel & 1 << VIEW) std::cout << "deleting pointGraphics for model" << m_point << std::endl;
scene()->removeItem(this);
delete this;
}
}
void PointGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
bool selection = true;
if ((event->modifiers() & Qt::ControlModifier) != 0) {
selection = !isSelected();
}
setSelected(selection);
if (selection) {
m_point->situation()->addSelectedPoint(m_point);
} else {
m_point->situation()->removeSelectedModel(m_point);
}
}
void PointGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
}
void PointGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
}
QRectF PointGraphicsItem::boundingRect() const {
return QRectF(-size, -size, 2*size, 2*size);
}
QPainterPath PointGraphicsItem::shape() const {
QPainterPath path;
path.addPolygon(m_points);
return path;
}
void PointGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Q_UNUSED(option);
Q_UNUSED(widget);
if (isSelected())
painter->setPen(Qt::red);
else
painter->setPen(Qt::black);
painter->setBrush(Qt::black);
painter->drawPolygon(m_points);
}
int PointGraphicsItem::type() const {
return POINT_TYPE;
}
boats-201908/graphicsview/point.h 0000664 0000000 0000000 00000005060 13530327553 0016733 0 ustar 00root root 0000000 0000000 //
// C++ Interface: PointGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef POINT_H
#define POINT_H
#include "commontypes.h"
#include "bubble.h"
#include "laylines.h"
#include
#include
class PointModel;
/**
\class PointGraphicsItem
\brief the QGraphicsItem for a point
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the representation of a PositionModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, PositionModel
*/
class PointGraphicsItem : public QObject, public QGraphicsItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
public:
PointGraphicsItem(PointModel *point = 0, QGraphicsItem *parent = 0);
~PointGraphicsItem();
PointModel* point() const { return m_point; }
BubbleGraphicsItem* bubble() const { return m_bubble; }
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
int type() const;
public slots:
void setPosition(QPointF position);
void deleteItem(PointModel *point);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
/// \a m_point holds the PointModel being represented
PointModel *m_point;
/// \a m_bubble holds the bubble to display
BubbleGraphicsItem *m_bubble;
QPolygon m_points;
/// \a m_laylines holds the laylines for the mark
LaylinesGraphicsItem *m_laylines;
};
#endif
boats-201908/graphicsview/polyline.cpp 0000664 0000000 0000000 00000003605 13530327553 0017773 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: PolyLineGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009-2010 Thibaut GRIDEL
//
// 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 .
//
//
#include "polyline.h"
#include "commontypes.h"
#include "situationmodel.h"
#include "polylinemodel.h"
#include
#include
#include
#include
extern int debugLevel;
PolyLineGraphicsItem::PolyLineGraphicsItem(PolyLineModel *polyline, QGraphicsItem *parent)
: QGraphicsPathItem(parent),
m_polyline(polyline) {
setZValue(0);
setPolyLine();
connect(polyline, SIGNAL(polyLineChanged(PolyLineModel*)),
this, SLOT(setPolyLine()));
connect(polyline->situation(), SIGNAL(polyLineRemoved(PolyLineModel*)),
this, SLOT(deleteItem(PolyLineModel*)));
}
PolyLineGraphicsItem::~PolyLineGraphicsItem() {}
void PolyLineGraphicsItem::setPolyLine() {
prepareGeometryChange();
setPath(m_polyline->path());
update();
}
void PolyLineGraphicsItem::deleteItem(PolyLineModel *polyline) {
if (polyline == m_polyline) {
if (debugLevel & 1 << VIEW) std::cout << "deleting polylineGraphics for model" << m_polyline << std::endl;
scene()->removeItem(this);
delete this;
}
}
boats-201908/graphicsview/polyline.h 0000664 0000000 0000000 00000003471 13530327553 0017441 0 ustar 00root root 0000000 0000000 //
// C++ Interface: PolyLineGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2009-2010 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef POLYLINE_H
#define POLYLINE_H
#include
#include
#include
class PolyLineModel;
/**
\class PolyLineGraphicsItem
\brief the QGraphicsItem for a polyline
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the representation of a PolyLineModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, PolyLineModel
*/
class PolyLineGraphicsItem : public QObject, public QGraphicsPathItem {
Q_OBJECT
public:
PolyLineGraphicsItem(PolyLineModel *polyline = 0, QGraphicsItem *parent = 0);
~PolyLineGraphicsItem();
PolyLineModel* polyline() const { return m_polyline; }
public slots:
void setPolyLine();
void deleteItem(PolyLineModel *polyline);
private:
/// \a m_polyline holds the PolyLineModel being represented
PolyLineModel *m_polyline;
};
#endif
boats-201908/graphicsview/sail.cpp 0000664 0000000 0000000 00000006607 13530327553 0017075 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: SailGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "sail.h"
#include "commontypes.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include
#include
#include
extern int debugLevel;
SailGraphicsItem::SailGraphicsItem(BoatModel *boat, QGraphicsItem *parent)
: QGraphicsPathItem(parent),
m_boat(boat),
m_sailAngle(0),
m_sailSize(0) {
setZValue(0);
setBrush(QBrush(Qt::white));
}
SailGraphicsItem::~SailGraphicsItem() {}
void SailGraphicsItem::setPosition(QPointF position) {
if (pos() != position) {
setPos(position);
update();
}
}
void SailGraphicsItem::setSailSize(qreal sailSize) {
m_sailSize = sailSize;
QPainterPath sailPathStalled;
sailPathStalled.cubicTo(.1 * sailSize, .2 * sailSize, .1 * sailSize, .2 * sailSize, 0, .3 * sailSize);
sailPathStalled.cubicTo(-.1 * sailSize, .4 * sailSize, -.1 * sailSize, .4 * sailSize, 0, .5 * sailSize);
sailPathStalled.cubicTo(.1 * sailSize, .6 * sailSize, .1 * sailSize, .6 * sailSize, 0, .7 * sailSize);
sailPathStalled.cubicTo(-.1 * sailSize, .8 * sailSize, -.1 * sailSize, .8 * sailSize, 0, sailSize);
sailPathStalled.lineTo(0, 0);
m_sailPathStalled = sailPathStalled;
QPainterPath sailPathStarboard;
sailPathStarboard.cubicTo(.1 * sailSize, .4 * sailSize, .1 * sailSize, .6 * sailSize, 0, sailSize);
sailPathStarboard.lineTo(0, 0);
m_sailPathStarboard = sailPathStarboard;
QPainterPath sailPathPort;
sailPathPort.cubicTo(-.1 * sailSize, .4 * sailSize, -.1 * sailSize, .6 * sailSize, 0, sailSize);
sailPathPort.lineTo(0, 0);
m_sailPathPort = sailPathPort;
setSailAngle(m_sailAngle); // Need to call setSailAngle() to update path, but don't want this to be sail specific. But not looking to change sail angle per se, so no need to use anything other than m_sailAngle.
}
/// calculate a sail incidence angle, corrected with user trimming
void SailGraphicsItem::setSailAngle(qreal value) {
m_sailAngle = value;
qreal angle = fmod(m_boat->heading() - m_boat->wind() - m_sailAngle +360, 360);
if(angle < 0) angle +=360;
if ((angle < 10 || angle > 350 || (angle > 170 && angle < 190)) && path() != m_sailPathStalled) {
setPath(m_sailPathStalled);
} else if (angle >= 10 && angle <= 170 && path() != m_sailPathStarboard) {
setPath(m_sailPathStarboard);
} else if (angle >= 190 && angle <= 350 && path() != m_sailPathPort) {
setPath(m_sailPathPort);
}
QTransform transform;
transform.rotate(- m_sailAngle);
setTransform(transform, false);
}
boats-201908/graphicsview/sail.h 0000664 0000000 0000000 00000004463 13530327553 0016540 0 ustar 00root root 0000000 0000000 //
// C++ Interface: SailGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2010 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef SAIL_H
#define SAIL_H
#include "boats.h"
#include
#include
class BoatModel;
/**
\class SailGraphicsItem
\brief the QGraphicsItem for a sail
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsPathItem for Item framework and QObject for slot and
signal framework. It displays the sail representation of a BoatModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, BoatModel
*/
class SailGraphicsItem : public QObject, public QGraphicsPathItem {
Q_OBJECT
public:
SailGraphicsItem(BoatModel *boat, QGraphicsItem *parent = 0);
virtual ~SailGraphicsItem();
BoatModel* boat() const { return m_boat; }
void setPosition(QPointF position);
void setSailSize(qreal size);
public slots:
void setSailAngle(qreal value);
protected:
/// \a m_boat holds the BoatModel being represented
BoatModel *m_boat;
/// \a m_sailAngle holds the ideal sail trimming angle
qreal m_sailAngle;
/// \a m_sailSize holds the size of the foot
qreal m_sailSize;
/// \a m_sailPathPort holds the sail path when on port tack
QPainterPath m_sailPathPort;
/// \a m_sailPathStarboard holds the sail path when on starboard tack
QPainterPath m_sailPathStarboard;
/// \a m_sailPathStalled holds the sail path when head to wind
QPainterPath m_sailPathStalled;
};
#endif // SAIL_H
boats-201908/graphicsview/situationscene.cpp 0000664 0000000 0000000 00000030361 13530327553 0021174 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: situationscene
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#include "situationscene.h"
#include "commontypes.h"
#include "situationmodel.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include "markmodel.h"
#include "polylinemodel.h"
#include "pointmodel.h"
#include "windmodel.h"
#include "scenarioanimation.h"
#include "trackanimation.h"
#include "statemachine.h"
#include "boat.h"
#include "track.h"
#include "mark.h"
#include "polyline.h"
#include "point.h"
#include "arrow.h"
#include
#include
#include
#include
#include
extern int debugLevel;
SituationScene::SituationScene(SituationModel *situation)
: QGraphicsScene(situation),
m_situation(situation),
m_time(QTime::currentTime()),
m_clickTime(QTime::currentTime()),
m_clickState(SINGLE),
m_defaultPopup(0),
m_boatPopup(0),
m_markPopup(0),
m_pointPopup(0) {
setItemIndexMethod(NoIndex);
// set a minimum scene rect
setSceneRect(-10000, -10000, 20000, 20000);
// react to self change of selection
connect(this, SIGNAL(selectionChanged()),
this, SLOT(setSelectedModels()));
// react to model track add
connect(situation, SIGNAL(trackAdded(TrackModel*)),
this, SLOT(addTrack(TrackModel*)));
// react to model boat add
connect(situation, SIGNAL(boatAdded(BoatModel*)),
this, SLOT(addBoatItem(BoatModel*)));
// react to model mark add
connect(situation, SIGNAL(markAdded(MarkModel*)),
this, SLOT(addMarkItem(MarkModel*)));
// react to model line add
connect(situation, SIGNAL(polyLineAdded(PolyLineModel*)),
this, SLOT(addPolyLine(PolyLineModel*)));
// react to model point add
connect(situation, SIGNAL(pointAdded(PointModel*)),
this, SLOT(addPoint(PointModel*)));
// react to layline angle
connect(situation, SIGNAL(laylineChanged(const int)),
this, SLOT(setLaylines(const int)));
connect(&situation->wind(), SIGNAL(windVisibleChanged(bool)),
this, SLOT(setWind(bool)));
connect(situation, SIGNAL(lookDirectionChanged(qreal)),
this, SIGNAL(lookDirectionChanged(qreal)));
connect(situation, SIGNAL(tiltChanged(qreal)),
this, SIGNAL(tiltChanged(qreal)));
setLaylines(situation->laylineAngle());
connect(situation->stateMachine()->animationState(), SIGNAL(entered()),
this, SLOT(setAnimation()));
connect(situation->stateMachine()->noSelectionState(), SIGNAL(entered()),
this, SLOT(clearSelection()));
}
void SituationScene::addTrack(TrackModel *track) {
if (debugLevel & 1 << VIEW) std::cout << "adding track graphics for model " << track << std::endl;
TrackGraphicsItem *trackItem = new TrackGraphicsItem(track);
addItem(trackItem);
}
void SituationScene::addBoatItem(BoatModel *boat) {
if (debugLevel & 1 << VIEW) std::cout << "adding boat graphics for model " << boat << std::endl;
BoatGraphicsItem *boatItem = new BoatGraphicsItem(boat);
addItem(boatItem);
}
void SituationScene::addMarkItem(MarkModel *mark) {
if (debugLevel & 1 << VIEW) std::cout << "adding mark graphics for model " << mark << std::endl;
MarkGraphicsItem *markItem = new MarkGraphicsItem(mark);
addItem(markItem);
}
void SituationScene::addPolyLine(PolyLineModel *polyline) {
if (debugLevel & 1 << VIEW) std::cout << "adding line graphics for model " << polyline << std::endl;
PolyLineGraphicsItem *polyLineItem = new PolyLineGraphicsItem(polyline);
addItem(polyLineItem);
}
void SituationScene::addPoint(PointModel *point) {
if (debugLevel & 1 << VIEW) std::cout << "adding point graphics for model " << point << std::endl;
PointGraphicsItem *pointItem = new PointGraphicsItem(point);
addItem(pointItem);
}
void SituationScene::setWind(bool visible) {
if (visible) {
if (debugLevel & 1 << VIEW) std::cout << "adding wind graphics" << std::endl;
ArrowGraphicsItem *arrow= new ArrowGraphicsItem(&m_situation->wind());
addItem(arrow);
}
}
/**
Creates a BoatGraphicsItem for animation purpose
*/
void SituationScene::setAnimation() {
clearSelection();
foreach (TrackAnimation *track, m_situation->animation()->animationItems()) {
BoatGraphicsItem *boatItem = new BoatGraphicsItem(track->boat());
boatItem->setOrder(0);
addItem(boatItem);
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
shadow->setXOffset(4);
shadow->setYOffset(4);
shadow->setBlurRadius(4);
boatItem->setGraphicsEffect(shadow);
if(track->boat()->track()->followTrack()) {
connect(boatItem->boat(), SIGNAL(positionChanged(QPointF)),
this, SIGNAL(centerChanged(QPointF)));
disconnect(m_situation, SIGNAL(lookDirectionChanged(qreal)));
connect(boatItem->boat(), SIGNAL(headingChanged(qreal)),
this, SIGNAL(lookDirectionChanged(qreal)));
}
}
}
/**
Reacts to user keyboard actions in the Scene
This method modifies the associated SituationModel.
Handled keys are for
- heading of selected boats (+,-)
- position of selected objects (H (left), L (right), J (down), K (up))
*/
void SituationScene::keyPressEvent(QKeyEvent *event) {
if (!m_situation->selectedModels().isEmpty()) {
if (event->key() == Qt::Key_Left) {
m_situation->setCurPosition(m_situation->curPosition() + QPointF(-5,0));
m_situation->stateMachine()->lmbMove();
} else if (event->key() == Qt::Key_Right) {
m_situation->setCurPosition(m_situation->curPosition() + QPointF(5,0));
m_situation->stateMachine()->lmbMove();
} else if (event->key() == Qt::Key_Up) {
m_situation->setCurPosition(m_situation->curPosition() + QPointF(0,-5));
m_situation->stateMachine()->lmbMove();
} else if (event->key() == Qt::Key_Down) {
m_situation->setCurPosition(m_situation->curPosition() + QPointF(0,5));
m_situation->stateMachine()->lmbMove();
} else if (event->key() == Qt::Key_Plus) {
m_situation->rotateModel(5.0);
} else if (event->key() == Qt::Key_Minus) {
m_situation->rotateModel(-5.0);
} else {
QGraphicsScene::keyPressEvent(event);
}
} else {
QGraphicsScene::keyPressEvent(event);
}
}
void SituationScene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if (debugLevel & 1 << VIEW) std::cout << "Mouse Press " << m_situation->selectedModels().size() << std::endl;
// if we don't use Ctrl, then clear selection
if ((event->modifiers() & Qt::ControlModifier) == 0) {
m_situation->clearSelectedModels();
clearSelection();
}
QGraphicsScene::mousePressEvent(event);
m_clickTime.start();
}
/**
Handles a timer to limit user interaction
This method limits the move processing to one event handled per 40ms.
This is very noticeable on Windows platform, and the
culprit is the drawing, not the model setting.
*/
void SituationScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
// limit update rate to 40ms
if ((m_time.elapsed() <40) ) {
return;
}
QGraphicsScene::mouseMoveEvent(event);
m_situation->setCurPosition(event->scenePos());
if (event->buttons() == Qt::LeftButton
&& (event->modifiers() & Qt::MetaModifier) == 0) {
m_situation->stateMachine()->lmbMove();
}
if (event->buttons() == Qt::RightButton
|| (event->buttons() == Qt::LeftButton
&& ((event->modifiers() & Qt::MetaModifier) != 0))) {
m_situation->stateMachine()->rmbMove();
}
if (event->buttons() == Qt::NoButton) {
m_situation->stateMachine()->move();
}
// trigger next update rate calculation
m_time.start();
}
/**
Performs action depending of button and mode
This method will trigger performing of actions like:
- setting position of selected objects
- setting heading of selected BoatGraphicsItem
- creating new TrackModel, BoatModel or MarkModel according to mode.
*/
void SituationScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
QGraphicsScene::mouseReleaseEvent(event);
if (m_clickState != SINGLE) {
m_clickState = SINGLE;
return;
}
mouseClickEvent(event);
}
void SituationScene::mouseClickEvent(QGraphicsSceneMouseEvent *event) {
if (debugLevel & 1 << VIEW) std::cout << "Mouse Release " << m_situation->selectedModels().size() << std::endl;
// do not deliver events in animation mode
if (m_situation->stateMachine()->animationState()->active()) {
return;
}
bool click = (m_clickTime.elapsed() < 250);
if (click && (event->button() == Qt::RightButton
|| (event->button() == Qt::LeftButton
&& ((event->modifiers() & Qt::MetaModifier) != 0)))) {
if (!m_situation->selectedModels().isEmpty()) {
switch(selectedItems()[0]->type()) {
case BOAT_TYPE: {
m_boatPopup->popup(event->screenPos());
return;
}
break;
case MARK_TYPE: {
m_markPopup->popup(event->screenPos());
return;
}
break;
case POINT_TYPE: {
m_pointPopup->popup(event->screenPos());
return;
}
break;
}
}
m_defaultPopup->popup(event->screenPos());
return;
}
if (event->button() == Qt::RightButton
|| (event->button() == Qt::LeftButton
&& ((event->modifiers() & Qt::MetaModifier) != 0))) {
m_situation->stateMachine()->rmbclick();
}
if (event->button() == Qt::LeftButton) {
m_situation->stateMachine()->lmbclick();
}
}
void SituationScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event);
m_clickState = DOUBLE;
m_situation->stateMachine()->noState();
m_situation->undo();
}
void SituationScene::setSelectedModels() {
if (debugLevel & 1 << VIEW) std::cout << "SelectedModels update " << m_situation->selectedModels().size() << std::endl;
emit selectedModelsChanged();
}
void SituationScene::setLaylines(const int angle) {
if (!m_situation->showLayline()) {
if (debugLevel & 1 << VIEW) std::cout << "resetting empty Background" << std::endl;
setBackgroundBrush(Qt::NoBrush);
return;
}
if (debugLevel & 1 << VIEW) std::cout << "creating layline Background for " << angle << std::endl;
qreal theta = angle * M_PI /180;
int length = Boats::seriesSizeList()[m_situation->situationSeries()];
// draw 4 times as big, then use transform to scale back the brush
// gives better precision grid
qreal x = 2*length*sin(theta) * 4;
qreal y = 2*length*cos(theta) * 4;
QPixmap pixmap(x,y);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QPen pen;
pen.setWidth(2);
QVector dashes;
dashes << length/10.0 << length/5.0;
pen.setStyle(Qt::CustomDashLine);
pen.setDashPattern(dashes);
painter.setPen(pen);
painter.setRenderHints(QPainter::Antialiasing);
painter.drawLine(QLineF(0,0,x,y));
painter.drawLine(QLineF(0,y,x,0));
QBrush brush;
QTransform transform;
transform.scale(0.25, 0.25);
brush.setTransform(transform);
brush.setTexture(pixmap);
setBackgroundBrush(brush);
}
boats-201908/graphicsview/situationscene.h 0000664 0000000 0000000 00000010166 13530327553 0020642 0 ustar 00root root 0000000 0000000 //
// C++ Interface: situationscene
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2011 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef SITUATIONSCENE_H
#define SITUATIONSCENE_H
#include
#include
#include
#include
class TrackModel;
class PositionModel;
class BoatModel;
class MarkModel;
class PolyLineModel;
class PointModel;
#include "situationmodel.h"
enum {
BOAT_TYPE = QGraphicsItem::UserType + 1,
MARK_TYPE,
POINT_TYPE,
ARROW_TYPE
};
/**
\class SituationScene
\brief The Scene for a scenario
The class represents the Scene for a Scenario, according to the
Graphics View Framework.
It inherits QGraphicsScene and manages user input.
The class handles a modal input status to trigger various actions
depending on the mode.
Action on Objects is handled by overloading the event methods:
keyPressEvent(), mousePressEvent(), mouseReleaseEvent() and
mouseMoveEvent().
Specialised methods handle the possible events and modify the ScenarioModel.
QGraphicsItem Objects selection is handled through setSelectedModels()
slot, and updates the various Lists needed to determine matching Model
objects.
The class provides slots to react to SituationModel changes and update
drawing accordingly.
The class prepares the drawing of animation boats as well.
\sa QGraphicsScene, SituationModel, BoatGraphicsItem, MarkGraphicsItem
*/
class SituationScene : public QGraphicsScene {
Q_OBJECT
public:
SituationScene(SituationModel* situation);
~SituationScene() {}
void setDefaultPopup(QMenu *theValue) { m_defaultPopup = theValue; }
void setBoatPopup(QMenu *theValue) { m_boatPopup = theValue; }
void setMarkPopup(QMenu *theValue) { m_markPopup = theValue; }
void setPointPopup(QMenu *theValue) { m_pointPopup = theValue; }
signals:
void selectedModelsChanged();
void centerChanged(QPointF position);
void lookDirectionChanged( const qreal lookDirection);
void tiltChanged( const qreal tilt);
public slots:
// Slot for selection mechanism
void setSelectedModels();
// Slots for SituationModel signals
void addTrack(TrackModel *track);
void addBoatItem(BoatModel *boat);
void addMarkItem(MarkModel *mark);
void addPolyLine(PolyLineModel *polyline);
void addPoint(PointModel *point);
void setLaylines(const int angle);
void setWind(bool visible);
// Slots for animation signals
void setAnimation();
protected:
// Overloaded methods for Events
void keyPressEvent(QKeyEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseClickEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
private:
SituationModel *m_situation;
/// \a m_time holds the timer used for movement filtering
QTime m_time;
/// \a m_clickTime holds the timer used for click/press detection
QTime m_clickTime;
enum {
SINGLE,
DOUBLE,
NONE
} m_clickState;
QMenu *m_defaultPopup;
QMenu *m_boatPopup;
QMenu *m_markPopup;
QMenu *m_pointPopup;
};
#endif
boats-201908/graphicsview/situationview.cpp 0000664 0000000 0000000 00000010733 13530327553 0021052 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: situationview
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2010 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include
#include "commontypes.h"
#include "situationview.h"
#include
extern int debugLevel;
SituationView::SituationView(QWidget *parent)
:QGraphicsView(parent) {
}
SituationView::SituationView(QGraphicsScene *scene, QWidget *parent)
: QGraphicsView(scene, parent),
scaleValue(1),
lookDirectionValue(0),
tiltValue(0) {
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
setResizeAnchor(QGraphicsView::AnchorViewCenter);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
connect( scene, SIGNAL(centerChanged(QPointF)),
this, SLOT(setCenter(QPointF)));
connect( scene, SIGNAL(lookDirectionChanged(qreal)),
this, SLOT(setLookDirection(qreal)));
connect( scene, SIGNAL(tiltChanged(qreal)),
this, SLOT(setTilt(qreal)));
}
SituationView::~SituationView() {
}
/**
Takes a picture of the current view and returns it as a QPixmap.
This method creates a QPixmap and calls render() on that pixmap
before returning it.
*/
QPixmap SituationView::screenShot() {
QPixmap pixmap(size());
pixmap.fill(Qt::white);
QPainter painter(&pixmap);
painter.setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
render(&painter);
return pixmap;
}
/**
Handles mouse wheel event to zoom in or out.
This method will call setScale() with rotation side.
*/
void SituationView::wheelEvent(QWheelEvent *event) {
if (debugLevel & 1 << VIEW) std::cout << "wheel event " << event->delta() << std::endl;
setScale(event->delta() > 0);
}
void SituationView::mousePressEvent(QMouseEvent *event) {
setDragMode(QGraphicsView::ScrollHandDrag);
QGraphicsView::mousePressEvent(event);
}
void SituationView::mouseReleaseEvent(QMouseEvent *event) {
QGraphicsView::mouseReleaseEvent(event);
setDragMode(QGraphicsView::NoDrag);
}
void SituationView::zoomIn() {
setScale(true);
}
void SituationView::zoomOut() {
setScale(false);
}
/**
Sets an acceptable scale that fits the whole scenario.
This method compares the matrix() before and after fitInView() and
possibly adopts the scale, rounded to the nearest .05
*/
void SituationView::zoomFit() {
fitInView(scene()->itemsBoundingRect(),Qt::KeepAspectRatio); // Qt doesn't seem to get this quite right when the view is tilted, but close enough
qreal s = sqrt (transform().det());
if (s < 10.0 && s > 0.1) {
// adapt scaling
scaleValue = pow(1.1, round(log(s)/log(1.1)));
}
transformView();
}
void SituationView::setLookDirection(qreal value) {
lookDirectionValue = value;
emit lookDirectionChanged(qRound(lookDirectionValue));
transformView();
}
void SituationView::setTilt(qreal value) {
tiltValue = value;
emit tiltChanged(qRound(tiltValue));
transformView();
}
void SituationView::setCenter(QPointF position) {
centerOn(position);
}
/**
Zoom in if \a in otherwise zoom out by .05 increments between
0.1 and 10
*/
void SituationView::setScale(bool in) {
if (in) {
if (scaleValue < 10.0) {
scaleValue *= 1.1;
}
} else if (scaleValue > 0.1) {
scaleValue /= 1.1;
}
if (debugLevel & 1 << VIEW)
std::cout << "new scale values " << scaleValue << std::endl;
transformView();
}
void SituationView::transformView() {
QTransform transform;
transform.rotate(tiltValue, Qt::XAxis);
transform.rotate(-lookDirectionValue, Qt::ZAxis);
transform.scale(scaleValue, scaleValue);
setTransform(transform, false);
}
boats-201908/graphicsview/situationview.h 0000664 0000000 0000000 00000004114 13530327553 0020513 0 ustar 00root root 0000000 0000000 //
// C++ Interface: situationview
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2010 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef SITUATIONVIEW_H
#define SITUATIONVIEW_H
#include
/**
\class SituationView
\brief The View for a scenario
The class represents the View for a Scenario, according to the
Graphics View Framework.
It inherits QGraphicsView and manages zoom and screenshot capture.
\sa SituationScene, SituationModel
*/
class SituationView : public QGraphicsView {
Q_OBJECT
public:
SituationView(QWidget *parent = 0);
SituationView(QGraphicsScene *scene, QWidget *parent = 0);
~SituationView();
QPixmap screenShot();
protected:
void wheelEvent(QWheelEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
public slots:
void zoomIn();
void zoomOut();
void zoomFit();
void setLookDirection(qreal value);
void setTilt(qreal value);
void setCenter(QPointF position);
signals:
void lookDirectionChanged( const int lookDirection);
void tiltChanged( const int tilt);
private:
void setScale(bool in);
void transformView();
/// \a scaleValue holds the value for the viewing scale
qreal scaleValue;
qreal lookDirectionValue;
qreal tiltValue;
};
#endif
boats-201908/graphicsview/spinnaker.cpp 0000664 0000000 0000000 00000013164 13530327553 0020133 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: SpinnakerGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2010 Thibaut GRIDEL
//
// 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 .
//
//
#include "spinnaker.h"
#include "commontypes.h"
#include "trackmodel.h"
#include "boatmodel.h"
#include
#include
#include
extern int debugLevel;
SpinnakerGraphicsItem::SpinnakerGraphicsItem(BoatModel *boat, QGraphicsItem *parent)
: SailGraphicsItem(boat, parent),
m_pole(new QGraphicsLineItem(this)) {
setHeading(boat->heading());
}
SpinnakerGraphicsItem::~SpinnakerGraphicsItem() {}
void SpinnakerGraphicsItem::setSailSize(qreal sailSize) {
m_sailSize = sailSize;
QPainterPath sailPathStarboard;
sailPathStarboard.cubicTo(.4 * sailSize, .2 * sailSize, .6 * sailSize, .2 * sailSize, sailSize, 0);
sailPathStarboard.arcTo(-sailSize, -sailSize, 2 * sailSize, 2 * sailSize, 0, -120);
sailPathStarboard.cubicTo(-.12 * sailSize, .62 * sailSize, -.03 * sailSize, .44 * sailSize, 0, 0);
m_sailPathStarboard = sailPathStarboard;
QPainterPath sailPathPort;
sailPathPort.cubicTo(-.4 * sailSize, .2 * sailSize, -.6 * sailSize, .2 * sailSize, -sailSize, 0);
sailPathPort.arcTo(- sailSize, -sailSize, 2 * sailSize, 2 * sailSize, 180, 120);
sailPathPort.cubicTo(.12 * sailSize, .62 * sailSize, .03 * sailSize, .44 * sailSize, 0, 0);
m_sailPathPort = sailPathPort;
QLineF line;
line.setP2(QPointF(0, -sailSize));
m_pole->setLine(line);
setSailAngle(m_boat->spinAngle() + m_boat->spinTrim());
}
/// calculate a sail incidence angle, corrected with user trimming
void SpinnakerGraphicsItem::setSailAngle(qreal value) {
m_sailAngle = value;
qreal angle = fmod(m_boat->heading() - m_boat->wind() - m_sailAngle, 360);
if(angle < 0) angle += 360;
if ((angle < 10 || angle > 350 || (angle > 170 && angle < 190)) && path() != m_sailPathStalled) {
setPath(m_sailPathStalled);
} else if (angle >= 10 && angle <= 170 && path() != m_sailPathStarboard) {
setPath(m_sailPathStarboard);
} else if (angle >= 190 && angle <= 350 && path() != m_sailPathPort) {
setPath(m_sailPathPort);
}
}
void SpinnakerGraphicsItem::setHeading(qreal value) {
qreal angle = fmod(value - m_boat->wind(), 360);
if (angle < 0) angle += 360;
QTransform rotation;
rotation.rotate(-angle);
setTransform(rotation, false);
QTransform poleRotation;
if (angle > 90 && angle < 180) {
poleRotation.rotate(90);
} else if (angle >= 180 && angle < 270) {
poleRotation.rotate(-90);
} else {
poleRotation.rotate(angle);
}
m_pole->setTransform(poleRotation, false);
QPainterPath sailPathStalled;
QPointF pole = m_pole->mapToParent(m_pole->line().p2());
double sinx = sin(angle* M_PI/180.0);
double cosx = cos(angle* M_PI/180.0);
double sign = .1;
if (angle>180) {
sign = -.1;
}
sailPathStalled.cubicTo(sign * m_sailSize * cosx + .4 * m_sailSize * sinx, sign * m_sailSize * sinx - .4 * m_sailSize * cosx,
sign * m_sailSize * cosx + .6 * m_sailSize * sinx, sign * m_sailSize * sinx - .6 * m_sailSize * cosx,
pole.x(), pole.y());
sailPathStalled.cubicTo(pole.x() + sign * m_sailSize, pole.y() + .2 * m_sailSize,
pole.x() + sign * m_sailSize, pole.y() + .2 * m_sailSize,
pole.x(), pole.y() + .3 * m_sailSize);
sailPathStalled.cubicTo(pole.x() - sign * m_sailSize, pole.y() + .4 * m_sailSize,
pole.x() - sign * m_sailSize, pole.y() + .4 * m_sailSize,
pole.x(), pole.y() + .5 * m_sailSize);
sailPathStalled.cubicTo(pole.x() + sign * m_sailSize, pole.y() + .6 * m_sailSize,
pole.x() + sign * m_sailSize, pole.y() + .6 * m_sailSize,
pole.x(), pole.y() + .7 * m_sailSize);
sailPathStalled.cubicTo(pole.x() - sign * m_sailSize, pole.y() + .8 * m_sailSize,
pole.x() - sign * m_sailSize, pole.y() + .8 * m_sailSize,
pole.x(), pole.y() + m_sailSize);
sailPathStalled.cubicTo(.8* pole.x(), pole.y() + m_sailSize,
.8 * pole.x(), pole.y() + m_sailSize,
.7 * pole.x(), .7 * (pole.y() + m_sailSize));
sailPathStalled.cubicTo(.6 * pole.x(), .4 * (pole.y() + m_sailSize),
.6 * pole.x(), .4 * (pole.y() + m_sailSize),
.5 * pole.x(), .5 * (pole.y() + m_sailSize));
sailPathStalled.cubicTo(.4 * pole.x(), .6 * (pole.y() + m_sailSize),
.4 * pole.x(), .6 * (pole.y() + m_sailSize),
.3 * pole.x(), .3 * (pole.y() + m_sailSize));
sailPathStalled.cubicTo(.2 * pole.x(), 0,
.2 * pole.x(), 0,
0, 0);
m_sailPathStalled = sailPathStalled;
}
boats-201908/graphicsview/spinnaker.h 0000664 0000000 0000000 00000003377 13530327553 0017605 0 ustar 00root root 0000000 0000000 //
// C++ Interface: SpinnakerGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2010 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef SPINNAKER_H
#define SPINNAKER_H
#include "boats.h"
#include "sail.h"
#include
#include
class BoatModel;
/**
\class SpinnakerGraphicsItem
\brief the QGraphicsItem for a sail
The class represents the Item according to the Graphics View Framework.
It inherits SailGraphicsItem which provides necessary update framework.
It displays the spin representation of a BoatModel on a SituationView.
\sa SituationView, SituationScene, SituationModel, BoatModel
*/
class SpinnakerGraphicsItem : public SailGraphicsItem {
Q_OBJECT
public:
SpinnakerGraphicsItem(BoatModel *boat, QGraphicsItem *parent = 0);
virtual ~SpinnakerGraphicsItem();
void setSailSize(qreal size);
public slots:
void setSailAngle(qreal value);
void setHeading(qreal value);
private:
/// \a m_pole holds the spinnaker pole
QGraphicsLineItem *m_pole;
};
#endif // SPINNAKER_H
boats-201908/graphicsview/track.cpp 0000664 0000000 0000000 00000003655 13530327553 0017251 0 ustar 00root root 0000000 0000000 //
// C++ Implementation: TrackGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2009 Thibaut GRIDEL
//
// 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 .
//
//
#include
#include
#include
#include
#include "track.h"
#include "commontypes.h"
#include "situationmodel.h"
#include "trackmodel.h"
extern int debugLevel;
TrackGraphicsItem::TrackGraphicsItem(TrackModel *track, QGraphicsItem *parent)
: QGraphicsPathItem(parent),
m_track(track) {
setZValue(0);
setTrack();
setShowPath(track->showPath());
connect(track, SIGNAL(showPathChanged(bool)),
this, SLOT(setShowPath(bool)));
connect(track, SIGNAL(trackChanged(TrackModel*)),
this, SLOT(setTrack()));
connect(track->situation(), SIGNAL(trackRemoved(TrackModel*)),
this, SLOT(deleteItem(TrackModel*)));
}
TrackGraphicsItem::~TrackGraphicsItem() {}
void TrackGraphicsItem::setTrack() {
prepareGeometryChange();
setPath(m_track->path());
update();
}
void TrackGraphicsItem::deleteItem(TrackModel *track) {
if (track == m_track) {
if (debugLevel & 1 << VIEW) std::cout << "deleting trackGraphics for model" << m_track << std::endl;
scene()->removeItem(this);
delete this;
}
}
boats-201908/graphicsview/track.h 0000664 0000000 0000000 00000003463 13530327553 0016713 0 ustar 00root root 0000000 0000000 //
// C++ Interface: BoatGraphicsItem
//
// Description:
//
//
// Author: Thibaut GRIDEL
//
// Copyright (c) 2008-2009 Thibaut GRIDEL
//
// 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 .
//
//
#ifndef TRACK_H
#define TRACK_H
#include
#include
#include
class TrackModel;
/**
\class TrackGraphicsItem
\brief the QGraphicsItem for a track
The class represents the Item according to the Graphics View Framework.
It inherits QGraphicsItem for Item framework and QObject for slot and
signal framework. It displays the representation of a TrackModel on a
SituationView.
\sa SituationView, SituationScene, SituationModel, TrackModel
*/
class TrackGraphicsItem : public QObject, public QGraphicsPathItem {
Q_OBJECT
public:
TrackGraphicsItem(TrackModel *track = 0, QGraphicsItem *parent = 0);
~TrackGraphicsItem();
TrackModel* track() const { return m_track; }
public slots:
void setTrack();
void setShowPath(bool showPath) {setVisible(showPath);}
void deleteItem(TrackModel *track);
private:
/// \a m_track holds the TrackModel being represented
TrackModel *m_track;
};
#endif
boats-201908/images.qrc 0000664 0000000 0000000 00000002210 13530327553 0014704 0 ustar 00root root 0000000 0000000
images/about.png
images/animate.png
images/addboat.png
images/addmark.png
images/addpoint.png
images/addpoly.png
images/addtrack.png
images/export.png
images/filenew.png
images/fileopen.png
images/fileprint.png
images/filequickprint.png
images/filesave.png
images/filesaveas.png
images/laylines.png
images/pdf.png
images/player_loop.png
images/player_play.png
images/player_pause.png
images/player_stop.png
images/redo.png
images/undo.png
images/tab_new.png
images/tab_remove.png
images/video.png
images/zone.png
images/zoomfit.png
images/zoomin.png
images/zoomout.png
boats-201908/images/ 0000775 0000000 0000000 00000000000 13530327553 0014202 5 ustar 00root root 0000000 0000000 boats-201908/images/about.png 0000664 0000000 0000000 00000062760 13530327553 0016035 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR – – ³cæµ sRGB ®Îé pHYs šœ tIMEØ
Þ½š> tEXtComment Created with GIMPW IDATxÚ|½iwYrwÉÌÊÚìnݣѴd[ïÑ—÷øgúƒäãåƒd5ÖŒ–iizZÝä4 n ˆ}©}Ïí^ˆª@àÇ88< P••yãÞXžx"B\\\dY–¦i–eB RzžÖÚZ›e !„ÖZcL’$Æ¥¾ Žã4M1RJ¥”"MÓ(Šð5Aär9¥^ÊZ«”’Rc²ùWš¦qZJ-…’Ry¾ÎR)!„” ðeÆ ûÁð¯øq¾ï!ðâÖZ| ÀÛ¶Ö
!´Öxóøâ4Mññ“$‰¢ <Ïó