Commit d9914774 authored by Peter Zhigalov's avatar Peter Zhigalov

Портировал изменения в проект с WinAPI

parent 59a224c2
......@@ -107,7 +107,7 @@ public:
float width;
float length;
float arrow_size;
lines_config(QColor n_color = Qt::black, float n_width = 1.0f, float n_length = 10.0f, float n_arrow_size = 5.0f)
lines_config(const QColor & n_color = Qt::black, float n_width = 1.0f, float n_length = 10.0f, float n_arrow_size = 5.0f)
: color(n_color), width(n_width), length(n_length), arrow_size(n_arrow_size) {}
};
......
This diff is collapsed.
......@@ -797,6 +797,8 @@ paintwidget::paintwidget()
hbmp_is_valid = false;
memset(&ps, 0, sizeof(PAINTSTRUCT));
isolines_config = lines_config(RGB(0, 0, 0), 1);
vectors_config = lines_config(RGB(0, 0, 0), 1, 10.0f, 5.0f);
use_purple = false;
use_legend = true;
use_light_colors = true;
......@@ -1187,11 +1189,11 @@ void paintwidget::draw(HDC hdc_local)
}
}
HPEN hIsolPen = GetStockPen(BLACK_PEN);
hOldPen = (HPEN)SelectObject(hdc_local, hIsolPen);
// Изолинии рисуем только если оно нам надо
if(draw_isolines)
{
HPEN hIsolPen = CreatePen(PS_SOLID, isolines_config.width, isolines_config.color);
hOldPen = (HPEN)SelectObject(hdc_local, hIsolPen);
for(size_t i = 0; i < triangles.size(); i++)
{
// Теперь рисуем изолинии
......@@ -1230,8 +1232,9 @@ void paintwidget::draw(HDC hdc_local)
LineTo(hdc_local, x + shift_x, y + shift_y);
}
}
SelectObject(hdc_local, hOldPen);
DeleteObject(hIsolPen);
}
SelectObject(hdc_local, hOldPen);
// Легенда
if(use_legend)
......@@ -1325,12 +1328,10 @@ void paintwidget::draw(HDC hdc_local)
if(draw_vectors)
{
HPEN hVecPen = GetStockPen(BLACK_PEN);
HPEN hVecPen = CreatePen(PS_SOLID, vectors_config.width, vectors_config.color);
hOldPen = (HPEN)SelectObject(hdc_local, hVecPen);
HBRUSH hVecBrush = GetStockBrush(BLACK_BRUSH);
hOldBrush = (HBRUSH)SelectObject(hdc_local, hVecBrush);
float vec_len = 10.5f, arrow_len = 5.5f;
float vec_len = vectors_config.length + 0.5f, arrow_len = vectors_config.arrow_size + 0.5f;
float angle = 38.0f * 3.14159265358979323846f / 180.0f;
float sin_angle = std::sin(angle), cos_angle = std::cos(angle);
......@@ -1376,7 +1377,7 @@ void paintwidget::draw(HDC hdc_local)
}
}
SelectObject(hdc_local, hOldPen);
SelectObject(hdc_local, hOldBrush);
DeleteObject(hVecPen);
}
DeleteObject(fnt_serif);
......
......@@ -86,6 +86,18 @@ public:
}
};
// Класс конфигурация для объектов-линий (изолиний, векторов)
class lines_config
{
public:
COLORREF color;
int width;
float length;
float arrow_size;
lines_config(const COLORREF & n_color = RGB(0, 0, 0), int n_width = 1, float n_length = 10.0f, float n_arrow_size = 5.0f)
: color(n_color), width(n_width), length(n_length), arrow_size(n_arrow_size) {}
};
// Класс виджет для рисования через WinAPI
class paintwidget
{
......@@ -149,6 +161,10 @@ public:
PAINTSTRUCT ps;
HBITMAP hbmp;
// Конфигурация изолиний
lines_config isolines_config;
// Конфигурация векторов
lines_config vectors_config;
// Использовать ли фиолетовые оттенки цвета
// Дает большую комбинацию оттенков, но приводит к
// некоторому дисбалансу между красным и синим
......
......@@ -18,18 +18,27 @@
#define CONTROL_COMBOBOX_VECTORS_U 10010
#define CONTROL_LABEL_VECTORS_V 10011
#define CONTROL_COMBOBOX_VECTORS_V 10012
#define CONTROL_MENU_OPEN 10013
#define CONTROL_MENU_TRANSPARENT 10014
#define CONTROL_MENU_SAVE 10015
#define CONTROL_MENU_EXIT 10016
#define CONTROL_MENU_INCREASE_INTERPOLATION 10017
#define CONTROL_MENU_DECREASE_INTERPOLATION 10018
#define CONTROL_MENU_USELEGEND 10019
#define CONTROL_MENU_USELIGHTCOLORS 10020
#define CONTROL_MENU_USEPURPLE 10021
#define CONTROL_MENU_USEMEMORYLIMIT 10022
#define CONTROL_MENU_ABOUT 10023
#define CONTROL_MENU_ABOUT_LIBS 10024
#define CONTROL_MENU_OPEN 10020
#define CONTROL_MENU_TRANSPARENT 10021
#define CONTROL_MENU_COPY 10022
#define CONTROL_MENU_SAVE 10023
#define CONTROL_MENU_EXIT 10024
#define CONTROL_MENU_INCREASE_INTERPOLATION 10030
#define CONTROL_MENU_DECREASE_INTERPOLATION 10031
#define CONTROL_MENU_ISOLINES_SHOW 10040
#define CONTROL_MENU_ISOLINES_COLOR 10041
#define CONTROL_MENU_ISOLINES_WIDTH 10042
#define CONTROL_MENU_VECTORS_SHOW 10050
#define CONTROL_MENU_VECTORS_COLOR 10051
#define CONTROL_MENU_VECTORS_WIDTH 10052
#define CONTROL_MENU_VECTORS_LENGTH 10053
#define CONTROL_MENU_VECTORS_ARROWSIZE 10054
#define CONTROL_MENU_USELEGEND 10060
#define CONTROL_MENU_USELIGHTCOLORS 10061
#define CONTROL_MENU_USEPURPLE 10062
#define CONTROL_MENU_USEMEMORYLIMIT 10063
#define CONTROL_MENU_ABOUT 10070
#define CONTROL_MENU_ABOUT_LIBS 10071
#define ABOUT_LABEL_VERSION 10100
#define ABOUT_LABEL_SITE 10101
#define ABOUT_LABEL_LICENSE 10102
......@@ -67,6 +76,11 @@
#define ABOUT_LIBS_LABEL_URL_TGA 10224
#define ABOUT_LIBS_BUTTON_OK 10225
#define ABOUT_LIBS_LABEL_LOGO 10226
#define INPUTBOX_LABEL_TEXT 10300
#define INPUTBOX_SPINBOX_TEXT 10301
#define INPUTBOX_SPINBOX_UPDOWN 10302
#define INPUTBOX_BUTTON_OK 10303
#define INPUTBOX_BUTTON_CANCEL 10304
#include <windows.h>
#include <commctrl.h>
......
......@@ -7,6 +7,7 @@ IDC_HAND_FB CURSOR DISCARDABLE "../resources/hand.cur"
APP_ACCELERATORS ACCELERATORS
BEGIN
0x4F, CONTROL_MENU_OPEN, VIRTKEY, CONTROL
"^C", CONTROL_MENU_COPY, VIRTKEY, CONTROL
0x53, CONTROL_MENU_SAVE, VIRTKEY, CONTROL
0x51, CONTROL_MENU_EXIT, VIRTKEY, CONTROL
VK_OEM_PLUS, CONTROL_MENU_INCREASE_INTERPOLATION, VIRTKEY
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment