Skip to content

Commit

Permalink
Merge pull request #13 from helios-base/develop
Browse files Browse the repository at this point in the history
Support v17
  • Loading branch information
hidehisaakiyama authored Apr 7, 2022
2 parents e140f21 + 3f28dcf commit 027f4f4
Show file tree
Hide file tree
Showing 5 changed files with 422 additions and 66 deletions.
211 changes: 211 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
---
# clang-format 13.0.0
Language: Cpp
# BasedOnStyle: GNU
#AccessModifierOffset: -2
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
#AlignArrayOfStructures: None
AlignArrayOfStructures: Right
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
#AlignOperands: Align
AlignOperands: AlignAfterOperator
#AlignOperands: BreakBeforeBinaryOperators
#AlignTrailingComments: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
#AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortLambdasOnASingleLine: All
#AllowShortIfStatementsOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: All
#AlwaysBreakAfterReturnType: AllDefinitions
AlwaysBreakAfterReturnType: TopLevelDefinitions
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
# AfterClass: true
AfterClass: false
AfterControlStatement: Always
# AfterEnum: true
AfterEnum: false
AfterFunction: true
# AfterNamespace: true
AfterNamespace: false
AfterObjCDeclaration: true
# AfterStruct: true
AfterStruct: false
# AfterUnion: true
AfterUnion: false
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
# BeforeLambdaBody: false
BeforeLambdaBody: true
BeforeWhile: true
# IndentBraces: true
IndentBraces: false
# SplitEmptyFunction: true
SplitEmptyFunction: false
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: true
#BreakBeforeBraces: GNU
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
#ColumnLimit: 79
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
#EmptyLineAfterAccessModifier: Never
EmptyLineAfterAccessModifier: Leave
#EmptyLineBeforeAccessModifier: LogicalBlock
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
#IndentWidth: 2
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
#PointerAlignment: Right
PointerAlignment: Middle
PPIndentWidth: -1
ReferenceAlignment: Pointer
#ReflowComments: true
ReflowComments: false
ShortNamespaceLines: 1
#SortIncludes: CaseSensitive
SortIncludes: Never
SortJavaStaticImport: Before
#SortUsingDeclarations: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
#SpaceAfterLogicalNot: false
SpaceAfterLogicalNot: true
#SpaceAfterTemplateKeyword: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
#SpaceBeforeParens: Always
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
#SpaceInEmptyBlock: false
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
#SpacesInAngles: false
SpacesInAngles: true
#SpacesInConditionalStatement: false
SpacesInConditionalStatement: true
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
#SpacesInParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
#Standard: c++03
Standard: c++14
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...
2 changes: 1 addition & 1 deletion src/model/csv_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ CSVLogger::existsFile()
if ( name != data_name )
{
std::cerr << "CSVLogger found mismatched header [" << name << "]."
<< " expected [" << *it << "]"
<< " expected [" << data_name << "]"
<< std::endl;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ noinst_HEADERS = \


soccerwindow2_CPPFLAGS = -I$(top_srcdir)/src/model $(QT_CPPFLAGS)
soccerwindow2_CXXFLAGS = $(QT_CXXFLAGS) -Wall -W
soccerwindow2_CXXFLAGS = $(QT_CXXFLAGS) -Wall -W -Wno-deprecated-copy
soccerwindow2_LDFLAGS = $(QT_LDFLAGS)
soccerwindow2_LDADD = $(top_builddir)/src/model/libsoccerwindow2_model.a $(QT_LDADD)
#soccerwindow2_LIBADD = ../model/libsoccerwindow2_model.a
Expand Down
130 changes: 101 additions & 29 deletions src/qt/player_painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include <rcsc/common/player_type.h>
#include <rcsc/common/server_param.h>
#include <rcsc/geom/angle_deg.h>
#include <rcsc/geom/vector_2d.h>
#include <rcsc/geom/line_2d.h>
#include <rcsc/geom/circle_2d.h>

#include <cstring>
Expand Down Expand Up @@ -919,39 +921,109 @@ PlayerPainter::drawCatchableArea( QPainter & painter,
side = static_cast< rcsc::SideID >( -1 * side );
}

double catchable = opt.scale( SP.catchableArea() );
painter.setPen( ( side == rcsc::LEFT )
? dconf.leftGoaliePen()
: dconf.rightGoaliePen() );
painter.setBrush( dconf.transparentBrush() );;
const double reliable_catch_dist = std::sqrt( std::pow( param.player_type_.reliableCatchLength(), 2 )
+ std::pow( SP.catchAreaWidth() * 0.5, 2 ) );
const double reliable_diagonal_angle = rcsc::AngleDeg::atan2_deg( SP.catchAreaWidth() * 0.5,
param.player_type_.reliableCatchLength() );

painter.drawEllipse( QRectF( param.x_ - catchable,
param.y_ - catchable,
catchable * 2,
catchable * 2 ) );
const double unreliable_catch_dist = std::sqrt( std::pow( param.player_type_.maxCatchLength(), 2 )
+ std::pow( SP.catchAreaWidth() * 0.5, 2 ) );
const double unreliable_diagonal_angle = rcsc::AngleDeg::atan2_deg( SP.catchAreaWidth() * 0.5,
param.player_type_.maxCatchLength() );

double delta = SP.catchAreaLength() * std::max( 0.0, param.player_type_.catchAreaLengthStretch() - 1.0 );
double max_l = SP.catchAreaLength() + delta;
double min_l = SP.catchAreaLength() - delta;
double max_area = std::sqrt( std::pow( SP.catchAreaWidth() * 0.5, 2.0 )
+ std::pow( max_l, 2.0 ) );
double min_area = std::sqrt( std::pow( SP.catchAreaWidth() * 0.5, 2.0 )
+ std::pow( min_l, 2.0 ) );
double max_r = opt.scale( max_area );
if ( max_r > catchable )
const double draw_reliable_r = opt.scale( reliable_catch_dist );
const double draw_unreliable_r = opt.scale( unreliable_catch_dist );

if ( SP.minCatchAngle() - reliable_diagonal_angle > -180.0 )
{
const rcsc::Line2D body_line( rcsc::Vector2D( param.player_.x(), param.player_.y() ),
param.player_.body() );
{
// draw unreliable ark
const int unreliable_start_angle = qRound( std::rint( -param.body_ + SP.minCatchAngle() - unreliable_diagonal_angle ) * 16 );
const int unreliable_span_angle = qRound( std::rint( SP.maxCatchAngle() - SP.minCatchAngle() + unreliable_diagonal_angle*2 ) * 16 );
const double unreliable_start_x = param.player_.x() + unreliable_catch_dist * rcsc::AngleDeg::cos_deg( param.body_ + SP.maxCatchAngle() + unreliable_diagonal_angle );
const double unreliable_start_y = param.player_.y() + unreliable_catch_dist * rcsc::AngleDeg::sin_deg( param.body_ + SP.maxCatchAngle() + unreliable_diagonal_angle );
const rcsc::Line2D start_line( rcsc::Vector2D( unreliable_start_x, unreliable_start_y ),
param.player_.body() + SP.minCatchAngle() );
const rcsc::Vector2D mid = body_line.intersection( start_line );
const double unreliable_end_x = param.player_.x() + unreliable_catch_dist * rcsc::AngleDeg::cos_deg( param.body_ + SP.minCatchAngle() - unreliable_diagonal_angle );
const double unreliable_end_y = param.player_.y() + unreliable_catch_dist * rcsc::AngleDeg::sin_deg( param.body_ + SP.minCatchAngle() - unreliable_diagonal_angle );
painter.setPen( ( side == rcsc::LEFT )
? dconf.leftGoalieStretchPen()
: dconf.rightGoalieStretchPen() );
painter.drawArc( QRectF( param.x_ - draw_unreliable_r,
param.y_ - draw_unreliable_r,
draw_unreliable_r * 2,
draw_unreliable_r * 2 ),
unreliable_start_angle, unreliable_span_angle );
const double draw_mid_x = ( mid.isValid()
? opt.screenX( mid.x )
: opt.screenX( ( unreliable_start_x + unreliable_end_x ) * 0.5 ) );
const double draw_mid_y = ( mid.isValid()
? opt.screenY( mid.y )
: opt.screenY( ( unreliable_start_y + unreliable_end_y ) * 0.5 ) );
painter.drawLine( QLineF( opt.screenX( unreliable_start_x ), opt.screenY( unreliable_start_y ),
draw_mid_x, draw_mid_y ) );
painter.drawLine( QLineF( draw_mid_x, draw_mid_y,
opt.screenX( unreliable_end_x ), opt.screenY( unreliable_end_y ) ) );
}
{
// draw reliable arc
const int reliable_start_angle = qRound( std::rint( -param.body_ + SP.minCatchAngle() - reliable_diagonal_angle ) * 16 );
const int reliable_span_angle = qRound( std::rint( SP.maxCatchAngle() - SP.minCatchAngle() + reliable_diagonal_angle*2 ) * 16 );
const double reliable_start_x = param.player_.x() + reliable_catch_dist * rcsc::AngleDeg::cos_deg( param.body_ + SP.maxCatchAngle() + reliable_diagonal_angle );
const double reliable_start_y = param.player_.y() + reliable_catch_dist * rcsc::AngleDeg::sin_deg( param.body_ + SP.maxCatchAngle() + reliable_diagonal_angle );
const rcsc::Line2D start_line( rcsc::Vector2D( reliable_start_x, reliable_start_y ),
param.player_.body() + SP.minCatchAngle() );
const rcsc::Vector2D mid = body_line.intersection( start_line );
const double reliable_end_x = param.player_.x() + reliable_catch_dist * rcsc::AngleDeg::cos_deg( param.body_ + SP.minCatchAngle() - reliable_diagonal_angle );
const double reliable_end_y = param.player_.y() + reliable_catch_dist * rcsc::AngleDeg::sin_deg( param.body_ + SP.minCatchAngle() - reliable_diagonal_angle );
painter.setPen( ( side == rcsc::LEFT )
? dconf.leftGoaliePen()
: dconf.rightGoaliePen() );
painter.drawArc( QRectF( param.x_ - draw_reliable_r,
param.y_ - draw_reliable_r,
draw_reliable_r * 2,
draw_reliable_r * 2 ),
reliable_start_angle, reliable_span_angle );
const double draw_mid_x = ( mid.isValid()
? opt.screenX( mid.x )
: opt.screenX( ( reliable_start_x + reliable_end_x ) * 0.5 ) );
const double draw_mid_y = ( mid.isValid()
? opt.screenY( mid.y )
: opt.screenY( ( reliable_start_y + reliable_end_y ) * 0.5 ) );
painter.drawLine( QLineF( opt.screenX( reliable_start_x ), opt.screenY( reliable_start_y ),
draw_mid_x, draw_mid_y ) );
painter.drawLine( QLineF( draw_mid_x, draw_mid_y,
opt.screenX( reliable_end_x ), opt.screenY( reliable_end_y ) ) );

// painter.drawLine( QLineF( opt.screenX( body_line.getX( -30.0 ) ), opt.screenY( -30.0 ),
// opt.screenX( body_line.getX( +30.0 ) ), opt.screenY( +30.0 ) ) );
}
}
else
{
painter.setBrush( dconf.transparentBrush() );

if ( draw_unreliable_r > draw_reliable_r )
{
painter.setPen( ( side == rcsc::LEFT )
? dconf.leftGoalieStretchPen()
: dconf.rightGoalieStretchPen() );
painter.drawEllipse( QRectF( param.x_ - draw_unreliable_r,
param.y_ - draw_unreliable_r,
draw_unreliable_r * 2,
draw_unreliable_r * 2 ) );
}

painter.setPen( ( side == rcsc::LEFT )
? dconf.leftGoalieStretchPen()
: dconf.rightGoalieStretchPen() );
painter.drawEllipse( QRectF( param.x_ - max_r,
param.y_ - max_r,
max_r * 2,
max_r * 2 ) );
double min_r = opt.scale( min_area );
painter.drawEllipse( QRectF( param.x_ - min_r,
param.y_ - min_r,
min_r * 2,
min_r * 2 ) );
? dconf.leftGoaliePen()
: dconf.rightGoaliePen() );
painter.drawEllipse( QRectF( param.x_ - draw_reliable_r,
param.y_ - draw_reliable_r,
draw_reliable_r * 2,
draw_reliable_r * 2 ) );
}

//
Expand Down
Loading

0 comments on commit 027f4f4

Please sign in to comment.