From b4ba6d6a8272d866fbff0c6f4e5fc32d615b20bc Mon Sep 17 00:00:00 2001 From: Person Date: Mon, 6 May 2019 19:29:27 -0700 Subject: [PATCH] --User changes -Add new variations waves22, waves23, waves42, waves3 and waves4 from user tatasz. -Add new stylesheet called lightdark.qss which gives a more modern look to the dark theme. Started by Michel Mastriani (triptychaos). --Included in the qmake and Wix installers. --Code changes -Add a new C# project that attempts to convert Apophysis plugins to Fractorium style Variation classes. It's not entirely perfect, but gets most of the job done much more quickly than doing so manually. -Remove unused OpenCL functions from variations: elliptic, poincare, mask, bMod, bSwirl, bTransform, bCollide, farblur, popcorn2_3D, falloff, falloff2, falloff3, crackle2, waves2b, hypercrop, depth_gaussian2, depth_sine, depth_sine2, dust, asteria, vibration, vibration2, arctanh, smartshape, squares, starblur2, Truchet,. -Add code in EmberTester to automatically detect such unused functions. --- Builds/MSVC/Installer/Product.wxs | 4 + Builds/MSVC/VS2017/Fractorium.sln | 35 +- Builds/QtCreator/Fractorium/Fractorium.pro | 2 + Data/lightdark.qss | 769 ++++++++++++++++++ Source/Ember/Ember.cpp | 5 + Source/Ember/EmberDefines.h | 1 + Source/Ember/Variation.h | 21 +- Source/Ember/VariationList.cpp | 5 + Source/Ember/Variations01.h | 5 - Source/Ember/Variations02.h | 21 +- Source/Ember/Variations03.h | 22 +- Source/Ember/Variations04.h | 5 - Source/Ember/Variations05.h | 11 +- Source/Ember/Variations06.h | 2 +- Source/Ember/Variations07.h | 509 +++++++++++- Source/EmberCL/EmberCLFunctions.h | 7 +- Source/EmberCL/EmberCLStructs.h | 1 + Source/EmberCL/IterOpenCLKernelCreator.cpp | 4 +- Source/EmberCL/RendererCL.cpp | 4 +- Source/EmberTester/EmberTester.cpp | 44 + Source/Fractorium/AboutDialog.ui | 6 +- Source/Fractorium/FinalRenderDialog.ui | 8 +- Source/Fractorium/Fractorium.ui | 232 +++--- Source/Fractorium/OptionsDialog.ui | 8 +- Source/apoconv/App.config | 6 + Source/apoconv/Form1.Designer.cs | 122 +++ Source/apoconv/Form1.cs | 597 ++++++++++++++ Source/apoconv/Form1.resx | 123 +++ Source/apoconv/Program.cs | 22 + Source/apoconv/Properties/AssemblyInfo.cs | 36 + .../apoconv/Properties/Resources.Designer.cs | 71 ++ Source/apoconv/Properties/Resources.resx | 117 +++ .../apoconv/Properties/Settings.Designer.cs | 30 + Source/apoconv/Properties/Settings.settings | 7 + Source/apoconv/apoconv.csproj | 83 ++ 35 files changed, 2738 insertions(+), 207 deletions(-) create mode 100644 Data/lightdark.qss create mode 100644 Source/apoconv/App.config create mode 100644 Source/apoconv/Form1.Designer.cs create mode 100644 Source/apoconv/Form1.cs create mode 100644 Source/apoconv/Form1.resx create mode 100644 Source/apoconv/Program.cs create mode 100644 Source/apoconv/Properties/AssemblyInfo.cs create mode 100644 Source/apoconv/Properties/Resources.Designer.cs create mode 100644 Source/apoconv/Properties/Resources.resx create mode 100644 Source/apoconv/Properties/Settings.Designer.cs create mode 100644 Source/apoconv/Properties/Settings.settings create mode 100644 Source/apoconv/apoconv.csproj diff --git a/Builds/MSVC/Installer/Product.wxs b/Builds/MSVC/Installer/Product.wxs index a429897..e87244b 100644 --- a/Builds/MSVC/Installer/Product.wxs +++ b/Builds/MSVC/Installer/Product.wxs @@ -264,6 +264,10 @@ + + + + diff --git a/Builds/MSVC/VS2017/Fractorium.sln b/Builds/MSVC/VS2017/Fractorium.sln index fe074a1..c66be39 100644 --- a/Builds/MSVC/VS2017/Fractorium.sln +++ b/Builds/MSVC/VS2017/Fractorium.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ember", "Ember.vcxproj", "{2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}" EndProject @@ -32,45 +32,76 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\..\..\Data\Version History.txt = ..\..\..\Data\Version History.txt EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "apoconv", "..\..\..\Source\apoconv\apoconv.csproj", "{4F78C421-8985-4411-8FFD-B0F323F857BE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}.Debug|Any CPU.ActiveCfg = Debug|x64 {2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}.Debug|x64.ActiveCfg = Debug|x64 {2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}.Debug|x64.Build.0 = Debug|x64 + {2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}.Release|Any CPU.ActiveCfg = Release|x64 {2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}.Release|x64.ActiveCfg = Release|x64 {2BDB7A54-BB1A-476B-A6E5-F81E90AD4E67}.Release|x64.Build.0 = Release|x64 + {320F611A-F9CE-4196-A8DC-FA24B2E8A320}.Debug|Any CPU.ActiveCfg = Debug|x64 {320F611A-F9CE-4196-A8DC-FA24B2E8A320}.Debug|x64.ActiveCfg = Debug|x64 {320F611A-F9CE-4196-A8DC-FA24B2E8A320}.Debug|x64.Build.0 = Debug|x64 + {320F611A-F9CE-4196-A8DC-FA24B2E8A320}.Release|Any CPU.ActiveCfg = Release|x64 {320F611A-F9CE-4196-A8DC-FA24B2E8A320}.Release|x64.ActiveCfg = Release|x64 {320F611A-F9CE-4196-A8DC-FA24B2E8A320}.Release|x64.Build.0 = Release|x64 + {6547D5FA-64CE-44BA-9D3C-B6E217456445}.Debug|Any CPU.ActiveCfg = Debug|x64 {6547D5FA-64CE-44BA-9D3C-B6E217456445}.Debug|x64.ActiveCfg = Debug|x64 {6547D5FA-64CE-44BA-9D3C-B6E217456445}.Debug|x64.Build.0 = Debug|x64 + {6547D5FA-64CE-44BA-9D3C-B6E217456445}.Release|Any CPU.ActiveCfg = Release|x64 {6547D5FA-64CE-44BA-9D3C-B6E217456445}.Release|x64.ActiveCfg = Release|x64 {6547D5FA-64CE-44BA-9D3C-B6E217456445}.Release|x64.Build.0 = Release|x64 + {4A191F4C-03AC-4F1B-AFFD-F5483ECEBD29}.Debug|Any CPU.ActiveCfg = Debug|x64 {4A191F4C-03AC-4F1B-AFFD-F5483ECEBD29}.Debug|x64.ActiveCfg = Debug|x64 {4A191F4C-03AC-4F1B-AFFD-F5483ECEBD29}.Debug|x64.Build.0 = Debug|x64 + {4A191F4C-03AC-4F1B-AFFD-F5483ECEBD29}.Release|Any CPU.ActiveCfg = Release|x64 {4A191F4C-03AC-4F1B-AFFD-F5483ECEBD29}.Release|x64.ActiveCfg = Release|x64 {4A191F4C-03AC-4F1B-AFFD-F5483ECEBD29}.Release|x64.Build.0 = Release|x64 + {35285FCF-6FA8-410E-841B-70AE744D38B8}.Debug|Any CPU.ActiveCfg = Debug|x64 {35285FCF-6FA8-410E-841B-70AE744D38B8}.Debug|x64.ActiveCfg = Debug|x64 {35285FCF-6FA8-410E-841B-70AE744D38B8}.Debug|x64.Build.0 = Debug|x64 + {35285FCF-6FA8-410E-841B-70AE744D38B8}.Release|Any CPU.ActiveCfg = Release|x64 {35285FCF-6FA8-410E-841B-70AE744D38B8}.Release|x64.ActiveCfg = Release|x64 {35285FCF-6FA8-410E-841B-70AE744D38B8}.Release|x64.Build.0 = Release|x64 + {7930CAAC-9FC4-4202-B6A3-E760F73F88B7}.Debug|Any CPU.ActiveCfg = Debug|x64 {7930CAAC-9FC4-4202-B6A3-E760F73F88B7}.Debug|x64.ActiveCfg = Debug|x64 {7930CAAC-9FC4-4202-B6A3-E760F73F88B7}.Debug|x64.Build.0 = Debug|x64 + {7930CAAC-9FC4-4202-B6A3-E760F73F88B7}.Release|Any CPU.ActiveCfg = Release|x64 {7930CAAC-9FC4-4202-B6A3-E760F73F88B7}.Release|x64.ActiveCfg = Release|x64 {7930CAAC-9FC4-4202-B6A3-E760F73F88B7}.Release|x64.Build.0 = Release|x64 + {F6A9102C-69A9-48FB-BC4B-49E49AF43236}.Debug|Any CPU.ActiveCfg = Debug|x64 {F6A9102C-69A9-48FB-BC4B-49E49AF43236}.Debug|x64.ActiveCfg = Debug|x64 {F6A9102C-69A9-48FB-BC4B-49E49AF43236}.Debug|x64.Build.0 = Debug|x64 + {F6A9102C-69A9-48FB-BC4B-49E49AF43236}.Release|Any CPU.ActiveCfg = Release|x64 {F6A9102C-69A9-48FB-BC4B-49E49AF43236}.Release|x64.ActiveCfg = Release|x64 {F6A9102C-69A9-48FB-BC4B-49E49AF43236}.Release|x64.Build.0 = Release|x64 + {C8096C47-E358-438C-A520-146D46B0637D}.Debug|Any CPU.ActiveCfg = Debug|x86 {C8096C47-E358-438C-A520-146D46B0637D}.Debug|x64.ActiveCfg = Debug|x64 + {C8096C47-E358-438C-A520-146D46B0637D}.Release|Any CPU.ActiveCfg = Release|x86 {C8096C47-E358-438C-A520-146D46B0637D}.Release|x64.ActiveCfg = Release|x64 {C8096C47-E358-438C-A520-146D46B0637D}.Release|x64.Build.0 = Release|x64 + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Debug|x64.Build.0 = Debug|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Release|Any CPU.Build.0 = Release|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Release|x64.ActiveCfg = Release|Any CPU + {4F78C421-8985-4411-8FFD-B0F323F857BE}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C7C67FAD-9040-4BCB-8613-18DFE58D38C4} + EndGlobalSection EndGlobal diff --git a/Builds/QtCreator/Fractorium/Fractorium.pro b/Builds/QtCreator/Fractorium/Fractorium.pro index 31d14b2..5a62514 100644 --- a/Builds/QtCreator/Fractorium/Fractorium.pro +++ b/Builds/QtCreator/Fractorium/Fractorium.pro @@ -98,6 +98,8 @@ unix:!macx { themes.files = $$ASSETS_DIR/dark_linux.qss } +themes.files += $$ASSETS_DIR/lightdark.qss + #message(THEMES INSTALL SOURCE: $$themes.files) INSTALLS += themes diff --git a/Data/lightdark.qss b/Data/lightdark.qss new file mode 100644 index 0000000..611ac95 --- /dev/null +++ b/Data/lightdark.qss @@ -0,0 +1,769 @@ +* +{ + font: 8.5pt "MS Shell Dlg 2";/*For some reason the font changes if you set any style. Set this to whatever font is the default on your system*/ +} + +QObject +{ + background-color: #5e5e5e; + color: rgb(224, 224, 224); + alternate-background-color: #5e5e5e; + selection-color: black; + selection-background-color: #7cabf9; +} + +QObject:disabled +{ + color: rgba(255, 255, 255, 40); +} + +/*This is needed to give the labels on the status bar some padding.*/ +QStatusBar QLabel { padding-left: 2px; padding-right: 2px; } + +Fractorium +{ + qproperty-VariationTreeColorNonZero:black; + qproperty-VariationTreeColorZero:white; + qproperty-VariationTreeBgColorNonZero: #AAAAAA; + qproperty-VariationTreeBgColorZero:#5e5e5e; +} + +/*================================================================================================== +QTableView +==================================================================================================*/ + +/*For some reason, Qt does not draw table headers correctly, so the style must always be manually specified.*/ +QHeaderView::section::vertical:enabled +{ + width: 12px; + color: black; + background-color: lightgray; + border: none; + padding: 0px; + padding-left: 4px; +} + +QHeaderView::section::horizontal:enabled +{ + height: 18px; + color: black; + background-color: lightgray; + border: none; + padding: 0px; + padding-left: 4px; +} + +QHeaderView::section::vertical:disabled +{ + width: 12px; + color: rgb(35, 35, 35); + background-color: rgb(53, 53, 53); + border: none; + padding: 0px; + padding-left: 4px; +} + +QHeaderView::section::horizontal:disabled +{ + height: 18px; + color:rgb(35, 35, 35); + background-color: rgb(53, 53, 53); + border: none; + padding: 0px; + padding-left: 4px; +} + +QTableView +{ + border: 1px solid lightgray; + gridline-color: gray; + selection-color: darkgray; + selection-background-color: rgb(53, 53, 53); +} + +QTableView QTableCornerButton::section:enabled +{ + border: none; + background-color: lightgray; +} + +QTableView QTableCornerButton::section:disabled +{ + border: none; + background-color: rgb(53, 53, 53); +} + +QTableView::indicator:disabled +{ + background-color: rgb(53, 53, 53); +} + +QTableView:disabled +{ + color: rgb(35, 35, 35); + border: 1px solid rgb(53, 53, 53); + gridline-color: rgb(35, 35, 35); +} + +QTableWidget +{ + border: 1px solid lightgray; +} + +/*================================================================================================== +QScrollBar +==================================================================================================*/ + +QScrollBar::vertical +{ + background-color: darkgray; + border: 0px solid darkgray; + width: 15px; + margin: 22px 0 22px 0; +} + +QScrollBar::handle::vertical +{ + background-color: gray; + border-top: 1px solid darkgray; + border-bottom: 1px solid darkgray; + min-height: 20px; +} + +QScrollBar::add-line::vertical +{ + border: 0px solid darkgray; + background-color: gray; + height: 22px; + subcontrol-position: bottom; + subcontrol-origin: margin; +} + +QScrollBar::sub-line::vertical +{ + border: 0px solid darkgray; + background-color: gray; + height: 22px; + subcontrol-position: top; + subcontrol-origin: margin; +} + +QScrollBar::up-arrow::vertical, QScrollBar::down-arrow::vertical +{ + border: 2px solid darkgray; + width: 5px; + height: 12px; + background-color: gray; +} + +QScrollBar::add-page::vertical, +QScrollBar::sub-page::vertical, +QScrollBar::add-page::horizontal, +QScrollBar::sub-page::horizontal +{ + background-color: darkgray; +} + +QScrollBar::horizontal +{ + background-color: darkgray; + border: 0px solid darkgray; + height: 15px; + margin: 0px 20px 0 20px; +} + +QScrollBar::handle::horizontal +{ + background-color: gray; + border-left: 1px solid darkgray; + border-right: 1px solid darkgray; + min-width: 20px; +} + +QScrollBar::add-line::horizontal +{ + border: 0px solid darkgray; + background-color: gray; + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} + +QScrollBar::sub-line::horizontal +{ + border: 0px solid darkgray; + background-color: gray; + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} + +QScrollBar::left-arrow::horizontal, +QScrollBar::right-arrow::horizontal +{ + border: 2px solid darkgray; + width: 12px; + height: 5px; + background-color: gray; +} + +/*================================================================================================== +QMenu +==================================================================================================*/ + +QMenuBar::item +{ + padding: 4px; +} + +QMenuBar::item:selected +{ + background: #7cabf9; + color: #000000; +} + +QMenu +{ + border: none; + margin: 0; + menu-scrollable: 0; +} + +QMenu::icon +{ + margin: 5px; +} + +QMenu::item +{ + padding: 5px 30px 5px 30px; +} + +QMenu::item:enabled:selected +{ + background: #7cabf9; + color: #000000; +} + +QMenu::item:disabled +{ + color: #A0A0A0; +} + +QMenu::separator +{ + height: 1px; + background: #A9A9A9; + margin: 0; +} + +/*================================================================================================== +Dock widget +==================================================================================================*/ + +QDockWidget::title +{ + text-align: center; + background-color: rgba(0,0,0,20); + border: 2px solid #5e5e5e; /* fix to simulate margin between this :title and tabs */ /* same as main background color */ + border-radius: 6px; /* bigger than normal due to previous border fix */ + padding: 4px 0px; /* also needed because of previous border fix */ +} + +QDockWidget::float-button +{ + background: gray; + border-radius: 3px; + subcontrol-origin: padding; + subcontrol-position: right center; +} + +QDockWidget::float-button +{ + right: 4px; +} + +QDockWidget::float-button:hover +{ + background-color: rgba(255,255,255,15); +} + +QDockWidget::float-button:pressed +{ + background-color: rgba(255,255,255,30); +} + +/*================================================================================================== +QTabWidget +==================================================================================================*/ + +QTabWidget::pane +{ + background-color: transparent; + position: absolute; +} +QTabWidget::pane:top +{ + top: -1px; + border-top: 1px solid #4a4a4a; +} + +QTabWidget::pane:bottom +{ + bottom: -1px; + border-bottom: 1px solid #4a4a4a; +} + +QTabWidget::pane:left +{ + right: -1px; + border-right: 1px solid #4a4a4a; +} + +QTabWidget::pane:right +{ + left: -1px; + border-left: 1px solid #4a4a4a; +} + +QTabWidget::tab-bar:top, +QTabWidget::tab-bar:bottom +{ + left: 5px; +} + +QTabWidget::tab-bar:left, +QTabWidget::tab-bar:right +{ + top: 5px; +} + +/*================================================================================================== +QTabBar +==================================================================================================*/ + +QTabBar +{ + qproperty-drawBase: 0; /* important */ + background-color: transparent; +} + +/* Workaround for QTabBars created from docked QDockWidgets which don't draw the border if not set and reseted as follows: */ +QTabBar +{ + border-top: 0px; + border-bottom: 1px solid #4a4a4a; +} + +QDockWidget QTabBar +{ + border-color: transparent; /* set color for all QTabBars but ones created from QDockWidget */ +} + +QDialog QTabBar +{ + border-color: transparent; /* set color for QTabBars inside Preferences dialog */ +} +/* end fix */ + +QTabBar::tab +{ + background-color: transparent; + border: 1px solid transparent; + padding: 4px 4px 4px 4px; + margin: 0px; +} + +QDialog QTabBar::tab:top +{ + background-color: transparent; + border: 1px solid transparent; + padding: 4px 4px 4px 4px; + min-width: 20ex; +} + +QTabBar::tab:left, +QTabBar::tab:right +{ + border-left-width: 0px; + border-right-width: 4px; + min-height: 9ex; +} + +QTabBar::tab:top, +QTabBar::tab:bottom +{ + border-top-width: 0px; + border-bottom-width: 4px; + min-width: 9ex; +} + +QDialog QTabBar::tab:selected, +QTabBar::tab:selected +{ + background-color: #5e5e5e; /* same as tab content background color */ + border-color: #4a4a4a; +} + +QTabBar::tab:top:selected +{ + border-top: 3px solid qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5e90fa, stop:1 #3874f2); /* selection color */ + border-bottom-color: #5e5e5e; /* same as tab content background color */ +} + +QTabBar::tab:bottom:selected +{ + border-bottom: 3px solid qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5e90fa, stop:1 #3874f2); /* selection color */ + border-right-color: #5e5e5e; /* same as tab content background color */ +} + +QTabBar::tab:right:selected +{ + border-left: 3px solid qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #5e90fa, stop:1 #3874f2); /* selection color */ + border-right-color: #5e5e5e; /* same as tab content background color */ +} + +QTabBar::tab:left:selected +{ + border-right: 3px solid qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #5e90fa, stop:1 #3874f2); /* selection color */ + border-left-color: #5e5e5e; /* same as tab content background color */ +} + +QTabBar::tab:first:selected +{ + margin-left: 4px; /* the first selected tab has nothing to overlap with on the left */ +} + +QTabBar::tab:last:selected +{ + margin-right: 4px; /* the last selected tab has nothing to overlap with on the right */ +} + +QTabBar::tab:only-one +{ + margin: 0; /* if there is only one tab, we don't want overlapping margins */ +} + +/*================================================================================================== +QToolBar +==================================================================================================*/ + +QToolBar +{ + padding: 0px; + border: 0px none gray; +} + +QToolBar > QToolButton +{ + margin: 1px; + padding: 1px; + border-radius: 3px; + border: 1px solid #5e5e5e; + position: relative; + subcontrol-position: right; + subcontrol-origin: margin; +} + +QDialog > QToolBar > QToolButton +{ + width: 95px; + margin: 0px; + padding: 0px; + border-radius: 3px; + border: 1px solid #5e5e5e; +} + +QDialog > QToolBar > QToolButton::menu-button +{ + left: -2px; + border-radius: 3px; + border: 1px solid #5e5e5e; +} + +/* when QToolButton is checked: */ +QToolBar > QToolButton:checked +{ + border: 1px solid #7cabf9; + background-color: rgba(124,171,249,60); /* transparency for #7cabf9 color */ +} + +QToolBar > QToolButton:checked:hover +{ + border: 1px solid #7cabf9; + background-color: rgba(124,171,249,80); /* transparency for #7cabf9 color */ +} + +QToolBar > QToolButton:hover +{ + background-color: rgba(0,0,0,20); +} + +QToolBar > QToolButton:pressed +{ + background-color: rgba(0,0,0,40); +} + +QToolBar > QToolButton:disabled +{ + background-color: rgba(0, 0, 0, 50); +} + +/*================================================================================================== +Remainder from the previous attempt at a stylesheet, dark_windows.qss +==================================================================================================*/ + +QPushButton +{ + margin: 1px; + padding: 4px; +} + +QPushButton:pressed +{ + background-color: gray; +} + +QPushButton:focus +{ + outline: none; +} + +QLineEdit, QTextEdit +{ + border: 2px solid gray; + color: darkgray; + background-color: rgb(40, 40, 50); +} + +QSpinBox, +QDoubleSpinBox +{ + padding-right: 0px; +} + +QCheckBox +{ + spacing: 5px; +} + +QCheckBox::indicator, +QTableView::indicator, +QGroupBox::indicator +{ + border: none; + border-radius: 3px; +} + +QCheckBox::indicator:enabled:unchecked, +QTableView::indicator:enabled:unchecked, +QGroupBox::indicator:enabled:unchecked +{ + background-color: lightgray; + image: url(:/Fractorium/Icons/checkbox_unchecked.png); +} + +QCheckBox::indicator:enabled:checked, +QTableView::indicator:enabled:checked, +QGroupBox::indicator:enabled:checked +{ + background-color: lightgray; + image: url(:/Fractorium/Icons/checkbox_checked.png); +} + +QCheckBox::indicator:disabled:unchecked, +QTableView::indicator:disabled:unchecked, +QGroupBox::indicator:disabled:unchecked +{ + background-color: gray; + image: none; +} + +QCheckBox::indicator:disabled:checked, +QTableView::indicator:disabled:checked, +QGroupBox::indicator:disabled:checked +{ + background-color: gray; + image: none; +} + +QRadioButton::indicator:checked +{ + background-color: black; + border: 2px solid gray; + border-radius: 7px; + width: 8px; + height: 8px; + margin: 3px; + padding: 1px; +} + +QRadioButton::indicator:checked:disabled +{ + background-color: rgb(35, 35, 35); +} + +QRadioButton::indicator:unchecked +{ + border: 2px solid gray; + border-radius: 7px; + width: 8px; + height: 8px; + margin: 3px; + padding: 1px; +} + +QComboBox +{ + margin: 1px; + padding-left: 4px; + border: 1px solid gray; +} + +QComboBox::down-arrow:enabled +{ + border: 1px solid gray; + margin-right: 2px; + margin-top: 0px; + margin-bottom: 1px; +} + +QComboBox::down-arrow:disabled +{ + border: 1px solid rgb(35, 35, 35); + margin-right: 2px; + margin-top: 0px; + margin-bottom: 1px; +} + +QComboBox::drop-down +{ + border: none; +} + +QComboBox QAbstractItemView +{ + border: 1px solid gray; + outline: none; +} + +QProgressBar +{ + color: black; + background-color: gray; + border: 0px none gray; + border-radius: 3px; + text-align: center; +} + +QProgressBar::chunk +{ + border-radius: 3px; + background-color: lightgray; +} + +QStatusBar QProgressBar +{ + min-width: 300px; + max-width: 300px; + margin-right: 4px; +} + +QGroupBox +{ + padding-top: 8px; + border: 2px solid gray; + border-radius: 4px; + margin-top: 3ex; +} + +QGroupBox::title +{ + subcontrol-origin: border; + subcontrol-position: top left; + margin-top: 1ex; + margin-left: 0px; + padding-right: 0px; + padding-left: 0px; + top: -2ex; + left: 8px; +} + +/*Setting this gives a more consistent look. Also, by omitting color and background color, it allows us to set it above with VariationTreeColorNonZero etc...*/ +QTreeView +{ + background-color: #5e5e5e; +} + +QTreeView::item +{ + outline: none; + margin-right: 1px; +} + +QTreeView::item:selected, +QTreeView::item:hover +{ + border: 0px none black; + background-color: #7cabf9; + outline: none; +} + +/*Specific controls*/ +QLineEdit#PaletteFilterLineEdit, +QLineEdit#VariationsFilterLineEdit +{ + height: 20px; + min-height: 20px; + max-height: 20px; +} + +QSpinBox#ThreadCountSpin, +QSpinBox#RandomCountSpin, +QSpinBox#CpuSubBatchSpin, +QSpinBox#OpenCLSubBatchSpin, +QSpinBox#CpuQualitySpin, +QSpinBox#OpenCLQualitySpin, +QDoubleSpinBox#OpenCLSubBatchPctSpin, +QSpinBox#FinalRenderCurrentSpin, +QSpinBox#FinalRenderThreadCountSpin, +QDoubleSpinBox#FinalRenderOpenCLSubBatchPctSpin +{ + padding: 2px; + border: 1px solid gray;/*Even though we normally use lightgray for borders, gray looks nicer here*/ +} + +QTableView#FinalRenderParamsTable QComboBox +{ + margin-top: 0px; + margin-bottom: 0px; +} + +QTableView#FinalRenderParamsTable QPushButton +{ + margin-top: 1px; + margin-bottom: 2px; +} + +QTableView#XaosTableView QHeaderView::section::vertical, +QTableView#XaosDistVizTableWidget QHeaderView::section::vertical, +QTableView#XaosAppliedTableView QHeaderView::section::vertical +{ + width: 19px; +} + +QTableView#SummaryTable QHeaderView::section::vertical +{ + width: 69px; +} + +QssDialog QssTextEdit#QssEdit +{ + background-color: #FFFCE1; +} + +QTextEdit#CreditsTextBrowser +{ + background-color: #FFFCE1; +} + diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp index c4c3d0e..75678f6 100644 --- a/Source/Ember/Ember.cpp +++ b/Source/Ember/Ember.cpp @@ -484,6 +484,11 @@ uint Timing::m_ProcessorCount; EXPORTPREPOSTREGVAR(DCTriangle, T) \ EXPORTPREPOSTREGVAR(RandCubes, T) \ EXPORTPREPOSTREGVAR(PixelFlow, T) \ + EXPORTPREPOSTREGVAR(Waves22, T) \ + EXPORTPREPOSTREGVAR(Waves23, T) \ + EXPORTPREPOSTREGVAR(Waves42, T) \ + EXPORTPREPOSTREGVAR(Waves3, T) \ + EXPORTPREPOSTREGVAR(Waves4, T) \ template EMBER_API class VariationList; \ template EMBER_API class SpatialFilter; \ template EMBER_API class GaussianFilter; \ diff --git a/Source/Ember/EmberDefines.h b/Source/Ember/EmberDefines.h index 38bec6e..edd279f 100644 --- a/Source/Ember/EmberDefines.h +++ b/Source/Ember/EmberDefines.h @@ -52,6 +52,7 @@ namespace EmberNs #define M_3PI (T(M_PI * 3)) #define SQRT5 T(2.2360679774997896964091736687313) #define M_PHI T(1.61803398874989484820458683436563) +#define M_1_2PI T(0.15915494309189533576888376337251) #define COLORMAP_LENGTH 256//These will need to change if 2D palette support is ever added, or variable sized palettes. #define WHITE 255 #define DEFAULT_SBS (1024 * 10) diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index cdaf277..2eb2caf 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -434,9 +434,14 @@ enum class eVariationId : et VAR_WAFFLE, VAR_WAVES , VAR_WAVES2 , - VAR_WAVES2_RADIAL, + VAR_WAVES22, + VAR_WAVES23, VAR_WAVES23D , VAR_WAVES2B , + VAR_WAVES2_RADIAL, + VAR_WAVES3, + VAR_WAVES4, + VAR_WAVES42, VAR_WAVESN , VAR_WDISC , VAR_WEDGE , @@ -841,9 +846,14 @@ enum class eVariationId : et VAR_PRE_WAFFLE, VAR_PRE_WAVES, VAR_PRE_WAVES2, - VAR_PRE_WAVES2_RADIAL, + VAR_PRE_WAVES22, + VAR_PRE_WAVES23, VAR_PRE_WAVES23D, VAR_PRE_WAVES2B, + VAR_PRE_WAVES2_RADIAL, + VAR_PRE_WAVES3, + VAR_PRE_WAVES4, + VAR_PRE_WAVES42, VAR_PRE_WAVESN, VAR_PRE_WDISC, VAR_PRE_WEDGE, @@ -1248,9 +1258,14 @@ enum class eVariationId : et VAR_POST_WAFFLE, VAR_POST_WAVES, VAR_POST_WAVES2, - VAR_POST_WAVES2_RADIAL, + VAR_POST_WAVES22, + VAR_POST_WAVES23, VAR_POST_WAVES23D, VAR_POST_WAVES2B, + VAR_POST_WAVES2_RADIAL, + VAR_POST_WAVES3, + VAR_POST_WAVES4, + VAR_POST_WAVES42, VAR_POST_WAVESN, VAR_POST_WDISC, VAR_POST_WEDGE, diff --git a/Source/Ember/VariationList.cpp b/Source/Ember/VariationList.cpp index 6327510..08fcc10 100644 --- a/Source/Ember/VariationList.cpp +++ b/Source/Ember/VariationList.cpp @@ -423,6 +423,11 @@ VariationList::VariationList() ADDPREPOSTREGVAR(Modulusy) ADDPREPOSTREGVAR(Rotate) ADDPREPOSTREGVAR(Shift) + ADDPREPOSTREGVAR(Waves22) + ADDPREPOSTREGVAR(Waves23) + ADDPREPOSTREGVAR(Waves3) + ADDPREPOSTREGVAR(Waves4) + ADDPREPOSTREGVAR(Waves42) //ADDPREPOSTREGVAR(LinearXZ) //ADDPREPOSTREGVAR(LinearYZ) //DC are special. diff --git a/Source/Ember/Variations01.h b/Source/Ember/Variations01.h index 79c2e26..104db55 100644 --- a/Source/Ember/Variations01.h +++ b/Source/Ember/Variations01.h @@ -4355,11 +4355,6 @@ public: return ss.str(); } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Zeps" }; - } - virtual string OpenCLFuncsString() const override { return diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index a5ea044..b33b3a6 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -4460,7 +4460,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Zeps" }; + return vector { "Zeps" }; } protected: @@ -5016,8 +5016,8 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T c0 = m_Ax / (1 + std::exp(m_Sx * helper.In.x)); - T c1 = m_Ay / (1 + std::exp(m_Sy * helper.In.y)); + T c0 = m_Ax / Zeps(1 + std::exp(m_Sx * helper.In.x)); + T c1 = m_Ay / Zeps(1 + std::exp(m_Sy * helper.In.y)); T x = (2 * (c0 - T(0.5))); T y = (2 * (c1 - T(0.5))); helper.Out.x = m_Vv * x; @@ -5040,8 +5040,8 @@ public: string ay = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" - << "\t\treal_t c0 = " << ax << " / (1 + exp(" << sx << " * vIn.x));\n" - << "\t\treal_t c1 = " << ay << " / (1 + exp(" << sy << " * vIn.y));\n" + << "\t\treal_t c0 = " << ax << " / Zeps(1 + exp(" << sx << " * vIn.x));\n" + << "\t\treal_t c1 = " << ay << " / Zeps(1 + exp(" << sy << " * vIn.y));\n" << "\t\treal_t x = (2 * (c0 - (real_t)(0.5)));\n" << "\t\treal_t y = (2 * (c1 - (real_t)(0.5)));\n" << "\n" @@ -5793,11 +5793,6 @@ public: << "\t}\n"; return ss.str(); } - - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Sqr" }; - } }; /// @@ -5813,7 +5808,7 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T d = m_Weight / helper.m_PrecalcSumSquares; + T d = m_Weight / Zeps(helper.m_PrecalcSumSquares); T sinx = std::sin(helper.In.x); T sinx2 = SQR(sinx); T cosx = std::cos(helper.In.x); @@ -5829,7 +5824,7 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t d = " << weight << " / precalcSumSquares;\n" + << "\t\treal_t d = " << weight << " / Zeps(precalcSumSquares);\n" << "\t\treal_t sinx = sin(vIn.x);\n" << "\t\treal_t sinx2 = SQR(sinx);\n" << "\t\treal_t cosx = cos(vIn.x);\n" @@ -5844,7 +5839,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Zeps" }; } }; diff --git a/Source/Ember/Variations03.h b/Source/Ember/Variations03.h index 239dede..d6c550a 100644 --- a/Source/Ember/Variations03.h +++ b/Source/Ember/Variations03.h @@ -2286,9 +2286,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T e = 1 / helper.m_PrecalcSumSquares + SQR(T(M_2_PI)); - helper.Out.x = m_Weight * (m_Weight / helper.m_PrecalcSumSquares * helper.In.x / e); - helper.Out.y = m_Weight * (m_Weight / helper.m_PrecalcSumSquares * helper.In.y / e); + T e = 1 / Zeps(helper.m_PrecalcSumSquares) + SQR(T(M_2_PI)); + T temp = m_Weight / Zeps(helper.m_PrecalcSumSquares); + helper.Out.x = m_Weight * (temp * helper.In.x / e); + helper.Out.y = m_Weight * (temp * helper.In.y / e); helper.Out.z = DefaultZ(helper); } @@ -2298,10 +2299,11 @@ public: intmax_t varIndex = IndexInXform(); string weight = WeightDefineString(); ss << "\t{\n" - << "\t\treal_t e = fma(M2PI, M2PI, 1 / precalcSumSquares);\n" + << "\t\treal_t e = fma(M2PI, M2PI, 1 / Zeps(precalcSumSquares));\n" << "\n" - << "\t\tvOut.x = " << weight << " * (" << weight << " / precalcSumSquares * vIn.x / e);\n" - << "\t\tvOut.y = " << weight << " * (" << weight << " / precalcSumSquares * vIn.y / e);\n" + << "\t\treal_t temp = " << weight << " / Zeps(precalcSumSquares);\n" + << "\t\tvOut.x = " << weight << " * (temp * vIn.x / e);\n" + << "\t\tvOut.y = " << weight << " * (temp * vIn.y / e);\n" << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); @@ -3804,7 +3806,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Zeps" }; + return vector { "Zeps" }; } protected: @@ -3877,7 +3879,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Zeps" }; + return vector { "Zeps" }; } protected: @@ -3963,7 +3965,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Zeps" }; + return vector { "Zeps" }; } protected: @@ -4054,7 +4056,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Zeps" }; + return vector { "Zeps" }; } virtual void Precalc() override diff --git a/Source/Ember/Variations04.h b/Source/Ember/Variations04.h index 2a8515c..6bd5682 100644 --- a/Source/Ember/Variations04.h +++ b/Source/Ember/Variations04.h @@ -3001,11 +3001,6 @@ public: return ss.str(); } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Sqr" }; - } - protected: void Init() { diff --git a/Source/Ember/Variations05.h b/Source/Ember/Variations05.h index 520ab10..d517495 100644 --- a/Source/Ember/Variations05.h +++ b/Source/Ember/Variations05.h @@ -1995,11 +1995,6 @@ public: return ss.str(); } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Sqr" }; - } - virtual void Precalc() override { m_SinTanC = std::sin(SafeTan(m_C)); @@ -2547,7 +2542,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Lerp" }; + return vector { "Lerp" }; } virtual void Precalc() override @@ -2751,7 +2746,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr", "Zeps" }; + return vector { "Zeps" }; } virtual void Precalc() override @@ -2984,7 +2979,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "SignNz", "LogMap", "LogScale", "Sqr", "Zeps" }; + return vector { "SignNz", "LogMap", "LogScale", "Zeps" }; } virtual void Precalc() override diff --git a/Source/Ember/Variations06.h b/Source/Ember/Variations06.h index 17cf86b..be626d1 100644 --- a/Source/Ember/Variations06.h +++ b/Source/Ember/Variations06.h @@ -4014,7 +4014,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Fract", "HashShadertoy" }; + return vector { "Fract", "HashShadertoy" }; } virtual void Precalc() override diff --git a/Source/Ember/Variations07.h b/Source/Ember/Variations07.h index 6615e1a..e9313bc 100644 --- a/Source/Ember/Variations07.h +++ b/Source/Ember/Variations07.h @@ -202,7 +202,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Sqr", "SignNz", "SafeDivInv", "JacobiElliptic", "EvalRational", "J1" }; + return vector { "Zeps", "SignNz", "SafeDivInv", "JacobiElliptic", "EvalRational", "J1" }; } virtual vector OpenCLGlobalDataNames() const override @@ -1966,7 +1966,7 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T lvl = (Floor(rand.Frand01() * m_Density) / Zeps(m_Density)); //random level. should care if density=0 but meh, works fine + T lvl = T(Floor(rand.Frand01() * m_Density) / Zeps(m_Density)); //random level. should care if density=0 but meh, works fine T randa = rand.Frand01() * M_2PI; //random angle T randr = lvl * m_Radius; //calc radius of rings @@ -2173,7 +2173,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Sqr" }; + return vector { "Zeps" }; } protected: @@ -2983,7 +2983,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Sqr" }; + return vector { "Sqr" }; } protected: @@ -3337,11 +3337,6 @@ public: m_BlurOver10 = m_Blur / 10; } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Zeps" }; - } - protected: void Init() { @@ -3443,7 +3438,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Sqr" }; + return vector { "Sqr" }; } protected: @@ -3597,7 +3592,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Fract", "HashShadertoy" }; + return vector { "Fract", "HashShadertoy" }; } protected: @@ -3725,7 +3720,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Sqr" }; + return vector { "Sqr" }; } protected: @@ -3991,11 +3986,6 @@ public: m_PhaseShift2 = M_2PI * m_Phase2 / Zeps(m_Freq2); } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Zeps", "Sqr" }; - } - protected: void Init() { @@ -4192,7 +4182,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Sqr", "Modulate" }; + return vector { "Zeps", "Modulate" }; } protected: @@ -4542,7 +4532,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sign", "Zeps", "ComplexMultReal", "ComplexLog", "ComplexPlusReal", "ComplexDivComplex" }; + return vector { "Zeps", "ComplexMultReal", "ComplexLog", "ComplexPlusReal", "ComplexDivComplex" }; } protected: @@ -4961,11 +4951,6 @@ public: m_Comp = m_Compensation <= 0 ? T(0) : T(1); } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Zeps" }; - } - protected: void Init() { @@ -5110,7 +5095,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Fract", "HashShadertoy" }; + return vector { "Fract", "HashShadertoy" }; } protected: @@ -5250,11 +5235,6 @@ public: m_CosAlpha = std::cos(m_Alpha); } - virtual vector OpenCLGlobalFuncNames() const override - { - return vector { "Zeps", "Fract", "HashShadertoy" }; - } - protected: void Init() { @@ -5885,7 +5865,7 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Zeps", "Fract", "HashShadertoy" }; + return vector { "Fract", "HashShadertoy" }; } protected: @@ -6612,6 +6592,468 @@ private: T m_AngleRad;//Precalc. }; +/// +/// waves3. +/// By tatasz. +/// +template +class Waves3Variation : public ParametricVariation +{ +public: + Waves3Variation(T weight = 1.0) : ParametricVariation("waves3", eVariationId::VAR_WAVES3, weight) + { + Init(); + } + + PARVARCOPY(Waves3Variation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T x0 = helper.In.x; + T y0 = helper.In.y; + T scalex = T(0.5) * m_Scalex * (T(1.0) + std::sin(y0 * m_Sxfreq)); + T scaley = T(0.5) * m_Scaley * (T(1.0) + std::sin(x0 * m_Syfreq)); + helper.Out.x = m_Weight * (x0 + std::sin(y0 * m_Freqx) * scalex); + helper.Out.y = m_Weight * (y0 + std::sin(x0 * m_Freqy) * scaley); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sxfreq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string syfreq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t x0 = vIn.x;\n" + << "\t\treal_t y0 = vIn.y;\n" + << "\n" + << "\t\treal_t scalex = (real_t)(0.5) * " << scalex << " * ((real_t)(1.0) + sin(y0 * " << sxfreq << "));\n" + << "\t\treal_t scaley = (real_t)(0.5) * " << scaley << " * ((real_t)(1.0) + sin(x0 * " << syfreq << "));\n" + << "\n" + << "\t\tvOut.x = " << weight << " * (x0 + sin(y0 * " << freqx << ") * scalex);\n" + << "\t\tvOut.y = " << weight << " * (y0 + sin(x0 * " << freqy << ") * scaley);\n" + << "\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Scalex, prefix + "waves3_scalex", T(0.05))); + m_Params.push_back(ParamWithName(&m_Scaley, prefix + "waves3_scaley", T(0.05))); + m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves3_freqx", T(7.0))); + m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves3_freqy", T(13.0))); + m_Params.push_back(ParamWithName(&m_Sxfreq, prefix + "waves3_sx_freq")); + m_Params.push_back(ParamWithName(&m_Syfreq, prefix + "waves3_sy_freq", T(2.0))); + } + +private: + T m_Scalex; + T m_Scaley; + T m_Freqx; + T m_Freqy; + T m_Sxfreq; + T m_Syfreq; +}; + +/// +/// waves4. +/// By tatasz. +/// +template +class Waves4Variation : public ParametricVariation +{ +public: + Waves4Variation(T weight = 1.0) : ParametricVariation("waves4", eVariationId::VAR_WAVES4, weight) + { + Init(); + } + + PARVARCOPY(Waves4Variation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T x0 = helper.In.x; + T y0 = helper.In.y; + T ax = T(Floor(y0 * m_Freqx / M_2PI)); + ax = std::sin(ax * T(12.9898) + ax * T(78.233) + T(1.0) + y0 * T(0.001) * m_Yfact) * T(43758.5453); + ax = ax - (int)ax; + + if (m_Cont == 1) ax = (ax > T(0.5)) ? T(1.0) : T(0.0); + + helper.Out.x = m_Weight * (x0 + std::sin(y0 * m_Freqx) * ax * ax * m_Scalex); + helper.Out.y = m_Weight * (y0 + std::sin(x0 * m_Freqy) * m_Scaley); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cont = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yfact = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t x0 = vIn.x;\n" + << "\t\treal_t y0 = vIn.y;\n" + << "\n" + << "\t\treal_t ax = floor(y0 * " << freqx << " / M_2PI);\n" + << "\t\tax = sin(ax * (real_t)(12.9898) + ax * (real_t)(78.233) + (real_t)(1.0) + y0 * (real_t)(0.001) * " << yfact << ") * (real_t)(43758.5453);\n" + << "\t\tax = ax - (int) ax;\n" + << "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : 0.0;\n" + << "\n" + << "\t\tvOut.x = " << weight << " * (x0 + sin(y0 * " << freqx << ") * ax * ax * " << scalex << ");\n" + << "\t\tvOut.y = " << weight << " * (y0 + sin(x0 * " << freqy << ") * " << scaley << ");\n" + << "\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Scalex, prefix + "waves4_scalex", T(0.05))); + m_Params.push_back(ParamWithName(&m_Scaley, prefix + "waves4_scaley", T(0.05))); + m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves4_freqx", T(7.0))); + m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves4_freqy", T(13.0))); + m_Params.push_back(ParamWithName(&m_Cont, prefix + "waves4_cont", T(0), eParamType::INTEGER, T(0), T(1))); + m_Params.push_back(ParamWithName(&m_Yfact, prefix + "waves4_yfact", T(0.1))); + } + +private: + T m_Scalex; + T m_Scaley; + T m_Freqx; + T m_Freqy; + T m_Cont; + T m_Yfact; +}; + +/// +/// waves22. +/// By tatasz. +/// +template +class Waves22Variation : public ParametricVariation +{ +public: + Waves22Variation(T weight = 1.0) : ParametricVariation("waves22", eVariationId::VAR_WAVES22, weight) + { + Init(); + } + + PARVARCOPY(Waves22Variation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T x0 = helper.In.x; + T y0 = helper.In.y; + T sinx, siny; + int px = (int)m_Powerx; + int py = (int)m_Powery; + + if (m_Modex < T(0.5)) + { + sinx = std::sin(y0 * m_Freqx); + } + else + { + sinx = T(0.5) * (T(1.0) + std::sin(y0 * m_Freqx)); + } + + T offsetx = std::pow(sinx, px) * m_Scalex; + + if (m_Modey < T(0.5)) + { + siny = std::sin(x0 * m_Freqy); + } + else + { + siny = T(0.5) * (T(1.0) + std::sin(x0 * m_Freqy)); + } + + T offsety = std::pow(siny, py) * m_Scaley; + helper.Out.x = m_Weight * (x0 + offsetx); + helper.Out.y = m_Weight * (y0 + offsety); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string modex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string modey = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string powerx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string powery = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t x0 = vIn.x;\n" + << "\t\treal_t y0 = vIn.y;\n" + << "\n" + << "\t\treal_t sinx, siny;\n" + << "\n" + << "\t\tint px = (int) " << powerx << ";\n" + << "\t\tint py = (int) " << powery << ";\n" + << "\t\tif (" << modex << " < (real_t)(0.5)){\n" + << "\t\tsinx = sin(y0 * " << freqx << ");\n" + << "\t\t} else {\n" + << "\t\tsinx = (real_t)(0.5) * ((real_t)(1.0) + sin(y0 * " << freqx << "));\n" + << "\t\t}\n" + << "\t\treal_t offsetx = pow(sinx, px) * " << scalex << ";\n" + << "\t\tif (" << modey << " < (real_t)(0.5)){\n" + << "\t\tsiny = sin(x0 * " << freqy << ");\n" + << "\t\t} else {\n" + << "\t\tsiny = (real_t)(0.5) * ((real_t)(1.0) + sin(x0 * " << freqy << "));\n" + << "\t\t}\n" + << "\t\treal_t offsety = pow(siny, py) * " << scaley << ";\n" + << "\t\tvOut.x = " << weight << " * (x0 + offsetx);\n" + << "\t\tvOut.y = " << weight << " * (y0 + offsety);\n" + << "\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Scalex, prefix + "waves22_scalex", T(0.05))); + m_Params.push_back(ParamWithName(&m_Scaley, prefix + "waves22_scaley", T(0.05))); + m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves22_freqx", T(7.0))); + m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves22_freqy", T(13.0))); + m_Params.push_back(ParamWithName(&m_Modex, prefix + "waves22_modex", T(0), eParamType::INTEGER, T(0), T(1))); + m_Params.push_back(ParamWithName(&m_Modey, prefix + "waves22_modey", T(0), eParamType::INTEGER, T(0), T(1))); + m_Params.push_back(ParamWithName(&m_Powerx, prefix + "waves22_powerx", T(2.0))); + m_Params.push_back(ParamWithName(&m_Powery, prefix + "waves22_powery", T(2.0))); + } + +private: + T m_Scalex; + T m_Scaley; + T m_Freqx; + T m_Freqy; + T m_Modex; + T m_Modey; + T m_Powerx; + T m_Powery; +}; + +/// +/// waves23. +/// By tatasz. +/// +template +class Waves23Variation : public ParametricVariation +{ +public: + Waves23Variation(T weight = 1.0) : ParametricVariation("waves23", eVariationId::VAR_WAVES23, weight) + { + Init(); + } + + PARVARCOPY(Waves23Variation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T x0 = helper.In.x; + T y0 = helper.In.y; + T mx = y0 * m_Freqx * M_1_2PI; + T fx = mx - Floor(mx); + + if (fx > T(0.5)) fx = T(0.5) - fx; + + T my = x0 * m_Freqy * M_1_2PI; + T fy = my - Floor(my); + + if (fy > T(0.5)) fy = T(0.5) - fy; + + helper.Out.x = m_Weight * (x0 + fx * m_Scalex); + helper.Out.y = m_Weight * (y0 + fy * m_Scaley); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t x0 = vIn.x;\n" + << "\t\treal_t y0 = vIn.y;\n" + << "\n" + << "\t\treal_t mx = y0 * " << freqx << " * M_1_2PI;\n" + << "\t\treal_t fx = mx - floor(mx);\n" + << "\t\tif (fx > (real_t)(0.5)) fx = (real_t)(0.5) - fx;\n" + << "\t\treal_t my = x0 * " << freqy << " * M_1_2PI;\n" + << "\t\treal_t fy = my - floor(my);\n" + << "\t\tif (fy > (real_t)(0.5)) fy = (real_t)(0.5) - fy;\n" + << "\t\tvOut.x = " << weight << " * (x0 + fx * " << scalex << ");\n" + << "\t\tvOut.y = " << weight << " * (y0 + fy * " << scaley << ");\n" + << "\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Scalex, prefix + "waves23_scalex", T(0.05))); + m_Params.push_back(ParamWithName(&m_Scaley, prefix + "waves23_scaley", T(0.05))); + m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves23_freqx", T(7.0))); + m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves23_freqy", T(13.0))); + } + +private: + T m_Scalex; + T m_Scaley; + T m_Freqx; + T m_Freqy; +}; + +/// +/// waves42. +/// By tatasz. +/// +template +class Waves42Variation : public ParametricVariation +{ +public: + Waves42Variation(T weight = 1.0) : ParametricVariation("waves42", eVariationId::VAR_WAVES42, weight) + { + Init(); + } + + PARVARCOPY(Waves42Variation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T x0 = helper.In.x; + T y0 = helper.In.y; + T ax = T(Floor(y0 * m_Freqx2)); + ax = std::sin(ax * T(12.9898) + ax * T(78.233) + T(1.0) + y0 * T(0.001) * m_Yfact) * T(43758.5453); + ax = ax - (int)ax; + + if (m_Cont == 1) ax = (ax > T(0.5)) ? T(1.0) : T(0.0); + + helper.Out.x = m_Weight * (x0 + std::sin(y0 * m_Freqx) * ax * ax * m_Scalex); + helper.Out.y = m_Weight * (y0 + std::sin(x0 * m_Freqy) * m_Scaley); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cont = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string yfact = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqx2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t x0 = vIn.x;\n" + << "\t\treal_t y0 = vIn.y;\n" + << "\n" + << "\t\treal_t ax = floor(y0 * " << freqx2 << ");\n" + << "\t\tax = sin(ax * (real_t)(12.9898) + ax * (real_t)(78.233) + (real_t)(1.0) + y0 * (real_t)(0.001) * " << yfact << ") * (real_t)(43758.5453);\n" + << "\t\tax = ax - (int) ax;\n" + << "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : 0.0;\n" + << "\n" + << "\t\tvOut.x = " << weight << " * (x0 + sin(y0 * " << freqx << ") * ax * ax * " << scalex << ");\n" + << "\t\tvOut.y = " << weight << " * (y0 + sin(x0 * " << freqy << ") * " << scaley << ");\n" + << "\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Scalex, prefix + "waves42_scalex", T(0.05))); + m_Params.push_back(ParamWithName(&m_Scaley, prefix + "waves42_scaley", T(0.05))); + m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves42_freqx", T(7.0))); + m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves42_freqy", T(13.0))); + m_Params.push_back(ParamWithName(&m_Cont, prefix + "waves42_cont", T(0), eParamType::INTEGER, T(0), T(1))); + m_Params.push_back(ParamWithName(&m_Yfact, prefix + "waves42_yfact", T(0.1))); + m_Params.push_back(ParamWithName(&m_Freqx2, prefix + "waves42_freqx2", T(1.0))); + } + +private: + T m_Scalex; + T m_Scaley; + T m_Freqx; + T m_Freqy; + T m_Cont; + T m_Yfact; + T m_Freqx2; +}; + MAKEPREPOSTPARVAR(Splits3D, splits3D, SPLITS3D) MAKEPREPOSTPARVAR(Waves2B, waves2b, WAVES2B) MAKEPREPOSTPARVAR(JacCn, jac_cn, JAC_CN) @@ -6675,4 +7117,9 @@ MAKEPREPOSTPARVAR(Modulusx, modulusx, MODULUSX) MAKEPREPOSTPARVAR(Modulusy, modulusy, MODULUSY) MAKEPREPOSTPARVAR(Rotate, rotate, ROTATE) MAKEPREPOSTPARVAR(Shift, shift, SHIFT) +MAKEPREPOSTPARVAR(Waves22, waves22, WAVES22) +MAKEPREPOSTPARVAR(Waves23, waves23, WAVES23) +MAKEPREPOSTPARVAR(Waves42, waves42, WAVES42) +MAKEPREPOSTPARVAR(Waves3, waves3, WAVES3) +MAKEPREPOSTPARVAR(Waves4, waves4, WAVES4) } diff --git a/Source/EmberCL/EmberCLFunctions.h b/Source/EmberCL/EmberCLFunctions.h index 011561e..aa81a50 100644 --- a/Source/EmberCL/EmberCLFunctions.h +++ b/Source/EmberCL/EmberCLFunctions.h @@ -185,13 +185,13 @@ static const char* RandFunctionString = "inline real_t MwcNextFRange(uint2* s, real_t lower, real_t upper)\n" "{\n" " real_t f = (real_t)MwcNext(s) / (real_t)UINT_MAX;\n" - " return lower + (f * (upper - lower));\n" + " return fma(f, upper - lower, lower);\n" "}\n" "\n" "inline real_t MwcNextNeg1Pos1(uint2* s)\n" "{\n" " real_t f = (real_t)MwcNext(s) / (real_t)UINT_MAX;\n" - " return -1.0 + (f * 2.0);\n" + " return fma(f, 2.0, -1.0);\n" "}\n" "\n" "inline real_t MwcNext0505(uint2* s)\n" @@ -213,11 +213,12 @@ static const char* AddToAccumWithCheckFunctionString = /// /// OpenCL equivalent various CarToRas member functions. +/// Normaly would subtract m_RasLlX and m_RasLlY, but they were negated in RendererCL before being passed in, so they could be used with fma(). /// static const char* CarToRasFunctionString = "inline void CarToRasConvertPointToSingle(__constant CarToRasCL* carToRas, Point* point, uint* singleBufferIndex)\n" "{\n" - " *singleBufferIndex = (uint)(carToRas->m_PixPerImageUnitW * point->m_X - carToRas->m_RasLlX) + (carToRas->m_RasWidth * (uint)(carToRas->m_PixPerImageUnitH * point->m_Y - carToRas->m_RasLlY));\n" + " *singleBufferIndex = (uint)fma(carToRas->m_PixPerImageUnitW, point->m_X, carToRas->m_RasLlX) + (carToRas->m_RasWidth * (uint)fma(carToRas->m_PixPerImageUnitH, point->m_Y, carToRas->m_RasLlY));\n" "}\n" "\n" "inline bool CarToRasInBounds(__constant CarToRasCL* carToRas, Point* point)\n" diff --git a/Source/EmberCL/EmberCLStructs.h b/Source/EmberCL/EmberCLStructs.h index 1549bf9..ff0a917 100644 --- a/Source/EmberCL/EmberCLStructs.h +++ b/Source/EmberCL/EmberCLStructs.h @@ -83,6 +83,7 @@ static string ConstantDefinesString(bool doublePrecision) "#define M_3PI (MPI * 3)\n" "#define SQRT5 2.2360679774997896964091736687313\n" "#define M_PHI 1.61803398874989484820458683436563\n" + "#define M_1_2PI 0.15915494309189533576888376337251\n" "#define DEG_2_RAD (MPI / 180)\n" "#define CURVES_LENGTH_M1 ((real_bucket_t)" << CURVES_LENGTH_M1 << ")\n" << "#define ONE_OVER_CURVES_LENGTH_M1 ((real_bucket_t)" << ONE_OVER_CURVES_LENGTH_M1 << ")\n" << diff --git a/Source/EmberCL/IterOpenCLKernelCreator.cpp b/Source/EmberCL/IterOpenCLKernelCreator.cpp index ddaec0a..34b1e30 100644 --- a/Source/EmberCL/IterOpenCLKernelCreator.cpp +++ b/Source/EmberCL/IterOpenCLKernelCreator.cpp @@ -93,7 +93,7 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, if (needPrecalcAtanYX) xformFuncs << "\treal_t precalcAtanyx;\n"; - xformFuncs << "\treal_t tempColor = outPoint->m_ColorX = xform->m_ColorSpeedCache + (xform->m_OneMinusColorCache * inPoint->m_ColorX);\n\n"; + xformFuncs << "\treal_t tempColor = outPoint->m_ColorX = fma(xform->m_OneMinusColorCache, inPoint->m_ColorX, xform->m_ColorSpeedCache);\n\n"; if (xform->PreVariationCount() + xform->VariationCount() == 0) { @@ -215,7 +215,7 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, "\toutPoint->m_Y = fma(xform->m_PostD, tempX, fma(xform->m_PostE, outPoint->m_Y, xform->m_PostF));\n"; } - xformFuncs << "\toutPoint->m_ColorX = tempColor + xform->m_DirectColor * (outPoint->m_ColorX - tempColor);\n"; + xformFuncs << "\toutPoint->m_ColorX = fma(xform->m_DirectColor, (outPoint->m_ColorX - tempColor), tempColor);\n"; xformFuncs << "\n"; xformFuncs << "\tif (isnan(outPoint->m_ColorX))\n"; xformFuncs << "\t outPoint->m_ColorX = 0.0; \n"; diff --git a/Source/EmberCL/RendererCL.cpp b/Source/EmberCL/RendererCL.cpp index 2ff5ffd..c2dd7e5 100644 --- a/Source/EmberCL/RendererCL.cpp +++ b/Source/EmberCL/RendererCL.cpp @@ -1822,9 +1822,9 @@ void RendererCL::ConvertCarToRas(const CarToRas& carToRas) { m_CarToRasCL.m_RasWidth = uint(carToRas.RasWidth()); m_CarToRasCL.m_PixPerImageUnitW = carToRas.PixPerImageUnitW(); - m_CarToRasCL.m_RasLlX = carToRas.RasLlX(); + m_CarToRasCL.m_RasLlX = -carToRas.RasLlX();//Flip here because it's only used by CarToRasConvertPointToSingle(), which only needs the negative of it. m_CarToRasCL.m_PixPerImageUnitH = carToRas.PixPerImageUnitH(); - m_CarToRasCL.m_RasLlY = carToRas.RasLlY(); + m_CarToRasCL.m_RasLlY = -carToRas.RasLlY();//Ditto here. m_CarToRasCL.m_CarLlX = carToRas.CarLlX(); m_CarToRasCL.m_CarLlY = carToRas.CarLlY(); m_CarToRasCL.m_CarUrX = carToRas.CarUrX(); diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index a73b3f2..40fc567 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -1278,6 +1278,12 @@ bool TestGlobalFuncs() { auto var = vlf->GetVariation(i); funcs = var->OpenCLGlobalFuncNames(); + auto localfuncs = var->OpenCLFuncsString(); + Ember ember; + Xform xf; + xf.AddVariation(var->Copy()); + ember.AddXform(xf); + auto kernel = GetEmberCLKernelString(ember, true, false, false, 1u, false); for (auto& func : funcs)//Test if the functions the variation says it requires actually exist. { @@ -1308,6 +1314,44 @@ bool TestGlobalFuncs() } } } + + //Test whether the global functions the variations purports to need are actually used. + for (auto& v : vec) + { + bool found = false; + + for (auto& v2 : vec)//Test if the functions the variation uses possibly use this function. It can be the case sometimes where a variation does not use it directly, but its global functions do. + { + if (v != v2) + { + auto it = funcmap.find(v2); + + if (it != funcmap.end()) + { + if (Find(it->second, v + "(")) + { + found = true; + break; + } + } + } + } + + if (!found && Find(str, v + "(")) + { + found = true; + } + + if (!found && Find(localfuncs, v + "(")) + { + found = true; + } + + if (!found) + { + cout << "Variation " << var->Name() << " purported to require the usage of global function " << v << ", but it's not found in its OpenCL function string:\n" /*<< kernel*/ << endl; + } + } } return success; diff --git a/Source/Fractorium/AboutDialog.ui b/Source/Fractorium/AboutDialog.ui index 30cb444..e08ba83 100644 --- a/Source/Fractorium/AboutDialog.ui +++ b/Source/Fractorium/AboutDialog.ui @@ -40,7 +40,7 @@ 6 5 681 - 221 + 171 @@ -58,7 +58,7 @@ QFrame::NoFrame - <html><head/><body><p align="center">Fractorium 1.0.0.15</p><p align="center"><span style=" font-size:10pt;">A Qt-based fractal flame editor which uses a C++ re-write of the flam3 algorithm named Ember and a GPU capable version named EmberCL which implements a portion of the cuburn algorithm in OpenCL.</span></p><p align="center"><a href="http://fractorium.com"><span style=" text-decoration: underline; color:#0000ff;">fractorium.com</span></a></p></body></html> + <html><head/><body><p align="center" style=" font-size:10pt;">Fractorium 1.0.0.15</p><p align="center"><span style=" font-size:10pt;">A Qt-based fractal flame editor which uses a C++ re-write of the flam3 algorithm named Ember and a GPU capable version named EmberCL which implements a portion of the cuburn algorithm in OpenCL.</span></p><p align="center"><a href="http://fractorium.com"><span style=" text-decoration: underline; color:#0000ff; font-size:10pt;">fractorium.com</span></a></p></body></html> Qt::RichText @@ -104,7 +104,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.1pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.14286pt; font-weight:400; font-style:normal;"> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Developers:</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Lead: </span><a href="http://www.fractorium.com"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Matt Feemster</span></a><span style=" font-size:10pt;"><br />Contributors: </span><a href="http://blog.highlyillogical.org/"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Simon Detheridge</span></a><span style=" font-size:10pt;">, </span><a href="https://www.deviantart.com/triptychaos"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Michel Mastriani.</span></a></p> <p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> diff --git a/Source/Fractorium/FinalRenderDialog.ui b/Source/Fractorium/FinalRenderDialog.ui index ae75abb..333bf7a 100644 --- a/Source/Fractorium/FinalRenderDialog.ui +++ b/Source/Fractorium/FinalRenderDialog.ui @@ -539,13 +539,13 @@ 0 - 45 + 46 16777215 - 45 + 46 @@ -748,13 +748,13 @@ 0 - 199 + 200 16777215 - 199 + 200 diff --git a/Source/Fractorium/Fractorium.ui b/Source/Fractorium/Fractorium.ui index c020994..5773efd 100644 --- a/Source/Fractorium/Fractorium.ui +++ b/Source/Fractorium/Fractorium.ui @@ -80,7 +80,7 @@ 0 0 - 1305 + 1277 985 @@ -173,7 +173,7 @@ 0 0 230 - 936 + 934 @@ -570,96 +570,6 @@ - - - - true - - - - 0 - 0 - - - - - 0 - 19 - - - - - 16777215 - 19 - - - - Qt::NoFocus - - - false - - - QFrame::Panel - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::ScrollPerItem - - - QAbstractItemView::ScrollPerItem - - - false - - - false - - - true - - - 15 - - - false - - - 15 - - - true - - - false - - - 15 - - - false - - - 15 - - - - Color - - - AlignCenter - - - - @@ -1675,6 +1585,11 @@ Brightness + + + true + + @@ -1715,6 +1630,11 @@ Field + + + true + + @@ -1827,6 +1747,96 @@ + + + + true + + + + 0 + 0 + + + + + 0 + 19 + + + + + 16777215 + 19 + + + + Qt::NoFocus + + + false + + + QFrame::Panel + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::ScrollPerItem + + + QAbstractItemView::ScrollPerItem + + + false + + + false + + + true + + + 15 + + + false + + + 15 + + + true + + + false + + + 16 + + + false + + + 16 + + + + Color + + + AlignCenter + + + + @@ -2389,13 +2399,13 @@ 0 - 67 + 68 16777215 - 67 + 68 @@ -2622,13 +2632,13 @@ 0 - 21 + 22 16777215 - 21 + 22 @@ -3310,13 +3320,13 @@ 0 - 42 + 41 16777215 - 42 + 41 @@ -3519,13 +3529,13 @@ 0 - 22 + 23 16777215 - 22 + 23 @@ -3849,13 +3859,13 @@ 0 - 45 + 68 16777215 - 67 + 68 @@ -6260,7 +6270,7 @@ 0 0 267 - 676 + 670 @@ -6472,13 +6482,13 @@ 0 - 126 + 128 16777215 - 126 + 128 @@ -6812,13 +6822,13 @@ 0 - 250 + 255 16777215 - 250 + 255 @@ -6863,13 +6873,13 @@ 0 - 173 + 170 16777215 - 173 + 170 @@ -7499,8 +7509,8 @@ 0 0 - 407 - 541 + 424 + 574 diff --git a/Source/Fractorium/OptionsDialog.ui b/Source/Fractorium/OptionsDialog.ui index 08270d6..216c071 100644 --- a/Source/Fractorium/OptionsDialog.ui +++ b/Source/Fractorium/OptionsDialog.ui @@ -571,13 +571,13 @@ 0 - 67 + 68 16777215 - 67 + 68 @@ -764,13 +764,13 @@ 120 - 67 + 68 16777215 - 67 + 68 diff --git a/Source/apoconv/App.config b/Source/apoconv/App.config new file mode 100644 index 0000000..016d28f --- /dev/null +++ b/Source/apoconv/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Source/apoconv/Form1.Designer.cs b/Source/apoconv/Form1.Designer.cs new file mode 100644 index 0000000..6a1983a --- /dev/null +++ b/Source/apoconv/Form1.Designer.cs @@ -0,0 +1,122 @@ +namespace apoconv +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.AllowDrop = true; + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.textBox1); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.textBox2); + this.splitContainer1.Size = new System.Drawing.Size(2871, 1225); + this.splitContainer1.SplitterDistance = 1389; + this.splitContainer1.TabIndex = 0; + // + // textBox1 + // + this.textBox1.AllowDrop = true; + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.Font = new System.Drawing.Font("Consolas", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox1.Location = new System.Drawing.Point(0, 0); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBox1.Size = new System.Drawing.Size(1389, 1225); + this.textBox1.TabIndex = 0; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop); + this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter); + // + // textBox2 + // + this.textBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox2.Font = new System.Drawing.Font("Consolas", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox2.Location = new System.Drawing.Point(0, 0); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBox2.Size = new System.Drawing.Size(1478, 1225); + this.textBox2.TabIndex = 1; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(28, 28); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4); + // + // Form1 + // + this.AllowDrop = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(2871, 1225); + this.Controls.Add(this.splitContainer1); + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Apophysis to Fractorium Plugin Converter"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + } +} + diff --git a/Source/apoconv/Form1.cs b/Source/apoconv/Form1.cs new file mode 100644 index 0000000..5729c2b --- /dev/null +++ b/Source/apoconv/Form1.cs @@ -0,0 +1,597 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows.Forms; + +namespace apoconv +{ + public partial class Form1 : Form + { + private List m_Params = new List(); + private List m_StructParams = new List(); + private List m_PrecalcFuncLines = new List(); + private List m_CalcFuncLines = new List(); + private List m_FinalCalcFuncLines = new List(); + private readonly SortedDictionary replacements = new SortedDictionary() + { + { "(double)", "" }, + { "(float)", "" }, + { "double", "T" }, + { "float", "T" }, + //{ "0.0", "0" }, + { "0.5", "T(0.5)" }, + { "1.0", "T(1.0)" }, + { "0.1", "T(0.1)" }, + { "0.01", "T(0.01)" }, + { "0.001", "T(0.001)" }, + { "12.9898", "T(12.9898)" }, + { "78.233", "T(78.233)" }, + { "43758.5453", "T(43758.5453)" }, + { "FTx", "helper.In.x" }, + { "FTy", "helper.In.y" }, + { "FTz", "helper.In.z" }, + { "FPx", "helper.Out.x" }, + { "FPy", "helper.Out.y" }, + { "FPz", "helper.Out.z" }, + { "VVAR", "m_Weight" }, + { "floor(", "Floor(" }, + { "cel(", "std::ceil(" }, + { "sin(", "std::sin(" }, + { "sinh(", "std::sinh(" }, + { "asin(", "std::asin(" }, + { "asinh(", "std::asinh(" }, + + { "cos(", "std::cos(" }, + { "cosh(", "std::cosh(" }, + { "acos(", "std::acos(" }, + { "acosh(", "std::acosh(" }, + + { "tan(", "std::tan(" }, + { "tanh(", "std::tanh(" }, + { "atan(", "std::atan(" }, + { "atan2(", "std::atan2(" }, + { "atanh(", "std::atanh(" }, + + { "sqrt(", "std::sqrt(" }, + { "pow(", "std::pow(" }, + { "fabs(", "std::abs(" }, + + { "sqr(", "Sqr(" }, + + { "M_E", "T(M_E)" }, + { "M_LOG2E", "T(M_LOG2E)" }, + { "M_LOG10E", "T(M_LOG10E)" }, + { "M_LN2", "T(M_LN2)" }, + { "M_LN10", "T(M_LN10)" }, + { "M_PI", "T(M_PI)" }, + { "M_PI_2", "T(M_PI_2)" }, + { "M_PI_4", "T(M_PI_4)" }, + { "M_1_PI", "T(M_1_PI)" }, + { "M_2_PI", "T(M_2_PI)" }, + { "M_2_SQRTPI", "T(M_2_SQRTPI)" }, + { "M_SQRT2", "T(M_SQRT2)" }, + { "M_SQRT1_2", "T(M_SQRT1_2)" }, + + }; + + public Form1() + { + InitializeComponent(); + //var lines = File.ReadAllLines("./waves4.cpp"); + //textBox1.Lines = lines; + } + + string Apo2Fractorium(string[] lines, bool doexport) + { + if (lines.Length == 0) + return ""; + + //doexport = false; + + bool isparvar = false; + string pluginname = ""; + string varclassname = ""; + m_Params.Clear(); + m_StructParams.Clear(); + m_PrecalcFuncLines.Clear(); + m_CalcFuncLines.Clear(); + m_FinalCalcFuncLines.Clear(); + + bool structstart = false; + + foreach (var line in lines) + { + if (line.Contains("APO_PLUGIN")) + { + var splits = line.Split(new char[] { '\"' }); + + if (splits.Length >= 1) + { + pluginname = splits[1]; + varclassname = pluginname.FirstCharToUpper() + "Variation"; + } + } + } + + foreach (var line in lines) + { + if (line.Contains("typedef struct")) + { + structstart = true; + continue; + } + + if (structstart) + { + if (line.Contains("{")) + continue; + + if (line.Contains("}")) + break; + + var splits = line.Trim().Split(new string[] { " ", ",", ";", "(", ")", "double", "float", "int", "unsigned", "long", "short", "char" }, StringSplitOptions.RemoveEmptyEntries); + + foreach (var split in splits) + { + m_StructParams.Add(new PrecalcParamInfo + { + OrigName = split.Trim(), + Name = split.Trim(), + MemberName = "m_" + split.RemoveFirst(pluginname + "_").FirstCharToUpper().Replace("_", "").Trim(), + }); + + isparvar = true; + } + } + } + + bool paramsstart = false; + + foreach (var line in lines) + { + if (line.Contains("APO_VARIABLES(")) + { + paramsstart = true; + continue; + } + + if (paramsstart) + { + if (line.Contains(");")) + break; + + var splits = line.Split(new char[] { '(', ')', ',' }); + + if (splits.Length > 2) + { + var pt = ""; + var l = ""; + var u = ""; + var def = ""; + + if (line.Contains("VAR_INTEGER_RANGE")) + { + pt = "eParamType::INTEGER"; + + if (splits.Length >= 5) + { + l = splits[2].Trim(); + u = splits[3].Trim(); + def = splits[4].Trim(); + } + } + else if (line.Contains("VAR_REAL_RANGE")) + { + pt = "eParamType::REAL"; + + if (splits.Length >= 5) + { + l = splits[2].Trim(); + u = splits[3].Trim(); + def = splits[4].Trim(); + } + } + else if (line.Contains("VAR_REAL_CYCLE")) + { + pt = "eParamType::REAL_CYCLIC"; + + if (splits.Length >= 5) + { + l = splits[2].Trim(); + u = splits[3].Trim(); + def = splits[4].Trim(); + } + } + else if (line.Contains("VAR_INTEGER_NONZERO")) + { + pt = "eParamType::INTEGER_NONZERO"; + def = splits[2].Trim(); + } + else if (line.Contains("INTEGER(")) + { + pt = "eParamType::INTEGER"; + def = splits[2].Trim(); + } + else + def = splits[2].Trim(); + + m_Params.Add(new ParamInfo + { + Name = splits[1].Trim(), + MemberName = "m_" + splits[1].RemoveFirst(pluginname + "_").FirstCharToUpper().Replace("_", "").Trim(), + Default = def, + Lower = l, + Upper = u, + ParamType = pt + }); + isparvar = true; + } + } + } + + foreach (var param in m_Params) + { + if (m_StructParams.Any(pi => pi.Name == param.Name)) + m_StructParams.RemoveAll(pi => pi.Name == param.Name); + } + + foreach (var param in m_StructParams) + { + if (!param.Name.StartsWith(pluginname + "_")) + param.Name = pluginname + "_" + param.Name; + + if (!param.Name.EndsWith("_precalc")) + param.Name = param.Name + "_precalc"; + + if (!param.MemberName.EndsWith("Precalc")) + param.MemberName += "Precalc"; + } + + bool calcstart = false; + int bracketcount = 0; + + foreach (var line in lines) + { + if (line.Contains("PluginVarCalc")) + { + calcstart = true; + continue; + } + + if (calcstart) + { + if (line.Contains("{")) + bracketcount++; + + if (line.Contains("}")) + bracketcount--; + + if (bracketcount <= 0) + break; + + if (line != "{" && !line.Contains("return")) + { + var templine = line; + + if (line.Contains("FPx") || line.Contains("FPy") || line.Contains("FPz")) + { + templine = templine.Replace("+=", "="); + templine = templine.Replace("-=", "= -(");//Will cause an error, forcing manual inspection + } + + m_CalcFuncLines.Add(templine.Trim()); + } + } + } + + bool precalcstart = false; + bracketcount = 0; + + foreach (var line in lines) + { + if (line.Contains("PluginVarPrepare")) + { + precalcstart = true; + continue; + } + + if (precalcstart) + { + if (line.Contains("{")) + bracketcount++; + + if (line.Contains("}")) + bracketcount--; + + if (bracketcount <= 0) + break; + + if (line != "{" && !line.Contains("return")) + { + var templine = line; + + foreach (var rep in replacements) + templine = templine.Replace(rep.Key, rep.Value); + + m_PrecalcFuncLines.Add(templine.Trim()); + } + } + } + + string final = "/// \r\n"; + final += "/// " + pluginname + ".\r\n"; + final += "/// \r\n"; + final += "template \r\n"; + + if (isparvar) + final += "class " + varclassname + " : public ParametricVariation\r\n"; + else + final += "class " + varclassname + " : public Variation\r\n"; + + final += "{\r\n"; + final += "public:\r\n"; + + if (isparvar) + final += "\t" + varclassname + "(T weight = 1.0) : ParametricVariation(\"" + pluginname + "\", eVariationId::VAR_" + pluginname.ToUpper() + ", weight)\r\n"; + else + final += "\t" + varclassname + "(T weight = 1.0) : Variation(\"" + pluginname + "\", eVariationId::VAR_" + pluginname.ToUpper() + ", weight)\r\n"; + + final += "\t{\r\n"; + + if (isparvar) + final += "\t Init();\r\n"; + + final += "\t}\r\n\r\n"; + + if (isparvar) + final += "\tPARVARCOPY(" + varclassname + ")\r\n"; + else + final += "\tVARCOPY(" + varclassname + ")\r\n"; + + final += "\r\n\tvirtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override\r\n"; + final += "\t{\r\n"; + + foreach (var line in m_CalcFuncLines) + { + var templine = "\t\t" + line; + + foreach (var rep in replacements) + templine = templine.Replace(rep.Key, rep.Value); + + templine += "\r\n"; + + foreach (var param in m_Params) + templine = templine.Replace("VAR(" + param.Name + ")", param.MemberName); + + foreach (var param in m_StructParams) + templine = templine.Replace("VAR(" + param.OrigName + ")", param.MemberName); + + m_FinalCalcFuncLines.Add(templine.Trim()); + final += templine; + } + + final += "\t\thelper.Out.z = DefaultZ(helper);\r\n"; + final += "\t}\r\n"; + + final += "\r\n\tvirtual string OpenCLString() const override\r\n"; + final += "\t{\r\n"; + final += "\t ostringstream ss, ss2;\r\n"; + final += "\t intmax_t i = 0, varIndex = IndexInXform();\r\n"; + final += "\t ss2 << \"_\" << XformIndexInEmber() << \"]\";\r\n"; + final += "\t string index = ss2.str();\r\n"; + final += "\t string weight = WeightDefineString();\r\n"; + + foreach (var param in m_Params) + { + final += "\t\tstring " + param.MemberName.Replace("m_", "").ToLower() + " = \"parVars[\" + ToUpper(m_Params[i++].Name()) + index;\r\n"; + } + + final += "\t\tss << \"\\t{\\n\"\r\n"; + + foreach (var line in m_FinalCalcFuncLines) + { + string templine; + + if (line != "") + templine = "\t\t<< \"\\t\\t" + line + "\\n\"\r\n"; + else + templine = "\t\t<< \"\\n\"\r\n"; + + templine = templine.Replace("\\tT ", "\\treal_t "). + Replace("helper.In.x", "vIn.x"). + Replace("helper.In.y", "vIn.y"). + Replace("helper.In.z", "vIn.z"). + Replace("helper.Out.x", "vOut.x"). + Replace("helper.Out.y", "vOut.y"). + Replace("helper.Out.z", "vOut.z"). + Replace("Floor", "floor"). + Replace("std::abs", "fabs"). + Replace("m_Weight", "\" << weight << \""). + Replace("std::", ""). + Replace("T(", "(real_t)(") + ; + + foreach (var param in m_Params) + { + if (templine.Contains(param.MemberName)) + templine = templine.Replace(param.MemberName, "\" << " + param.MemberName.Substring(2).ToLower() + " << \""); + } + + foreach (var param in m_StructParams) + { + if (templine.Contains(param.MemberName)) + templine = templine.Replace(param.MemberName, "\" << " + param.MemberName.Substring(2).ToLower() + " << \""); + } + + final += templine; + } + + final += "\t\t<< \"\\t\\tvOut.z = \" << DefaultZCl()\r\n"; + final += "\t\t<< \"\\t}\\n\";\r\n"; + final += "\t\treturn ss.str();\r\n"; + final += "\t}\r\n"; + + if (isparvar) + { + final += "\r\n\tvirtual void Precalc() override\r\n"; + final += "\t{\r\n"; + + foreach (var line in m_PrecalcFuncLines) + { + var templine = line; + + foreach (var param in m_Params) + templine = templine.Replace("VAR(" + param.Name + ")", param.MemberName); + + foreach (var param in m_StructParams) + templine = templine.Replace("VAR(" + param.OrigName + ")", param.MemberName); + + final += "\t\t" + templine + "\r\n"; + } + + final += "\t}\r\n"; + } + + final += "\r\n\tvirtual vector OpenCLGlobalFuncNames() const override\r\n"; + final += "\t{\r\n"; + final += "\t return vector { \"Zeps\" };\r\n"; + final += "\t}\r\n"; + bool saidprecalc = false; + + if (isparvar) + { + + final += "\r\nprotected:\r\n"; + final += "\tvoid Init()\r\n"; + final += "\t{\r\n"; + final += "\t\tstring prefix = Prefix();\r\n"; + final += "\t\tm_Params.clear();\r\n"; + + foreach (var param in m_Params) + final += "\t\tm_Params.push_back(ParamWithName(&" + param.MemberName + + ", prefix + \"" + + param.Name + + (param.Default != "0" && param.Default != "0.0" && param.Default != "" || param.ParamType != "" ? + "\", T(" + param.Default + ")" + : + "\"") + + (param.ParamType != "" ? ", " + param.ParamType : "") + + (param.Lower != "" ? ", T(" + param.Lower + ")" : "") + + (param.Upper != "" ? ", T(" + param.Upper + ")" : "") + + "));\r\n"; + + foreach (var param in m_StructParams) + { + final += "\t\tm_Params.push_back(ParamWithName(true, &" + param.MemberName + + ", prefix + \"" + + param.Name + "\"));" + (!saidprecalc ? "//Precalc." : "") + "\r\n"; + saidprecalc = true; + } + + final += "\t}\r\n"; + final += "\r\nprivate:\r\n"; + + foreach (var param in m_Params) + final += "\tT " + param.MemberName + ";\r\n"; + + saidprecalc = false; + + foreach (var param in m_StructParams) + { + final += "\tT " + param.MemberName + ";" + (!saidprecalc ? "//Precalc." : "") + "\r\n"; + saidprecalc = true; + } + } + + final += "};\r\n\r\n"; + + if (doexport) + { + if (isparvar) + final += "MAKEPREPOSTPARVAR(" + pluginname.FirstCharToUpper() + ", " + pluginname + ", " + pluginname.ToUpper() + ")\r\n"; + else + final += "MAKEPREPOSTVAR(" + pluginname.FirstCharToUpper() + ", " + pluginname + ", " + pluginname.ToUpper() + ")\r\n"; + + final += "EXPORTPREPOSTREGVAR(" + pluginname.FirstCharToUpper() + ", T) \\\r\n"; + final += "ADDPREPOSTREGVAR(" + pluginname.FirstCharToUpper() + ")\r\n\r\n"; + } + + return final; + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + textBox2.Text = Apo2Fractorium(textBox1.Lines, true); + + } + + private void textBox1_DragDrop(object sender, DragEventArgs e) + { + textBox1.TextChanged -= textBox1_TextChanged; + string final = ""; + List tb1lines = new List(); + + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + + foreach (var file in files) + { + var lines = File.ReadAllLines(file); + tb1lines.AddRange(lines.ToList()); + final += Apo2Fractorium(lines, true); + } + + textBox1.Lines = tb1lines.ToArray(); + textBox2.Text = final; + } + + textBox1.TextChanged += textBox1_TextChanged; + } + + private void textBox1_DragEnter(object sender, DragEventArgs e) + { + e.Effect = DragDropEffects.Copy; + } + } + + public class ParamInfo + { + public string Name = ""; + public string MemberName = ""; + public string Default = ""; + public string Lower = ""; + public string Upper = ""; + public string ParamType = ""; + } + + + public class PrecalcParamInfo : ParamInfo + { + public string OrigName = ""; + } + + public static class StringExtensions + { + public static string FirstCharToUpper(this string input) + { + switch (input) + { + case null: throw new ArgumentNullException(nameof(input)); + + case "": throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)); + + default: return input.First().ToString().ToUpper() + input.Substring(1); + } + } + + public static string RemoveFirst(this string input, string removeString) + { + int index = input.IndexOf(removeString); + return (index < 0) + ? input + : input.Remove(index, removeString.Length); + } + } +} diff --git a/Source/apoconv/Form1.resx b/Source/apoconv/Form1.resx new file mode 100644 index 0000000..ad53752 --- /dev/null +++ b/Source/apoconv/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Source/apoconv/Program.cs b/Source/apoconv/Program.cs new file mode 100644 index 0000000..cd452bf --- /dev/null +++ b/Source/apoconv/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace apoconv +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Source/apoconv/Properties/AssemblyInfo.cs b/Source/apoconv/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3e6c45f --- /dev/null +++ b/Source/apoconv/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("apoconv")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("apoconv")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4f78c421-8985-4411-8ffd-b0f323f857be")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Source/apoconv/Properties/Resources.Designer.cs b/Source/apoconv/Properties/Resources.Designer.cs new file mode 100644 index 0000000..bcae8aa --- /dev/null +++ b/Source/apoconv/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace apoconv.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("apoconv.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Source/apoconv/Properties/Resources.resx b/Source/apoconv/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Source/apoconv/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/apoconv/Properties/Settings.Designer.cs b/Source/apoconv/Properties/Settings.Designer.cs new file mode 100644 index 0000000..4c2b8cf --- /dev/null +++ b/Source/apoconv/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace apoconv.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Source/apoconv/Properties/Settings.settings b/Source/apoconv/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Source/apoconv/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Source/apoconv/apoconv.csproj b/Source/apoconv/apoconv.csproj new file mode 100644 index 0000000..53e52a8 --- /dev/null +++ b/Source/apoconv/apoconv.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {4F78C421-8985-4411-8FFD-B0F323F857BE} + WinExe + apoconv + apoconv + v4.7 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file