Nicolas Winkler před 5 roky
rodič
revize
58d7e06e58

+ 16 - 3
Almond.cpp

@@ -6,6 +6,8 @@
 #include <QGradient>
 #include "gradientchoosedialog.h"
 
+#include "GridFlowLayout.h"
+
 #include <cmath>
 
 Almond::Almond(QWidget* parent) :
@@ -34,9 +36,20 @@ Almond::Almond(QWidget* parent) :
     ui.backgroundProgress->setVisible(false);
 
     backgroundTasks.setMaxThreadCount(1);
-    this->setWindowIcon(QIcon(":/icons/icon"));
-    //ui.verticalLayout_left->addWidget(new MyGLWidget(ui.centralWidget));
-    //mw->show();
+    QIcon icon{ ":/icons/icon" };
+    icon.addFile(":/icons/icon@2x");
+    this->setWindowIcon(icon);
+
+    // replace vertical layout with gridflowlayout
+    /*GridFlowLayout* gfl = new GridFlowLayout(nullptr);
+    //ui.horizontalLayout_4->addItem(gfl);
+    for (int i = 0; i < ui.verticalLayout_right->count(); i++) {
+        printf("%d: \n", i);
+        gfl->addItem(ui.verticalLayout_right->takeAt(i));
+    }
+    ui.verticalLayout_right->setEnabled(false);
+    delete ui.dockWidgetContents_2->layout();
+    ui.dockWidgetContents_2->setLayout(gfl);*/
 }
 
 

+ 6 - 3
Almond.pro

@@ -37,6 +37,7 @@ SOURCES += \
         customgenerator.cpp \
         exportdialogs.cpp \
         gradientchoosedialog.cpp \
+        GridFlowLayout.cpp \
         main.cpp
 
 HEADERS += \
@@ -50,6 +51,7 @@ HEADERS += \
         choosegenerators.h \
         customgenerator.h \
         exportdialogs.h \
+        GridFlowLayout.h \
         gradientchoosedialog.h
 
 FORMS += \
@@ -79,7 +81,7 @@ unix:LIBS += -lm -latomic
 
 win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/lib/ -lavcodec
 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/lib/ -lavcodec
-else:unix: LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lavcodec
+else:unix: LIBS += -lavcodec
 
 win32:FFMPEGPATH = $$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/lib/
 win32:INCLUDEPATH += $$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/include
@@ -126,8 +128,9 @@ unix|win32: LIBS += -L$FFMPEGPATH -lswscale
 RESOURCES += Almond.qrc \
     splash.qrc
 
-unix|win32: LIBS += -L$$PWD/libmandel/ -L$$PWD/libalmond/ -lmandel -lqd -lasmjit -lalmond -llibpng16_static -lzlibstatic
-unix: LIBS += -lrt
+win32:LIBS += -llibpng16_static -lzlibstatic
+unix|win32: LIBS += -L$$PWD/libmandel/ -L$$PWD/libalmond/ -lmandel -lqd -lasmjit -lalmond
+unix: LIBS += -lrt -lpng -lavcodec -lavdevice -lavformat -lavutil -lswscale -lavfilter
 
 INCLUDEPATH += $$PWD/libmandel/include $$PWD/libmandel/qd-2.3.22/include $$PWD/libalmond/include
 DEPENDPATH += $$PWD/libmandel/include $$PWD/libmandel/qd-2.3.22/include $$PWD/libalmond/include

+ 1 - 0
Almond.qrc

@@ -1,6 +1,7 @@
 <RCC>
     <qresource prefix="/icons">
         <file alias="icon">icon.png</file>
+        <file alias="icon@2x">icon.png</file>
     </qresource>
     <qresource prefix="/gradients">
         <file alias="default">gradients/default.xml</file>

+ 51 - 55
Almond.ui

@@ -44,7 +44,50 @@
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_right">
        <item>
-        <widget class="QGroupBox" name="groupBox_3">
+        <widget class="QGroupBox" name="grp_zoom">
+         <property name="title">
+          <string>Zoom</string>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_2">
+          <item row="1" column="0">
+           <widget class="QPushButton" name="zoom_in">
+            <property name="text">
+             <string>Zoom In</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="QPushButton" name="zoom_out">
+            <property name="text">
+             <string>Zoom Out</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0" colspan="2">
+           <widget class="QPushButton" name="resetZoom">
+            <property name="text">
+             <string>Reset Zoom</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="grp_display_opts">
          <property name="title">
           <string>Display/Calculation Options</string>
          </property>
@@ -129,67 +172,20 @@
         </widget>
        </item>
        <item>
-        <spacer name="verticalSpacer_3">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>13</width>
-           <height>13</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <layout class="QGridLayout" name="gridLayout">
-         <item row="0" column="0">
-          <widget class="QGroupBox" name="groupBox_2">
-           <property name="title">
-            <string>Zoom</string>
-           </property>
-           <layout class="QGridLayout" name="gridLayout_2">
-            <item row="1" column="0">
-             <widget class="QPushButton" name="zoom_in">
-              <property name="text">
-               <string>Zoom In</string>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="1">
-             <widget class="QPushButton" name="zoom_out">
-              <property name="text">
-               <string>Zoom Out</string>
-              </property>
-             </widget>
-            </item>
-            <item row="0" column="0" colspan="2">
-             <widget class="QPushButton" name="resetZoom">
-              <property name="text">
-               <string>Reset Zoom</string>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
-       </item>
-       <item>
         <spacer name="verticalSpacer_2">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>13</width>
-           <height>13</height>
+           <width>0</width>
+           <height>0</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
-        <widget class="QGroupBox" name="groupBox">
+        <widget class="QGroupBox" name="grp_fractal">
          <property name="title">
           <string>Fractal</string>
          </property>
@@ -233,20 +229,20 @@
         </widget>
        </item>
        <item>
-        <spacer name="verticalSpacer">
+        <spacer name="verticalSpacer_3">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>13</width>
-           <height>13</height>
+           <width>0</width>
+           <height>0</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
-        <widget class="QGroupBox" name="export_box">
+        <widget class="QGroupBox" name="grp_export_box">
          <property name="title">
           <string>Export</string>
          </property>

+ 1 - 1
CMakeLists.txt

@@ -37,7 +37,7 @@ target_include_directories(Almond SYSTEM PUBLIC ${FFMPEG_INCLUDE_DIRS})
 target_link_libraries(Almond PUBLIC libalmond)
 target_link_libraries(Almond PUBLIC Qt5::Core Qt5::Widgets Qt5::OpenGL Qt5::Xml Qt5::Concurrent)
 target_link_libraries(Almond PUBLIC ${FFMPEG_LIBRARIES})
-target_link_libraries(Almond PUBLIC OpenGL::GL)
+#target_link_libraries(Almond PUBLIC OpenGL::GL)
 
 set_property(TARGET Almond PROPERTY AUTOMOC ON)
 set_property(TARGET Almond PROPERTY AUTORCC ON)

+ 13 - 30
MandelWidget.cpp

@@ -662,13 +662,14 @@ void MandelWidget::clearAll(void)
 
 void MandelWidget::initializeGL(void)
 {
-    this->context()->functions()->glClearColor(0, 0, 0, 0);
+    auto& gl = *this->context()->functions();
+    gl.glClearColor(0, 0, 0, 0);
     this->context()->makeCurrent(nullptr);
 
-    glDisable(GL_DEPTH_TEST);
+    gl.glDisable(GL_DEPTH_TEST);
 
     // looks not even better
-    glEnable(GL_FRAMEBUFFER_SRGB);
+    gl.glEnable(GL_FRAMEBUFFER_SRGB);
 
     //glShadeModel(GL_SMOOTH);
 
@@ -682,8 +683,8 @@ void MandelWidget::resizeGL(int w, int h)
 
     currentViewport.height = currentViewport.width / aspect;
     targetViewport = currentViewport;
-    float x = this->devicePixelRatioF();
-    glViewport(0, 0, w * x, h * x);
+    float pixelRatio = this->devicePixelRatioF();
+    glViewport(0, 0, w * pixelRatio, h * pixelRatio);
 
     if (mandelView.get() != nullptr) {
         mandelView->width = w;
@@ -701,17 +702,17 @@ void MandelWidget::paintGL(void)
 
     int width = this->width();
     int height = this->height();
-    float x = this->devicePixelRatioF();
-    mandelView->width = width * x;
-    mandelView->height = height * x;
+    float pixelRatio = this->devicePixelRatioF();
+    mandelView->width = width * pixelRatio;
+    mandelView->height = height * pixelRatio;
     //glViewport(0, 0, width, height);
 
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
 #ifdef QT_OPENGL_ES_1
-    glOrthof(0, width * x, height * x, 0, -1.0, 1.0);
+    glOrthof(0, width * pixelRatio, height * pixelRatio, 0, -1.0, 1.0);
 #else
-    glOrtho(0, width * x, height * x, 0, -1.0, 1.0);
+    glOrtho(0, width * pixelRatio, height * pixelRatio, 0, -1.0, 1.0);
 #endif
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
@@ -761,31 +762,13 @@ void MandelWidget::updateAnimations(void)
 void MandelWidget::drawRubberband(void)
 {
     QPainter rubberbandPainter{ this };
-    rubberbandPainter.fillRect(rubberband, QColor{ 25, 225, 25, 50 });
+    rubberbandPainter.fillRect(rubberband, QColor{ 125, 140, 225, 120 });
 
-    QPen pen{ QColor{ 10, 200, 10 } };
+    QPen pen{ QColor{ 100, 115, 200 } };
     pen.setWidth(2);
     rubberbandPainter.setPen(pen);
 
     rubberbandPainter.drawRect(rubberband);
-    /*glColor3ub(10, 200, 10);
-    glBegin(GL_LINE_LOOP);
-    glVertex2d(rubberband.x(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.bottom());
-    glVertex2d(rubberband.x(), rubberband.bottom());
-    glEnd();
-
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glColor4f(0.1f, 0.9f, 0.1f, 0.2f);
-    glBegin(GL_TRIANGLE_FAN);
-    glVertex2d(rubberband.x(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.bottom());
-    glVertex2d(rubberband.x(), rubberband.bottom());
-    glEnd();
-    glDisable(GL_BLEND);*/
 }
 
 

+ 1 - 1
libalmond/include/MandelVideoGenerator.h

@@ -47,7 +47,7 @@ public:
 private:
     const ExportVideoInfo evi;
     std::vector<ProgressCallback> progressCallbacks;
-    public:
+public:
     MandelVideoGenerator(const ExportVideoInfo& evi);
 
     void generate(mnd::MandelGenerator& gen);

+ 2 - 2
libalmond/src/ImageExport.cpp

@@ -56,8 +56,8 @@ void exportPng(const ImageExportInfo& iei, std::function<void(float)> progressCa
     long chunkHeight = height / 20;
     if (chunkHeight < 1)
         chunkHeight = 1;
-    if (width >= 4096 && chunkHeight > 64)
-        chunkHeight = 64;
+    while (width * chunkHeight > 512 * 512)
+        chunkHeight /= 2;
 
     auto rowPointers = std::make_unique<png_byte*[]>(chunkHeight);
     for (long chunkY = 0; chunkY < height; chunkY += chunkHeight) {

+ 1 - 3
libalmond/src/MandelVideoGenerator.cpp

@@ -179,10 +179,8 @@ Bitmap<RGBColor> MandelVideoGenerator::overlay(const Bitmap<RGBColor>& outer,
     double innerWidth = outer.width * scale / oversizeFactor;
     double innerHeight = outer.height * scale / oversizeFactor;
 
-            double lerpVal = ::log(1.0 / scale) / ::log(oversizeFactor);
-            printf("lerpval: %f\n", lerpVal);
     auto before = std::chrono::high_resolution_clock::now();
-#pragma omp parallel for schedule(static, 1)
+#pragma omp parallel for schedule(static, 64)
     for (int i = 0; i < ret.height; i++) {
         for (int j = 0; j < ret.width; j++) {
             double newJ = outerLeft + outerWidth * j / ret.width;

+ 3 - 3
libalmond/src/VideoStream.cpp

@@ -95,9 +95,6 @@ VideoStream::VideoStream(int width, int height, const std::string& filename, int
     picture = av_frame_alloc();
     if (!picture)
         throw VideoExportException{ "error allocating frame" };
-    if (av_frame_make_writable(picture) < 0) {
-        throw VideoExportException{ "error making frame writeable" };
-    }
     picture->format = codecContext->pix_fmt;
     picture->width  = codecContext->width;
     picture->height = codecContext->height;
@@ -106,6 +103,9 @@ VideoStream::VideoStream(int width, int height, const std::string& filename, int
     if (retval < 0) {
         throw VideoExportException{ "could not allocate frame data" };
     }
+    if (av_frame_make_writable(picture) < 0) {
+        throw VideoExportException{ "error making frame writeable" };
+    }
     //av_image_alloc(picture->data, picture->linesize, width, height, codecContext->pix_fmt, 32);
 
     swsContext = sws_getContext(width, height,

+ 18 - 10
mandelvid/src/main.cpp

@@ -6,38 +6,45 @@
 
 
 int main() {
-    //mnd::MandelContext mndCtxt = mnd::initializeContext();
+    mnd::MandelContext mndCtxt = mnd::initializeContext();
 
 
     ExportVideoInfo evi;
     
     evi.start = mnd::MandelViewport::standardView();
-    evi.end = mnd::MandelViewport {
+    /*evi.end = mnd::MandelViewport {
         mnd::Real("-1.5016327722130767973008541252724123393337183519056236025189105693015282429244791506194548898968185999262221668435271537932672968559900159142085320685031"),
         mnd::Real("9.1949171527697821768939276268368163504538591789778359909730511642378316080598664365235178721745031546786105261407973733873085119833457073054327967448264e-06"),
         mnd::Real("1.6236294899543021550377844129369984149698872979955210084321757728274664401182171658849308001321609757279087031477100527629814577654596624031152718524352e-10"),
         mnd::Real("1.2246019034401093377903721086780361028058704962292211685926779200766324399350798858672587301860274703389823933260119617558370004128301410779021141722617e-10")
+    };*/
+    evi.end = mnd::MandelViewport {
+        mnd::Real("-2.0"),
+        mnd::Real("-1.0"),
+        mnd::Real("1.0e-3"),
+        mnd::Real("1.0e-3")
     };
     //evi.end.zoomCenter(1.0e+27);
     evi.gradient = Gradient::defaultGradient();
 
-    evi.width = 64;
-    evi.height = 64;
-    evi.maxIterations = 5000;
-    evi.fps = 30;
-    evi.zoomSpeed = 1.3;
+    evi.mi.bWidth = 1280;
+    evi.mi.bHeight = 720;
+    evi.mi.maxIter = 1000;
+    evi.fps = 60;
+    evi.zoomSpeed = 1.0;
     evi.path = "video.avi";
     evi.bitrate = 1500;
     evi.preset = "veryfast";
 
-    evi.start.adjustAspectRatio(evi.width, evi.height);
+    evi.start.adjustAspectRatio(evi.mi.bWidth, evi.mi.bHeight);
 
-    //MandelVideoGenerator mvg(evi);
+    MandelVideoGenerator mvg(evi);
 
-    //mvg.generate();
+    mvg.generate(mndCtxt.getDefaultGenerator());
     //
     
 
+/*
     mnd::MandelContext mc = mnd::initializeContext();
     mnd::MandelInfo mi;
     mi.view = evi.start;
@@ -50,6 +57,7 @@ int main() {
     iei.gradient = &evi.gradient;
     iei.generator = &mc.getDefaultGenerator();
     alm::exportPng("file.png", iei);
+*/
 
     return 0;
 }