追加岩心图片、图像成像2个绘制
This commit is contained in:
parent
5512745b23
commit
1b03eacaa0
|
|
@ -59,6 +59,9 @@ signals:
|
|||
//井斜方位图
|
||||
void sig_AddDenv(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0);
|
||||
|
||||
//图像 成像
|
||||
void sig_AddDrawImage(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0);
|
||||
|
||||
//新建波列
|
||||
void sig_AddWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
|
||||
//删除波列
|
||||
|
|
|
|||
532
logPlus/Gradient.cpp
Normal file
532
logPlus/Gradient.cpp
Normal file
|
|
@ -0,0 +1,532 @@
|
|||
#include "Gradient.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
//extern char *GetBinDir(char *str);
|
||||
|
||||
BYTE GetRValue(COLORREF colour)
|
||||
{
|
||||
QColor color(colour);
|
||||
return color.red();
|
||||
}
|
||||
|
||||
BYTE GetGValue(COLORREF colour)
|
||||
{
|
||||
QColor color(colour);
|
||||
return color.green();
|
||||
}
|
||||
|
||||
BYTE GetBValue(COLORREF colour)
|
||||
{
|
||||
QColor color(colour);
|
||||
return color.blue();
|
||||
}
|
||||
|
||||
|
||||
CGradient::CGradient()
|
||||
{
|
||||
m_StartPeg.colour = 0x00FFFFFF;//
|
||||
m_StartPeg.position = 0.0f;
|
||||
m_EndPeg.colour = 0x00000000;//
|
||||
m_EndPeg.position = 1.0f;
|
||||
m_Background.colour = 0x00FFFFFF; //A default pal
|
||||
m_Background.position = 0.0f;
|
||||
m_InterpolationMethod = Linear;
|
||||
m_UseBackground = false;
|
||||
m_Quantization = -1;
|
||||
|
||||
m_FileFlag = "LogPlus";
|
||||
pegs.clear();
|
||||
}
|
||||
CGradient::~CGradient()
|
||||
{
|
||||
pegs.clear();
|
||||
}
|
||||
|
||||
//void CGradient::MakeEntries(RGBTRIPLE *lpPal, int iEntryCount)
|
||||
//{
|
||||
// float pos;
|
||||
// COLORREF colour;
|
||||
// int curpeg;
|
||||
// if ( iEntryCount < 1 || iEntryCount >= 65535)
|
||||
// return ;
|
||||
|
||||
// InterpolateFn Interpolate = GetInterpolationProc();
|
||||
|
||||
// if(pegs.count() > 0)
|
||||
// {
|
||||
// //Some things are already constant and so can be found early
|
||||
// float firstpegpos = pegs[0].position;
|
||||
// float lastpegpos = pegs[pegs.count()-1].position;
|
||||
// COLORREF lastpegcolour = pegs[pegs.count()-1].colour;
|
||||
|
||||
|
||||
// for(int i = 0; i < iEntryCount; i++)
|
||||
// {
|
||||
// if(m_Quantization == -1)
|
||||
// pos = (float)i/iEntryCount;
|
||||
// else
|
||||
// pos = ((float)(int)(((float)i/iEntryCount)*m_Quantization))/m_Quantization + 0.5f / m_Quantization;
|
||||
|
||||
// if(pos <= firstpegpos)
|
||||
// {
|
||||
// colour = Interpolate(m_StartPeg.colour, pegs[0].colour, pos, 0, firstpegpos);
|
||||
// lpPal[i].rgbtRed = GetRValue(colour);
|
||||
// lpPal[i].rgbtGreen = GetGValue(colour);
|
||||
// lpPal[i].rgbtBlue = GetBValue(colour);
|
||||
// }
|
||||
// else if(pos > lastpegpos)
|
||||
// {
|
||||
// colour = Interpolate(lastpegcolour, m_EndPeg.colour, pos, lastpegpos, 1);
|
||||
// lpPal[i].rgbtRed = GetRValue(colour);
|
||||
// lpPal[i].rgbtGreen = GetGValue(colour);
|
||||
// lpPal[i].rgbtBlue = GetBValue(colour);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// curpeg = IndexFromPos(pos);
|
||||
// colour = Interpolate(pegs[curpeg].colour, pegs[curpeg+1].colour, pos, pegs[curpeg].position, pegs[curpeg+1].position);
|
||||
// lpPal[i].rgbtRed = GetRValue(colour);
|
||||
// lpPal[i].rgbtGreen = GetGValue(colour);
|
||||
// lpPal[i].rgbtBlue = GetBValue(colour);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //When there are no extra peg we can just interpolate the start and end
|
||||
// for(int i = 0; i < iEntryCount; i++)
|
||||
// {
|
||||
// if(m_Quantization == -1)
|
||||
// pos = (float)i/iEntryCount;
|
||||
// else
|
||||
// pos = ((float)(int)(((float)i/iEntryCount)*m_Quantization))/m_Quantization + 0.5f / m_Quantization;
|
||||
|
||||
// colour = Interpolate(m_StartPeg.colour, m_EndPeg.colour, pos, 0, 1);
|
||||
// lpPal[i].rgbtRed = GetRValue(colour);
|
||||
// lpPal[i].rgbtGreen = GetGValue(colour);
|
||||
// lpPal[i].rgbtBlue = GetBValue(colour);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(m_UseBackground)
|
||||
// {
|
||||
// lpPal[0].rgbtRed = GetRValue(m_Background.colour);
|
||||
// lpPal[0].rgbtGreen = GetGValue(m_Background.colour);
|
||||
// lpPal[0].rgbtBlue = GetBValue(m_Background.colour);
|
||||
// }
|
||||
//}
|
||||
|
||||
InterpolateFn CGradient::GetInterpolationProc()
|
||||
{
|
||||
switch(m_InterpolationMethod)
|
||||
{
|
||||
case Linear: return InterpolateLinear;
|
||||
case FlatStart: return InterpolateFlatStart;
|
||||
case FlatMid: return InterpolateFlatMid;
|
||||
case FlatEnd: return InterpolateFlatEnd;
|
||||
case Cosine: return InterpolateCosine;
|
||||
case HSLRedBlue: return InterpolateHSLClockwise;
|
||||
case HSLBlueRed: return InterpolateHSLAntiClockwise;
|
||||
case HSLShortest: return InterpolateHSLShortest;
|
||||
case HSLLongest: return InterpolateHSLLongest;
|
||||
case Reverse:
|
||||
{
|
||||
QVector <CPeg> pegsTemp;
|
||||
//CArray <CPeg, CPeg&> pegsTemp;
|
||||
int n = pegs.count();
|
||||
pegsTemp.clear();
|
||||
pegsTemp.resize(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
pegsTemp[i].colour = pegs[n-i-1].colour;
|
||||
}
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
pegs[i].colour = pegsTemp[i].colour;
|
||||
}
|
||||
|
||||
CPeg temp;
|
||||
temp.colour = m_StartPeg.colour;
|
||||
m_StartPeg.colour = m_EndPeg.colour;
|
||||
m_EndPeg.colour = temp.colour;
|
||||
|
||||
return InterpolateReverse;
|
||||
}
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CGradient::IndexFromPos(float pos)
|
||||
{
|
||||
//ASSERT(pos >= 0.0f && pos <= 1.0f);
|
||||
if ( pos<0 || pos>1 )
|
||||
return NONE;
|
||||
// positions betwen 0 and 1!
|
||||
|
||||
if(pos < pegs[0].position)
|
||||
return STARTPEG;
|
||||
|
||||
for(int i = 0; i < pegs.count()-1; i++)
|
||||
if(pos >= pegs[i].position && pos <= pegs[i+1].position)
|
||||
return i;
|
||||
|
||||
return -1; // Eh? somethings wrong here
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateLinear(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
if(start == end) return first;
|
||||
if(end - start == 0) return second;
|
||||
if(position == start) return first;
|
||||
if(position == end) return second;
|
||||
return RGB((BYTE)((GetRValue(second)*(position - start) + GetRValue(first)*(end-position))/(end-start)),
|
||||
(BYTE)((GetGValue(second)*(position - start) + GetGValue(first)*(end-position))/(end-start)),
|
||||
(BYTE)((GetBValue(second)*(position - start) + GetBValue(first)*(end-position))/(end-start)));
|
||||
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateReverse(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
if(start == end) return first;
|
||||
if(end - start == 0) return second;
|
||||
if(position == start) return first;
|
||||
if(position == end) return second;
|
||||
// return RGB((BYTE)((GetRValue(first)*(position - start) + GetRValue(second)*(end-position))/(end-start)),
|
||||
// (BYTE)((GetGValue(first)*(position - start) + GetGValue(second)*(end-position))/(end-start)),
|
||||
// (BYTE)((GetBValue(first)*(position - start) + GetBValue(second)*(end-position))/(end-start)));
|
||||
|
||||
return RGB((BYTE)((GetRValue(second)*(position - start) + GetRValue(first)*(end-position))/(end-start)),
|
||||
(BYTE)((GetGValue(second)*(position - start) + GetGValue(first)*(end-position))/(end-start)),
|
||||
(BYTE)((GetBValue(second)*(position - start) + GetBValue(first)*(end-position))/(end-start)));
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateFlatStart(COLORREF first, COLORREF, float, float, float)
|
||||
{return first;}
|
||||
|
||||
COLORREF CGradient::InterpolateFlatMid(COLORREF first, COLORREF second, float, float, float)
|
||||
{
|
||||
unsigned short sr, sg, sb, er, eg, eb;
|
||||
sr = GetRValue(first);
|
||||
sg = GetGValue(first);
|
||||
sb = GetBValue(first);
|
||||
er = GetRValue(second);
|
||||
eg = GetGValue(second);
|
||||
eb = GetBValue(second);
|
||||
|
||||
return RGB((sr+er)/2, (sg+eg)/2, (sb+eb)/2);
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateFlatEnd(COLORREF, COLORREF second, float, float, float)
|
||||
{return second;}
|
||||
|
||||
COLORREF CGradient::InterpolateCosine(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
float theta = (position-start)/(end-start) * 3.1415927f;
|
||||
float f = (1 - cosf(theta)) * .5f;
|
||||
|
||||
return RGB((BYTE)(((float)GetRValue(first))*(1-f) + ((float)GetRValue(second))*f),
|
||||
(BYTE)(((float)GetGValue(first))*(1-f) + ((float)GetGValue(second))*f),
|
||||
(BYTE)(((float)GetBValue(first))*(1-f) + ((float)GetBValue(second))*f));
|
||||
}
|
||||
void RGB_to_HSL (float r, float g, float b, float *h, float *s, float *l)
|
||||
{
|
||||
float v;
|
||||
float m;
|
||||
float vm;
|
||||
float r2, g2, b2;
|
||||
|
||||
v = max(r,g);
|
||||
v = max(v,b);
|
||||
m = min(r,g);
|
||||
m = min(m,b);
|
||||
|
||||
if ((*l = (m + v) / 2.0f) <= 0.0f) return;
|
||||
if ((*s = vm = v - m) > 0.0f) {
|
||||
*s /= (*l <= 0.5f) ? (v + m ) :
|
||||
(2.0f - v - m) ;
|
||||
} else
|
||||
return;
|
||||
|
||||
|
||||
r2 = (v - r) / vm;
|
||||
g2 = (v - g) / vm;
|
||||
b2 = (v - b) / vm;
|
||||
|
||||
if (r == v)
|
||||
*h = (g == m ? 5.0f + b2 : 1.0f - g2);
|
||||
else if (g == v)
|
||||
*h = (b == m ? 1.0f + r2 : 3.0f - b2);
|
||||
else
|
||||
*h = (r == m ? 3.0f + g2 : 5.0f - r2);
|
||||
|
||||
*h /= 6.0f;
|
||||
}
|
||||
|
||||
void HSL_to_RGB(float h, float sl, float l, float *r, float *g, float *b)
|
||||
{
|
||||
float v;
|
||||
|
||||
v = (l <= 0.5f) ? (l * (1.0f + sl)) : (l + sl - l * sl);
|
||||
if (v <= 0) {
|
||||
*r = *g = *b = 0.0f;
|
||||
} else {
|
||||
float m;
|
||||
float sv;
|
||||
int sextant;
|
||||
float fract, vsf, mid1, mid2;
|
||||
|
||||
m = l + l - v;
|
||||
sv = (v - m ) / v;
|
||||
h *= 6.0f;
|
||||
sextant = (int)h;
|
||||
fract = h - sextant;
|
||||
vsf = v * sv * fract;
|
||||
mid1 = m + vsf;
|
||||
mid2 = v - vsf;
|
||||
switch (sextant) {
|
||||
case 0: *r = v; *g = mid1; *b = m; break;
|
||||
case 1: *r = mid2; *g = v; *b = m; break;
|
||||
case 2: *r = m; *g = v; *b = mid1; break;
|
||||
case 3: *r = m; *g = mid2; *b = v; break;
|
||||
case 4: *r = mid1; *g = m; *b = v; break;
|
||||
case 5: *r = v; *g = m; *b = mid2; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateHSLClockwise(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
float sh = 0, ss = 0, sl = 0, eh = 0, es = 0, el = 0, h = 0, s = 0, l = 0, r = 0, g = 0, b = 0;
|
||||
RGB_to_HSL((float)GetRValue(first)/255.0f, (float)GetGValue(first)/255.0f,
|
||||
(float)GetBValue(first)/255.0f, &sh, &ss, &sl);
|
||||
RGB_to_HSL((float)GetRValue(second)/255.0f, (float)GetGValue(second)/255.0f,
|
||||
(float)GetBValue(second)/255.0f, &eh, &es, &el);
|
||||
|
||||
sh = sh - floorf(sh);
|
||||
eh = eh - floorf(eh);
|
||||
|
||||
//Interpolate H clockwise
|
||||
if(eh >= sh) h = (eh*(position - start) + sh*(end-position))/(end-start);
|
||||
else h = ((eh + 1.0f)*(position - start) + sh*(end-position))/(end-start);
|
||||
h = (h>=1.0f)?h-1.0f:h;
|
||||
|
||||
s = ((es*(position - start) + ss*(end-position))/(end-start));
|
||||
l = ((el*(position - start) + sl*(end-position))/(end-start));
|
||||
|
||||
HSL_to_RGB(h, s, l, &r, &g, &b);
|
||||
return RGB((BYTE)(r*255.0f), (BYTE)(g*255.0f), (BYTE)(b*255.0f));
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateHSLAntiClockwise(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
float sh = 0, ss = 0, sl = 0, eh = 0, es = 0, el = 0, h = 0, s = 0, l = 0, r = 0, g = 0, b = 0;
|
||||
RGB_to_HSL((float)GetRValue(first)/255.0f, (float)GetGValue(first)/255.0f,
|
||||
(float)GetBValue(first)/255.0f, &sh, &ss, &sl);
|
||||
RGB_to_HSL((float)GetRValue(second)/255.0f, (float)GetGValue(second)/255.0f,
|
||||
(float)GetBValue(second)/255.0f, &eh, &es, &el);
|
||||
|
||||
sh = sh - floorf(sh);
|
||||
eh = eh - floorf(eh);
|
||||
|
||||
//Interpolate H anticlockwise
|
||||
if(eh <= sh) h = (eh*(position - start) + sh*(end-position))/(end-start);
|
||||
else h = ((eh + 1.0f)*(position - start) + sh*(end-position))/(end-start);
|
||||
h = (h>=1.0f)?h-1.0f:h;
|
||||
|
||||
s = ((es*(position - start) + ss*(end-position))/(end-start));
|
||||
l = ((el*(position - start) + sl*(end-position))/(end-start));
|
||||
|
||||
HSL_to_RGB(h, s, l, &r, &g, &b);
|
||||
return RGB((BYTE)(r*255.0f), (BYTE)(g*255.0f), (BYTE)(b*255.0f));
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateHSLLongest(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
float sh = 0, ss = 0, sl = 0, eh = 0, es = 0, el = 0, h = 0, s = 0, l = 0, r = 0, g = 0, b = 0;
|
||||
RGB_to_HSL((float)GetRValue(first)/255.0f, (float)GetGValue(first)/255.0f,
|
||||
(float)GetBValue(first)/255.0f, &sh, &ss, &sl);
|
||||
RGB_to_HSL((float)GetRValue(second)/255.0f, (float)GetGValue(second)/255.0f,
|
||||
(float)GetBValue(second)/255.0f, &eh, &es, &el);
|
||||
|
||||
sh = sh - (float)floor(sh);
|
||||
eh = eh - (float)floor(eh);
|
||||
|
||||
//Interpolate H short route
|
||||
if(((eh-sh)-floor(eh-sh) < 0.5f)?(eh < sh):(eh >= sh)) h = (eh*(position - start) + sh*(end-position))/(end-start);
|
||||
else h = ((eh+(sh>eh?1.0f:-1.0f))*(position - start) + sh*(end-position))/(end-start);
|
||||
//TRACE3("sh: %f eh: %f h: %f\n", sh, eh, h);
|
||||
|
||||
h = h - floorf(h);
|
||||
|
||||
s = ((es*(position - start) + ss*(end-position))/(end-start));
|
||||
l = ((el*(position - start) + sl*(end-position))/(end-start));
|
||||
|
||||
HSL_to_RGB(h, s, l, &r, &g, &b);
|
||||
return RGB((BYTE)(r*255.0f), (BYTE)(g*255.0f), (BYTE)(b*255.0f));
|
||||
}
|
||||
|
||||
COLORREF CGradient::InterpolateHSLShortest(COLORREF first, COLORREF second, float position, float start, float end)
|
||||
{
|
||||
float sh = 0, ss = 0, sl = 0, eh = 0, es = 0, el = 0, h = 0, s = 0, l = 0, r = 0, g = 0, b = 0;
|
||||
RGB_to_HSL((float)GetRValue(first)/255.0f, (float)GetGValue(first)/255.0f,
|
||||
(float)GetBValue(first)/255.0f, &sh, &ss, &sl);
|
||||
RGB_to_HSL((float)GetRValue(second)/255.0f, (float)GetGValue(second)/255.0f,
|
||||
(float)GetBValue(second)/255.0f, &eh, &es, &el);
|
||||
|
||||
sh = sh - (float)floor(sh);
|
||||
eh = eh - (float)floor(eh);
|
||||
|
||||
//Interpolate H short route
|
||||
if(((eh-sh)-floor(eh-sh) > 0.5f)?(eh < sh):(eh >= sh)) h = (eh*(position - start) + sh*(end-position))/(end-start);
|
||||
else h = ((eh+(sh>eh?1.0f:-1.0f))*(position - start) + sh*(end-position))/(end-start);
|
||||
//TRACE3("sh: %f eh: %f h: %f\n", sh, eh, h);
|
||||
|
||||
h = h - floorf(h);
|
||||
|
||||
s = ((es*(position - start) + ss*(end-position))/(end-start));
|
||||
l = ((el*(position - start) + sl*(end-position))/(end-start));
|
||||
|
||||
HSL_to_RGB(h, s, l, &r, &g, &b);
|
||||
return RGB((BYTE)(r*255.0f), (BYTE)(g*255.0f), (BYTE)(b*255.0f));
|
||||
}
|
||||
|
||||
void CGradient::GetColorArray(COLORREF colorArr[])
|
||||
{
|
||||
float pos;
|
||||
|
||||
InterpolateFn Interpolate = GetInterpolationProc();
|
||||
|
||||
//if (pegs.GetSize() > 0)
|
||||
if (pegs.count() > 0)
|
||||
{
|
||||
float firstpegpos = pegs[0].position;
|
||||
COLORREF fistpegcolour = pegs[0].colour;
|
||||
float lastpegpos = pegs[pegs.count()-1].position;
|
||||
COLORREF lastpegcolour = pegs[pegs.count()-1].colour;
|
||||
//float lastpegpos = pegs[pegs.GetUpperBound()].position;
|
||||
//COLORREF lastpegcolour = pegs[pegs.GetUpperBound()].colour;
|
||||
int curpeg;
|
||||
|
||||
int index; float pos2; COLORREF colour;
|
||||
for (index=0,pos=0.0; index<256; index++,pos+=0.003906)
|
||||
{
|
||||
if(m_Quantization != -1)
|
||||
pos2 = ((float)(int)(pos*m_Quantization))/m_Quantization + 0.5f / m_Quantization;
|
||||
else pos2 = pos;
|
||||
|
||||
if (pos2 <= firstpegpos)
|
||||
{
|
||||
colour = Interpolate(m_StartPeg.colour, pegs[0].colour, pos2, 0, firstpegpos);
|
||||
colorArr[index] = colour;
|
||||
}
|
||||
else if (pos2 > lastpegpos)
|
||||
{
|
||||
colour = Interpolate(lastpegcolour, m_EndPeg.colour, pos2, lastpegpos, 1);
|
||||
colorArr[index] = colour;
|
||||
}
|
||||
else
|
||||
{
|
||||
curpeg = IndexFromPos2(pos2);
|
||||
colour = Interpolate(pegs[curpeg].colour, pegs[curpeg+1].colour, pos2, pegs[curpeg].position, pegs[curpeg+1].position);
|
||||
colorArr[index] = colour;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else //pegs.size == 0
|
||||
{
|
||||
int index; float pos2; COLORREF colour;
|
||||
for (index=0,pos=0.0; index<256; index++,pos+=0.003906)
|
||||
{
|
||||
if (m_Quantization != -1)
|
||||
pos2 = ((float)(int)(pos*m_Quantization))/m_Quantization + 0.5f / m_Quantization;
|
||||
else pos2 = pos;
|
||||
|
||||
colour = Interpolate(m_StartPeg.colour, m_EndPeg.colour, pos2, 0, 1);
|
||||
colorArr[index] = colour;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
int CGradient::IndexFromPos2(float pos)
|
||||
{
|
||||
int begin = 0;
|
||||
//int end = pegs.GetSize()-1;
|
||||
int end = pegs.count()-1;
|
||||
int mid;
|
||||
|
||||
while(begin <= end)
|
||||
{
|
||||
mid = (begin + end) / 2;
|
||||
if (pos > pegs[mid].position)
|
||||
{
|
||||
begin = mid+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = mid-1;
|
||||
}
|
||||
}
|
||||
|
||||
// if (mid==0)
|
||||
// mid =1;
|
||||
return end;
|
||||
}
|
||||
//读取配色方案
|
||||
void CGradient::Serialize(QString strCfg)//CArchive &ar)
|
||||
{
|
||||
//lhj 2019-8-14 配色文件转换成TXT格式
|
||||
// 保存为TXT格式
|
||||
// strCfg.TrimLeft();
|
||||
// strCfg.TrimRight();
|
||||
strCfg.trimmed();
|
||||
|
||||
int i,n;
|
||||
char str[256],strName[256];
|
||||
//CString strCipPath;
|
||||
CPeg peg;
|
||||
|
||||
//GetBinDir(str);
|
||||
memset(str, '\0', sizeof (str));
|
||||
strcat(str, QCoreApplication::applicationDirPath().toStdString().c_str());
|
||||
strcat(str,"\\color\\");
|
||||
strcat(str,strCfg.toStdString().c_str());
|
||||
//strcat(str,"_clr.cfg");
|
||||
|
||||
FILE *fp;
|
||||
fp=fopen(str,"r");
|
||||
if ( fp!=NULL)
|
||||
{
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%s",str);
|
||||
//m_FileFlag.Format("%s",str);
|
||||
m_FileFlag = str;
|
||||
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%ld",&m_Background.colour);
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%ld %ld",&m_StartPeg.colour,&m_EndPeg.colour);
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%d",&i);
|
||||
m_UseBackground=i;
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%d",&m_Quantization);
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%d",&m_InterpolationMethod);
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%d",&n);
|
||||
pegs.clear();
|
||||
for( i = 0; i < n; i++)
|
||||
{
|
||||
fgets(strName,256,fp);
|
||||
sscanf(strName,"%ld %g",&peg.colour,&peg.position);
|
||||
pegs.append(peg);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
111
logPlus/Gradient.h
Normal file
111
logPlus/Gradient.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
// Gradient.h : header file
|
||||
#ifndef Gradient_H
|
||||
#define Gradient_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include "CStringType.h"
|
||||
|
||||
//typedef struct myRGBTRIPLE {
|
||||
// BYTE rgbtBlue;
|
||||
// BYTE rgbtGreen;
|
||||
// BYTE rgbtRed;
|
||||
//} RGBTRIPLE;
|
||||
|
||||
typedef DWORD COLORREF;
|
||||
typedef DWORD *LPCOLORREF;
|
||||
|
||||
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
|
||||
|
||||
//#define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff))
|
||||
|
||||
//#define GetRValue(rgb) (LOBYTE(rgb))
|
||||
//#define GetGValue(rgb) (LOBYTE(((WORD)(rgb)) >> 8))
|
||||
//#define GetBValue(rgb) (LOBYTE((rgb)>>16))
|
||||
|
||||
typedef COLORREF (__cdecl* InterpolateFn)(COLORREF first, COLORREF second, float position, float start, float end);
|
||||
typedef struct CPeg {
|
||||
COLORREF colour;
|
||||
float position;
|
||||
} ;
|
||||
enum DataType{LINEAR, LOG};
|
||||
enum InterpolationMethod
|
||||
{
|
||||
Linear,
|
||||
FlatStart,
|
||||
FlatMid,
|
||||
FlatEnd,
|
||||
Cosine,
|
||||
HSLRedBlue,
|
||||
HSLBlueRed,
|
||||
HSLShortest,
|
||||
HSLLongest,
|
||||
Reverse
|
||||
};
|
||||
|
||||
//不滤波;3×3平均;3×3十字;N×N平均;Sobel边缘增强;Robert边缘增强;中值滤波;Laplacian边缘增强;USM;自适应滤波;保守滤波;
|
||||
enum FilterMethod
|
||||
{
|
||||
NONEMETHOD, //不滤波
|
||||
MEANDEFAULT, //3×3平均
|
||||
CROSS,
|
||||
MEANCUSTOM,
|
||||
SOBEL,
|
||||
ROBERT,
|
||||
Median,
|
||||
Laplacian,
|
||||
USM,
|
||||
Adaptive,
|
||||
Conservative
|
||||
};
|
||||
#define BACKGROUND -4
|
||||
#define STARTPEG -3
|
||||
#define ENDPEG -2
|
||||
#define NONE -1
|
||||
class CGradient
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CGradient();
|
||||
~CGradient();
|
||||
// Attributes
|
||||
public:
|
||||
QVector <CPeg> pegs;
|
||||
bool m_UseBackground;
|
||||
CPeg m_StartPeg, m_EndPeg, m_Background;//ace
|
||||
int m_Quantization;
|
||||
InterpolationMethod m_InterpolationMethod;
|
||||
QString m_FileFlag;
|
||||
public:
|
||||
//void MakeEntries(RGBTRIPLE *lpPal, int iEntryCount);
|
||||
void GetColorArray(COLORREF colorArr[]);
|
||||
InterpolateFn GetInterpolationProc();
|
||||
int IndexFromPos2(float pos);
|
||||
int IndexFromPos(float pos);
|
||||
void Serialize(QString strCfg);//CArchive &ar);
|
||||
COLORREF GetBackgroundColour() const {return m_Background.colour;};
|
||||
//----- Interpolation routines -----//
|
||||
static COLORREF InterpolateLinear(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateFlatStart(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateFlatMid(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateFlatEnd(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateCosine(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateHSLClockwise(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateHSLAntiClockwise(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateHSLLongest(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateHSLShortest(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
static COLORREF InterpolateReverse(COLORREF first, COLORREF second,
|
||||
float position, float start, float end);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#include "DraggablePixmap.h"
|
||||
#include "TransparentDraggableRect.h"
|
||||
#include <QtMath>
|
||||
#include "Gradient.h"
|
||||
|
||||
//以下参数从配置文件读取
|
||||
extern int g_iIndex;
|
||||
|
|
@ -68,6 +69,9 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
|
|||
//井斜方位图
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_AddDenv(QString, QString, QString, QString, QString, int)), this, SLOT(s_addDenv(QString, QString, QString, QString, QString,int)));
|
||||
|
||||
//图像 成图
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_AddDrawImage(QString, QString, QString, QString, QString, int)), this, SLOT(s_addDrawImage(QString, QString, QString, QString, QString,int)));
|
||||
|
||||
}
|
||||
|
||||
FormDraw::~FormDraw()
|
||||
|
|
@ -331,6 +335,7 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam
|
|||
if(g_iSupport3D)
|
||||
{
|
||||
initWave_3D(curv, strSlfName, strWaveName);
|
||||
//DrawImageNew_NoFilter(curv, strSlfName, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -349,7 +354,7 @@ void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWe
|
|||
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT"
|
||||
|| strLineName == "GEO_LITH" || strLineName == "SWALL_CORE"
|
||||
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT"
|
||||
|| strLineName == "CORE_PHYSICS")
|
||||
|| strLineName == "CORE_PHYSICS"|| strLineName == "IMAGE_DATA")
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -447,6 +452,11 @@ void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWe
|
|||
//岩心实验数据
|
||||
initCorePhysics(curv, strSlfName, strLineName);
|
||||
}
|
||||
else if(strLineName == "IMAGE_DATA")
|
||||
{
|
||||
//岩心图片
|
||||
initIMAGE_DATA(curv, strSlfName, strLineName);
|
||||
}
|
||||
|
||||
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||
|
||||
|
|
@ -1130,6 +1140,75 @@ void FormDraw::s_addDenv(QString strUuid, QString strSlfName, QString strWellNam
|
|||
m_listLineName.push_back(strLineName);
|
||||
}
|
||||
|
||||
void FormDraw::s_addDrawImage(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW)
|
||||
{
|
||||
//井名&道名不一致
|
||||
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_listLineName.contains(strLineName))
|
||||
{
|
||||
qDebug() << "FormDraw strLineName already exist! " << strLineName;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName);
|
||||
curv->m_strUuid = m_strUuid;
|
||||
//背景设置成透明色
|
||||
curv->setBackground(Qt::transparent);
|
||||
curv->setStyleSheet("background: transparent;");
|
||||
//
|
||||
//QRect rect = this->rect();
|
||||
//curv->setGeometry(rect.left(),rect.top(), rect.width(), rect.height());
|
||||
|
||||
double dHight = 0;
|
||||
dHight = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm;
|
||||
if(g_iShow==1)
|
||||
{
|
||||
//显示刻度
|
||||
dHight = dHight+30;
|
||||
}
|
||||
qDebug() << "FormDraw dHight=" << QString::number((int)dHight);
|
||||
if(dHight>32767)
|
||||
{
|
||||
dHight = 32767;
|
||||
}
|
||||
|
||||
//curv->setMaximumHeight((int)dHight);
|
||||
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
|
||||
curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184
|
||||
|
||||
|
||||
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
|
||||
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// curv->setSizePolicy(policy);
|
||||
|
||||
curv->show();
|
||||
|
||||
//图像 成像
|
||||
DrawImageNew_NoFilter(curv, strSlfName, "");
|
||||
|
||||
//道-对象
|
||||
QString strAliasName = "井斜方位图";
|
||||
QString strUnit = "(°)";
|
||||
QColor newlineColor=QColor(0,0,0);
|
||||
double width=2;
|
||||
QString strScaleType = "";
|
||||
//道-对象
|
||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "DrawImageObject");
|
||||
//
|
||||
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||
|
||||
//
|
||||
m_listLineName.push_back(strLineName);
|
||||
}
|
||||
|
||||
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
|
||||
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
|
||||
{
|
||||
|
|
@ -1785,6 +1864,216 @@ void FormDraw::initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString st
|
|||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "waveObject");
|
||||
}
|
||||
|
||||
// 搜索所有配色方案名
|
||||
int FormDraw::getColorConfig(QVector <QString> &qFiles)
|
||||
{
|
||||
char str[256],*buffer;
|
||||
int i,nRet=0;
|
||||
QString qstr;
|
||||
QByteArray ba;
|
||||
|
||||
//GetBinDir(str);
|
||||
qstr = QCoreApplication::applicationDirPath();//QString(QLatin1String(str)); //char*=>QString
|
||||
qstr+="\\color\\colorConfig.list";
|
||||
qFiles.clear();
|
||||
QFile f(qstr);
|
||||
if(!f.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
//cout << "Open failed." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QTextStream txtInput(&f);
|
||||
qstr = txtInput.readLine();
|
||||
//QString==>char *
|
||||
ba = qstr.toLatin1(); // must
|
||||
buffer=ba.data();
|
||||
sscanf(buffer,"%d",&nRet);
|
||||
for (i=0;i<nRet;i++)
|
||||
{
|
||||
qstr = txtInput.readLine();
|
||||
qFiles.append(qstr);
|
||||
}
|
||||
f.close();
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
void FormDraw::DrawImageNew_NoFilter(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
||||
{
|
||||
if(strSlfName.isEmpty()) return;
|
||||
if(strWaveName=="" || strWaveName=="AC") strWaveName="DYNIMAGE";
|
||||
//
|
||||
CLogIO *logio=new CLogIO();
|
||||
logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead);
|
||||
//
|
||||
int index=logio->OpenWave(strWaveName.toStdString().c_str());
|
||||
if(index<0) {
|
||||
delete logio;
|
||||
return;
|
||||
}
|
||||
|
||||
Slf_WAVE _wave;
|
||||
logio->GetWaveInfo(index, &_wave);
|
||||
float _SDep,_EDep,_Rlev;
|
||||
_SDep = _wave.StartDepth;
|
||||
_EDep = _wave.EndDepth;
|
||||
// _SDep = 0.0 - g_iY2;
|
||||
// _EDep = 0.0 - g_iY1;
|
||||
_Rlev = _wave.DepLevel;
|
||||
int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5));
|
||||
|
||||
int _nSamples = _wave.TimeSamples;
|
||||
|
||||
char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1];
|
||||
logio->ReadWave(index,_SDep,m_Record,(void *)value);
|
||||
logio->CloseWave(index);
|
||||
delete logio;
|
||||
|
||||
bool bFistValue=false;
|
||||
float vmax = -9999;//(float)_nSamples;
|
||||
float vmin = -9999;
|
||||
//
|
||||
double** wavedata;
|
||||
wavedata = new double*[_nSamples];
|
||||
for(int kk = 0;kk<_nSamples;kk++){
|
||||
wavedata[kk] = new double[m_Record];
|
||||
}
|
||||
|
||||
for (int i=0; i<m_Record; i++)
|
||||
{
|
||||
for(int kk = 0;kk<_nSamples;kk++)
|
||||
{
|
||||
double val = GetData(_wave.RepCode,(char *)&value[(kk)*_wave.CodeLen+i*_nSamples*_wave.CodeLen]);
|
||||
wavedata[kk][i] = val;
|
||||
if(val==-9999)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(bFistValue==false)
|
||||
{
|
||||
//最大值,最小值默认采用第一个有效值
|
||||
bFistValue=true;
|
||||
vmax = vmin = val;
|
||||
}
|
||||
//
|
||||
if(vmax<val)vmax=val;
|
||||
if(vmin>val)vmin=val;
|
||||
}
|
||||
}
|
||||
delete[] value;
|
||||
|
||||
// g_iY1 = 0.0 -_EDep;
|
||||
// g_iY2 = 0.0 -_SDep;
|
||||
//------------------------
|
||||
widget->m_iX1 = vmin;
|
||||
widget->m_iX2 = vmax;
|
||||
widget->m_iY1 = g_iY1;
|
||||
widget->m_iY2 = g_iY2;
|
||||
//
|
||||
widget->xAxis->setRange(vmin, vmax);
|
||||
widget->yAxis->setRange(g_iY1, g_iY2);
|
||||
widget->axisRect()->setupFullAxesBox();
|
||||
//
|
||||
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
|
||||
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
|
||||
|
||||
//对调XY轴,在最前面设置
|
||||
QCPAxis *yAxis = widget->yAxis;
|
||||
QCPAxis *xAxis = widget->xAxis;
|
||||
widget->xAxis = yAxis;
|
||||
widget->yAxis = xAxis;
|
||||
|
||||
//-------------------
|
||||
// set up the QCPColorMap:
|
||||
QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis);
|
||||
int nx = m_Record;
|
||||
int ny = _nSamples;
|
||||
colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点
|
||||
//colorMap->data()->setRange(QCPRange(g_iY1, g_iY2), QCPRange(vmin, vmax)); // 并在键(x)和值(y)维上跨越坐标范围-4..4
|
||||
colorMap->data()->setRange(QCPRange(0-_EDep, 0-_SDep), QCPRange(vmin, vmax));
|
||||
// :现在,我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据:
|
||||
double x, y, z;
|
||||
for (int xIndex=0; xIndex<nx; ++xIndex)
|
||||
{
|
||||
for (int yIndex=0; yIndex<ny; ++yIndex)
|
||||
{
|
||||
if(wavedata[yIndex][xIndex]==-9999)
|
||||
{
|
||||
colorMap->data()->setCell(nx-xIndex-1, yIndex, vmin);
|
||||
continue;
|
||||
}
|
||||
//colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]);
|
||||
colorMap->data()->setCell(nx-xIndex-1, yIndex, wavedata[yIndex][xIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加色标:
|
||||
QCPColorScale *colorScale = new QCPColorScale(widget);
|
||||
colorMap->setColorScale(colorScale); // 将颜色图与色标关联
|
||||
// 将颜色贴图的“颜色渐变”设置为其中一个预设
|
||||
//colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
|
||||
// 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色
|
||||
// 渐变,请参阅QCPColorGradient的文档以获取可能的效果.
|
||||
// int nIndex=11;
|
||||
// QVector<MyColorItem> colorList;
|
||||
// bool inpolation = true;
|
||||
// int iColorNum = getSystemColor(nIndex, colorList, inpolation);
|
||||
// //
|
||||
// QCPColorGradient gradient;
|
||||
// for(int i=0; i<iColorNum; i++)
|
||||
// {
|
||||
// double dbTmpIndex=(double)(i+1)/iColorNum;
|
||||
// gradient.setColorStopAt(dbTmpIndex, colorList[i].color); // x% 位置的颜色
|
||||
// }
|
||||
// colorMap->setGradient(gradient);
|
||||
|
||||
QVector <QString> m_qvFiles;
|
||||
int n=getColorConfig(m_qvFiles);
|
||||
if(n<=0)return;
|
||||
|
||||
//获取配色方案
|
||||
int nIndex=0;
|
||||
CGradient m_GraInfo;
|
||||
m_GraInfo.Serialize(m_qvFiles[nIndex]);
|
||||
|
||||
//获取颜色数组
|
||||
int iColorNum = 256;
|
||||
COLORREF pColorArr[256];
|
||||
m_GraInfo.GetColorArray(pColorArr);
|
||||
|
||||
//
|
||||
QCPColorGradient gradient;
|
||||
for(int i=0; i<iColorNum; i++)
|
||||
{
|
||||
double dbTmpIndex=(double)(i+1)/iColorNum;
|
||||
QColor color(pColorArr[i]);
|
||||
gradient.setColorStopAt(dbTmpIndex, color); // x% 位置的颜色
|
||||
}
|
||||
colorMap->setGradient(gradient);
|
||||
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
|
||||
colorMap->rescaleDataRange();
|
||||
|
||||
//----调色板--------
|
||||
// widget->plotLayout()->addElement(0, 1, colorScale); // 将其添加到主轴矩形的右侧
|
||||
// colorScale->setType(QCPAxis::atRight); // 刻度应为垂直条,刻度线/坐标轴标签右侧(实际上,右侧已经是默认值)
|
||||
// colorScale->axis()->setLabel("Magnetic Field Strength");
|
||||
// //确保轴rect和色标同步其底边距和顶边距(以便它们对齐):
|
||||
// QCPMarginGroup *marginGroup = new QCPMarginGroup(widget);
|
||||
// widget->axisRect()->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
|
||||
// colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
|
||||
|
||||
// 重新缩放键(x)和值(y)轴,以便可以看到整个颜色图:
|
||||
//widget->rescaleAxes();
|
||||
|
||||
QString strAliasName = "";
|
||||
QString strUnit = "";
|
||||
QColor newlineColor=QColor(0,0,0);
|
||||
double width=2;
|
||||
QString strScaleType = "";
|
||||
//道-对象
|
||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "DrawImageObject");
|
||||
}
|
||||
|
||||
|
||||
void FormDraw::initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
||||
|
|
@ -2111,6 +2400,50 @@ void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strL
|
|||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject");
|
||||
|
||||
}
|
||||
void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
|
||||
{
|
||||
|
||||
int iMyWidth = widget->axisRect(0)->width();
|
||||
float vmax = iMyWidth;
|
||||
float vmin = 0;
|
||||
widget->m_iX1 = vmin;
|
||||
widget->m_iX2 = iMyWidth;
|
||||
widget->m_iY1 = g_iY1;
|
||||
widget->m_iY2 = g_iY2;
|
||||
//
|
||||
widget->xAxis->setRange(vmin, vmax);
|
||||
widget->yAxis->setRange(g_iY1, g_iY2);
|
||||
widget->axisRect()->setupFullAxesBox();
|
||||
//
|
||||
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
|
||||
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
|
||||
|
||||
//对调XY轴,在最前面设置
|
||||
QCPAxis *yAxis = widget->yAxis;
|
||||
QCPAxis *xAxis = widget->xAxis;
|
||||
widget->xAxis = yAxis;
|
||||
widget->yAxis = xAxis;
|
||||
|
||||
|
||||
m_LeftVal = 0;
|
||||
m_RightVal = 90;
|
||||
//隐藏刻度
|
||||
widget->xAxis->setTicks(false);
|
||||
widget->yAxis->setTicks(false);
|
||||
widget->xAxis2->setTicks(false);
|
||||
widget->yAxis2->setTicks(false);
|
||||
//
|
||||
LoadFromIMAGE_SLF(widget, strSlfName, strLineName);
|
||||
//显示文本
|
||||
|
||||
QString strAliasName = "岩心图片";
|
||||
QString strUnit = "";
|
||||
QColor newlineColor=QColor(0,0,0);
|
||||
double width=2;
|
||||
QString strScaleType = "";
|
||||
//道-对象
|
||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "yanxinImageObject");
|
||||
}
|
||||
|
||||
bool FormDraw::LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
|
||||
{
|
||||
|
|
@ -2180,6 +2513,61 @@ bool FormDraw::LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString st
|
|||
}
|
||||
return true;
|
||||
}
|
||||
bool FormDraw::LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
|
||||
{
|
||||
{
|
||||
QString ss=strSlfName;
|
||||
CMemRdWt *logio=new CMemRdWt();
|
||||
if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead))
|
||||
{
|
||||
delete logio;
|
||||
// QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes);
|
||||
return false;
|
||||
}
|
||||
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
|
||||
if(iIndex>-1) {
|
||||
int len=logio->GetTableRecordLength(iIndex);
|
||||
if(len<sizeof(IMAGE_DATA)) len=sizeof(IMAGE_DATA);
|
||||
char*buf=new char[len+1];
|
||||
IMAGE_DATA *m_Result=(IMAGE_DATA *)buf;
|
||||
|
||||
int count=logio->GetTableRecordCount(iIndex);
|
||||
for(int i=0;i<count;i++) {
|
||||
memset(m_Result,0,sizeof(IMAGE_DATA));
|
||||
logio->ReadTable(iIndex,i+1,m_Result);
|
||||
// WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth);
|
||||
// if(!item) continue;
|
||||
// OGWordsResultItem* pResult = dynamic_cast<OGWordsResultItem*>(item);
|
||||
//logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Image,i+1);
|
||||
|
||||
|
||||
// SetCharacters(m_Result->Words);
|
||||
|
||||
// fontColor=QColor(0,0,0,255);
|
||||
// backgroundColor=QColor(255,255,255,255);
|
||||
// wordfont.setFamily("黑体");
|
||||
// wordfont.setPointSize(10);
|
||||
|
||||
//显示图片Image
|
||||
QString filename=QString::fromLocal8Bit(m_Result->Image);
|
||||
int pos=filename.lastIndexOf("\\");
|
||||
int pos1=filename.lastIndexOf("/");
|
||||
if(pos1>pos) pos=pos1;
|
||||
if(filename.lastIndexOf(".")>-1) {
|
||||
int aa=filename.lastIndexOf(".");
|
||||
if(aa<pos) {
|
||||
filename="";
|
||||
}
|
||||
}
|
||||
widget->addImageToPlot(-m_Result->EndDepth, -m_Result->StartDepth, filename );
|
||||
}
|
||||
logio->CloseTable(iIndex);
|
||||
delete buf;
|
||||
}
|
||||
delete logio;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//解释结论
|
||||
void FormDraw::initResult(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
|
||||
|
|
|
|||
|
|
@ -93,6 +93,10 @@ public:
|
|||
void initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||
void initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||
|
||||
//图像-3d成图
|
||||
int getColorConfig(QVector <QString> &qFiles);
|
||||
void DrawImageNew_NoFilter(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||
|
||||
//表格曲线
|
||||
void initTableLine(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
|
||||
void ReadFracDef();
|
||||
|
|
@ -104,7 +108,7 @@ public:
|
|||
void CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio);
|
||||
void Refurbish();
|
||||
void DrawJykt(QMyCustomPlot *widget, QString strSlfName);
|
||||
void DrawDenv(QMyCustomPlot *widget, QString strSlfName);
|
||||
void DrawDenv(QMyCustomPlot *widget, QString strSlfName);
|
||||
|
||||
int m_PointNum;
|
||||
//
|
||||
|
|
@ -174,11 +178,14 @@ public:
|
|||
|
||||
//岩心实验数据
|
||||
void initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
|
||||
|
||||
//岩心图片数据
|
||||
void initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
|
||||
bool LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
|
||||
//深度
|
||||
void initDepth(QMyCustomPlot *widget);
|
||||
//频率统计图
|
||||
void initFgrq(QMyCustomPlot *widget);
|
||||
|
||||
signals:
|
||||
//void sig_AddLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
|
||||
|
||||
|
|
@ -198,6 +205,8 @@ public slots:
|
|||
void s_addJykt(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);
|
||||
//井斜方位图
|
||||
void s_addDenv(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);
|
||||
//图像 成像
|
||||
void s_addDrawImage(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);
|
||||
|
||||
//
|
||||
void s_addWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,14 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName)
|
|||
connect(this, SIGNAL(sig_AddDenv(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
|
||||
this, SLOT(s_addDenv(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
|
||||
|
||||
//岩心图片
|
||||
connect(this, SIGNAL(sig_AddYanXinImage(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
|
||||
this, SLOT(s_addYanXinImage(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
|
||||
|
||||
//图像 成像
|
||||
connect(this, SIGNAL(sig_AddDrawImage(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
|
||||
this, SLOT(s_addDrawImage(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
|
||||
|
||||
//曲线选中,置顶
|
||||
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString)));
|
||||
|
||||
|
|
@ -124,6 +132,14 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam
|
|||
{
|
||||
emit sig_AddDenv(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
|
||||
}
|
||||
else if(strType=="yanxinImageObject")
|
||||
{
|
||||
emit sig_AddYanXinImage(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
|
||||
}
|
||||
else if(strType=="DrawImageObject")
|
||||
{
|
||||
emit sig_AddDrawImage(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
|
||||
}
|
||||
}
|
||||
|
||||
void FormTrack::setDrawDt(QStringList listdt, float vmax, float vmin)
|
||||
|
|
@ -454,6 +470,72 @@ void FormTrack::s_addDenv(QString strSlfName, QString strWellName, QString strTr
|
|||
ui->tableWidget->setCellWidget(row, 0, formInfo);
|
||||
}
|
||||
|
||||
void FormTrack::s_addYanXinImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType)
|
||||
{
|
||||
qDebug() << "FormTrack s_addYanXinImage";
|
||||
|
||||
ui->tableWidget->m_strUuid = m_strUuid;
|
||||
int row = ui->tableWidget->rowCount();
|
||||
ui->tableWidget->setRowCount(row + 1);
|
||||
|
||||
//避免出现小滚动条
|
||||
//ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10);
|
||||
//this->resize(g_iOneWidth, 100*(row + 1)+30);
|
||||
|
||||
//曲线信息栏
|
||||
FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor);
|
||||
formInfo->m_strUuid = m_strUuid;
|
||||
formInfo->m_strAliasName = strAliasName;
|
||||
formInfo->m_strUnit = strUnit;
|
||||
formInfo->m_strScaleType = strScaleType;
|
||||
formInfo->m_strType = "yanxinImageObject";
|
||||
formInfo->m_nJg = 2;
|
||||
formInfo->setLineWidth(dWidth);
|
||||
formInfo->setVMax(vmax);
|
||||
formInfo->setVMin(vmin);
|
||||
formInfo->setFrontColor(QColor(0,0,0));
|
||||
formInfo->setBackColor(QColor(255,255,255));
|
||||
//设置高度
|
||||
ui->tableWidget->setRowHeight(row, 100);
|
||||
//单元格委托
|
||||
//ui->tableWidget->setItemDelegateForRow(row, m_delegate);
|
||||
//
|
||||
ui->tableWidget->setCellWidget(row, 0, formInfo);
|
||||
}
|
||||
|
||||
void FormTrack::s_addDrawImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType)
|
||||
{
|
||||
qDebug() << "FormTrack s_addDrawImage";
|
||||
|
||||
ui->tableWidget->m_strUuid = m_strUuid;
|
||||
int row = ui->tableWidget->rowCount();
|
||||
ui->tableWidget->setRowCount(row + 1);
|
||||
|
||||
//避免出现小滚动条
|
||||
//ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10);
|
||||
//this->resize(g_iOneWidth, 100*(row + 1)+30);
|
||||
|
||||
//曲线信息栏
|
||||
FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor);
|
||||
formInfo->m_strUuid = m_strUuid;
|
||||
formInfo->m_strAliasName = strAliasName;
|
||||
formInfo->m_strUnit = strUnit;
|
||||
formInfo->m_strScaleType = strScaleType;
|
||||
formInfo->m_strType = "DrawImageObject";
|
||||
formInfo->m_nJg = 2;
|
||||
formInfo->setLineWidth(dWidth);
|
||||
formInfo->setVMax(vmax);
|
||||
formInfo->setVMin(vmin);
|
||||
formInfo->setFrontColor(QColor(0,0,0));
|
||||
formInfo->setBackColor(QColor(255,255,255));
|
||||
//设置高度
|
||||
ui->tableWidget->setRowHeight(row, 100);
|
||||
//单元格委托
|
||||
//ui->tableWidget->setItemDelegateForRow(row, m_delegate);
|
||||
//
|
||||
ui->tableWidget->setCellWidget(row, 0, formInfo);
|
||||
}
|
||||
|
||||
QJsonObject FormTrack::makeJson()
|
||||
{
|
||||
// 创建根对象
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ signals:
|
|||
void sig_AddGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void sig_AddJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void sig_AddDenv(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void sig_AddYanXinImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void sig_AddDrawImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
|
||||
|
||||
public slots:
|
||||
|
|
@ -86,6 +88,8 @@ public slots:
|
|||
void s_addGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void s_addJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void s_addDenv(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void s_addYanXinImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
void s_addDrawImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
|
||||
|
||||
void s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,11 @@ void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfNa
|
|||
//新建井斜方位图
|
||||
emit CallManage::getInstance()->sig_AddDenv(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||||
}
|
||||
else if(strType=="DrawImageObject")
|
||||
{
|
||||
//图像 成图
|
||||
emit CallManage::getInstance()->sig_AddDrawImage(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||||
}
|
||||
}
|
||||
|
||||
//ui->tableWidget->resizeColumnsToContents(); // 调整列宽以适应内容
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ SOURCES += \
|
|||
../common/geometryutils.cpp \
|
||||
ConsoleOutputWidget.cpp \
|
||||
GeoIndicatorGenerator.cpp \
|
||||
Gradient.cpp \
|
||||
InDefTableDlg.cpp \
|
||||
InterfaceWidget.cpp \
|
||||
PropertyWidget.cpp \
|
||||
|
|
@ -63,6 +64,7 @@ SOURCES += \
|
|||
qtcommonclass.cpp \
|
||||
qtprojectwidgets.cpp \
|
||||
totalTitleBar.cpp \
|
||||
transparentdraggableimage.cpp \
|
||||
variantfactory.cpp \
|
||||
variantmanager.cpp
|
||||
|
||||
|
|
@ -72,6 +74,7 @@ HEADERS += \
|
|||
ConsoleOutputWidget.h \
|
||||
DraggablePixmap.h \
|
||||
GeoIndicatorGenerator.h \
|
||||
Gradient.h \
|
||||
InDefTableDlg.h \
|
||||
InterfaceWidget.h \
|
||||
PropertyWidget.h \
|
||||
|
|
@ -103,6 +106,7 @@ HEADERS += \
|
|||
qtcommonclass.h \
|
||||
qtprojectwidgets.h \
|
||||
totalTitleBar.h \
|
||||
transparentdraggableimage.h \
|
||||
variantfactory.h \
|
||||
variantmanager.h
|
||||
|
||||
|
|
|
|||
|
|
@ -375,6 +375,7 @@ void MainWindowCurve::initToolBar()
|
|||
connect(m_ganzhuangtuAc, &QAction::triggered, this, &MainWindowCurve::s_NewGanZhuangTu);
|
||||
connect(m_collapseAc, &QAction::triggered, this, &MainWindowCurve::s_Jykt);
|
||||
connect(m_deviAc, &QAction::triggered, this, &MainWindowCurve::s_Denv);
|
||||
connect(m_electric_imagingAc, &QAction::triggered, this, &MainWindowCurve::s_DrawImage);
|
||||
}
|
||||
|
||||
void MainWindowCurve::loadStyle(const QString &qssFile)
|
||||
|
|
@ -942,6 +943,54 @@ void MainWindowCurve::s_Denv()
|
|||
emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "井斜方位图", "DenvObject", nW);
|
||||
}
|
||||
|
||||
//图像 成图
|
||||
void MainWindowCurve::s_DrawImage()
|
||||
{
|
||||
QString strSlfName = "";
|
||||
QString strLeft = m_leftWidgets->getLeftTreeString();
|
||||
if(strLeft.length() > 0)
|
||||
{
|
||||
QStringList list = strLeft.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 3)
|
||||
{
|
||||
strSlfName = list[0];
|
||||
}
|
||||
}
|
||||
|
||||
if(ui->tableWidget_2->columnCount()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int column = ui->tableWidget_2->currentColumn();//列编号从0开始
|
||||
if(column<0)
|
||||
{
|
||||
//当前没有选中井
|
||||
QMessageBox::warning(this, "提示", "当前没有选中井", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
if(column%2==0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
//空白列
|
||||
QMessageBox::warning(this, "提示", "当前没有选中井", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
QString strWellName = ui->tableWidget_2->item(0, column)->text();
|
||||
int iWidth = ui->tableWidget_2->columnWidth(column);
|
||||
|
||||
int nW = 320;
|
||||
//设置列宽
|
||||
ui->tableWidget_2->setColumnWidth(column, iWidth+nW+8);
|
||||
|
||||
//新建道
|
||||
emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "成像", "DrawImageObject", nW);
|
||||
}
|
||||
|
||||
void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName)
|
||||
{
|
||||
qDebug() << "MainWindowCurve s_NewTrackChangeWidth";
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ public slots:
|
|||
void s_NewGanZhuangTu(); // 杆状图
|
||||
void s_Jykt(); // 井眼垮塌矢量图
|
||||
void s_Denv(); // 井斜方位图
|
||||
void s_DrawImage(); // 图像 成图
|
||||
|
||||
//
|
||||
void s_Save();//保存
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "TransparentDraggableGeoLith.h"
|
||||
#include "TransparentDraggableSwallCore.h"
|
||||
#include "TransparentDraggableGujing.h"
|
||||
#include "transparentdraggableimage.h"
|
||||
#include "qtcommonclass.h"
|
||||
|
||||
//是否隐藏刻度
|
||||
|
|
@ -354,15 +355,19 @@ void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QS
|
|||
QString strUuid = qtCommon->getUUid();
|
||||
|
||||
// 在初始化代码中
|
||||
TransparentDraggableRect *dragRect = new TransparentDraggableRect(this, strUuid);
|
||||
TransparentDraggableImage *dragRect = new TransparentDraggableImage(this, strUuid);
|
||||
//图片,提前设值,后面setRange改变
|
||||
dragRect->setResult(imagePath);
|
||||
// 设置初始范围
|
||||
dragRect->setRange(left_Low, right_Hight);
|
||||
// 可选:设置颜色
|
||||
dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色
|
||||
//最小宽度
|
||||
dragRect->setMinWidth(0.1);
|
||||
//dragRect->setTitle(strText);
|
||||
|
||||
m_mapDraggable_Image[strUuid] = dragRect;
|
||||
|
||||
m_mapDraggableRect[strUuid] = dragRect;
|
||||
}
|
||||
|
||||
void QMyCustomPlot::addTextToPlot(double left_Low, double right_Hight, const QString strText)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public:
|
|||
QMap<QString, QObject*> m_mapDraggable_GeoLith;
|
||||
QMap<QString, QObject*> m_mapDraggable_SwallCore;
|
||||
QMap<QString, QObject*> m_mapDraggable_Gujing;
|
||||
QMap<QString, QObject*> m_mapDraggable_Image;
|
||||
|
||||
public slots:
|
||||
void slot_time();
|
||||
|
|
|
|||
562
logPlus/transparentdraggableimage.cpp
Normal file
562
logPlus/transparentdraggableimage.cpp
Normal file
|
|
@ -0,0 +1,562 @@
|
|||
#include "transparentdraggableimage.h"
|
||||
|
||||
|
||||
extern double g_dPixelPerCm;//每厘米像素数
|
||||
//static GeoIndicatorGenerator m_drawGeo;
|
||||
|
||||
TransparentDraggableImage::TransparentDraggableImage(QMyCustomPlot *parentPlot, QString strUuid, double minWidth, QString strTitle)
|
||||
: QObject(parentPlot), mPlot(parentPlot), mstrTitle(strTitle), mMinWidth(minWidth)
|
||||
{
|
||||
m_strUuid = strUuid;
|
||||
//
|
||||
initRect();
|
||||
}
|
||||
|
||||
TransparentDraggableImage::~TransparentDraggableImage()
|
||||
{
|
||||
if(mPlot) {
|
||||
// mPlot->removeItem(mRect);
|
||||
// mPlot->removeItem(mLeftHandle);
|
||||
// mPlot->removeItem(mRightHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TransparentDraggableImage::DrawSVGNormal(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout)
|
||||
{
|
||||
QString svg=svgFileName;
|
||||
QRectF boundingRect = painter->transform().mapRect(borderRect);
|
||||
painter->save();
|
||||
QTransform transform;
|
||||
transform.reset();
|
||||
if (!IsWellSectonHorizonLayout)
|
||||
{
|
||||
painter->setWorldTransform(transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
QPixmap tiledmap(svg);
|
||||
QRect border(boundingRect.left(),boundingRect.top(),boundingRect.width(),boundingRect.height());
|
||||
painter->drawPixmap(border,tiledmap);
|
||||
painter->restore();
|
||||
}
|
||||
//拉伸
|
||||
void TransparentDraggableImage::DrawSVGSteched(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout)
|
||||
{
|
||||
QString svg=svgFileName;
|
||||
QSvgRenderer m_SvgRenderer;
|
||||
m_SvgRenderer.load(svg);
|
||||
m_SvgRenderer.render(painter,borderRect);
|
||||
}
|
||||
//平铺
|
||||
void TransparentDraggableImage::DrawSVGTiled(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout)
|
||||
{
|
||||
QString svg=svgFileName;
|
||||
QRectF boundingRect = painter->transform().mapRect(borderRect);
|
||||
painter->save();
|
||||
QTransform transform;
|
||||
transform.reset();
|
||||
if (!IsWellSectonHorizonLayout)
|
||||
{
|
||||
painter->setWorldTransform(transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
QPixmap tiledmap(svg);
|
||||
painter->drawTiledPixmap(boundingRect,tiledmap);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//设置最小宽度
|
||||
void TransparentDraggableImage::setMinWidth(double minWidth)
|
||||
{
|
||||
mMinWidth = minWidth;
|
||||
}
|
||||
|
||||
//设置标题
|
||||
void TransparentDraggableImage::setTitle(QString strTitle)
|
||||
{
|
||||
mstrTitle = strTitle;
|
||||
mItemTitle->setText(mstrTitle);
|
||||
mPlot->replot();
|
||||
}
|
||||
|
||||
//设置解释结论
|
||||
void TransparentDraggableImage::setResult(QString filePath)
|
||||
{
|
||||
m_Result = filePath;
|
||||
}
|
||||
|
||||
void TransparentDraggableImage::drawResult(double left_Low, double right_Hight, double lY1, double lY2)
|
||||
{
|
||||
if(m_Result=="")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double x1 = mPlot->xAxis->coordToPixel(left_Low);
|
||||
double x2 = mPlot->xAxis->coordToPixel(right_Hight);
|
||||
double y1 = mPlot->yAxis->coordToPixel(lY1);
|
||||
double y2 = mPlot->yAxis->coordToPixel(lY2);
|
||||
|
||||
//
|
||||
QString filePath = m_Result;
|
||||
//
|
||||
QString strLast = filePath.right(4);
|
||||
if(strLast.toLower()==".svg")
|
||||
{
|
||||
QString path,filename;
|
||||
GetWellNameAndPath(filePath, filename, path);
|
||||
QString basename = filename;
|
||||
|
||||
QString val=filePath;
|
||||
QImage image(y2-y1, x1-x2,QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
QRectF fillRect(0,0, y2-y1, x1-x2);
|
||||
painter.fillRect(fillRect,Qt::white);
|
||||
//拉伸
|
||||
DrawSVGSteched(&painter,filePath,fillRect,0);
|
||||
//平铺
|
||||
//DrawSVGTiled(&painter,filePath,fillRect,0);
|
||||
//正常
|
||||
//DrawSVGNormal(&painter,filePath,fillRect,0);
|
||||
|
||||
val=GetImagePath()+"TempNew";
|
||||
QDir ss;
|
||||
if(!ss.exists(val)) {
|
||||
ss.mkdir(val);
|
||||
}
|
||||
val+=QDir::separator();
|
||||
val+=basename+".png";
|
||||
image.save(val);
|
||||
|
||||
//
|
||||
mPixmap->setPixmap(QPixmap(val)); // 设置图片
|
||||
}
|
||||
else
|
||||
{
|
||||
mPixmap->setPixmap(QPixmap(filePath)); // 设置图片
|
||||
|
||||
// QString path,filename;
|
||||
// GetWellNameAndPath(filePath, filename, path);
|
||||
// QString basename = filename;
|
||||
|
||||
// QString val=filePath;
|
||||
// QImage image(y2-y1, x1-x2,QImage::Format_RGB32);
|
||||
// QPainter painter(&image);
|
||||
// QRectF fillRect(0,0, y2-y1, x1-x2);
|
||||
// painter.fillRect(fillRect,Qt::white);
|
||||
// //平铺
|
||||
// DrawSVGNormal(&painter,filePath,fillRect,0);
|
||||
|
||||
// val=GetImagePath()+"TempNew";
|
||||
// QDir ss;
|
||||
// if(!ss.exists(val)) {
|
||||
// ss.mkdir(val);
|
||||
// }
|
||||
// val+=QDir::separator();
|
||||
// val+=basename+".png";
|
||||
// image.save(val);
|
||||
|
||||
// //
|
||||
// mPixmap->setPixmap(QPixmap(val)); // 设置图片
|
||||
}
|
||||
|
||||
mPlot->replot();
|
||||
}
|
||||
|
||||
// 设置矩形范围
|
||||
void TransparentDraggableImage::setRange(double left_Low, double right_Hight)
|
||||
{
|
||||
if(left_Low >= right_Hight) return;
|
||||
|
||||
double lY1 = mPlot->yAxis->range().lower;//+10
|
||||
double lY2 = mPlot->yAxis->range().upper;
|
||||
mRect->topLeft->setCoords(left_Low, lY1);
|
||||
mRect->bottomRight->setCoords(right_Hight, lY2);
|
||||
|
||||
//位置与rect不一样,否则图像反转
|
||||
mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||
mPixmap->bottomRight->setCoords(left_Low, lY2);
|
||||
drawResult(left_Low, right_Hight, lY1, lY2);
|
||||
|
||||
//mItemTitle->position->setCoords(0.5, 0.5);
|
||||
// 设置父锚点,定位点
|
||||
//mItemTitle->position->setParentAnchor(mRect->bottom);
|
||||
mItemTitle->position->setCoords((mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2,
|
||||
(mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置
|
||||
|
||||
//mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper);
|
||||
//mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower);
|
||||
|
||||
updateHandles();
|
||||
mPlot->replot();
|
||||
}
|
||||
|
||||
// 获取当前范围
|
||||
QCPRange TransparentDraggableImage::getRange()
|
||||
{
|
||||
return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x());
|
||||
}
|
||||
|
||||
// 设置矩形颜色
|
||||
void TransparentDraggableImage::setColor(const QColor &color)
|
||||
{
|
||||
mRect->setBrush(QBrush(color));
|
||||
mRect->setPen(QPen(color.darker()));
|
||||
mPlot->replot();
|
||||
}
|
||||
|
||||
// 删除框图
|
||||
void TransparentDraggableImage::deleteRect()
|
||||
{
|
||||
if(mPlot) {
|
||||
|
||||
// mRect->deleteLater();
|
||||
// mLeftHandle->deleteLater();
|
||||
// mRightHandle->deleteLater();
|
||||
// mPixmap->deleteLater();
|
||||
|
||||
mPlot->m_mapDraggable_Image.remove(m_strUuid);
|
||||
|
||||
mPlot->removeItem(mRect);
|
||||
mPlot->removeItem(mLeftHandle);
|
||||
mPlot->removeItem(mRightHandle);
|
||||
mPlot->removeItem(mPixmap);
|
||||
mPlot->removeItem(mItemTitle);
|
||||
|
||||
mPlot->replot();
|
||||
this->deleteLater();
|
||||
|
||||
//
|
||||
// //避免二次绘制框图
|
||||
// mPlot->m_bDrawRect = false;
|
||||
// mDragMode = DragNone;
|
||||
// //取消选中框
|
||||
// mPlot->selectionRect()->cancel();
|
||||
// mPlot->replot();
|
||||
// mPlot->selectionRect()->mActive=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TransparentDraggableImage::initRect()
|
||||
{
|
||||
// 创建透明矩形
|
||||
mRect = new QCPItemRect(mPlot);
|
||||
mRect->setLayer("overlay"); // 确保在最上层
|
||||
mRect->setBrush(QBrush(QColor(255, 255, 255, 50))); // 半透明蓝色
|
||||
mRect->setPen(QPen(QColor(70, 70, 255, 200)));
|
||||
|
||||
// 创建左右边界控制点
|
||||
mLeftHandle = new QCPItemRect(mPlot);
|
||||
mLeftHandle->setLayer("overlay");
|
||||
mLeftHandle->setBrush(QBrush(Qt::red));
|
||||
mLeftHandle->setPen(QPen(Qt::darkRed));
|
||||
|
||||
mRightHandle = new QCPItemRect(mPlot);
|
||||
mRightHandle->setLayer("overlay");
|
||||
mRightHandle->setBrush(QBrush(Qt::red));
|
||||
mRightHandle->setPen(QPen(Qt::darkRed));
|
||||
|
||||
// 设置初始位置
|
||||
//double center = mPlot->xAxis->range().center();
|
||||
// setRange(center - 10, center + 10);
|
||||
|
||||
// 连接鼠标事件
|
||||
connect(mPlot, &QCustomPlot::mousePress, this, &TransparentDraggableImage::onMousePress);
|
||||
connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableImage::onMouseMove);
|
||||
connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableImage::onMouseRelease);
|
||||
|
||||
mPixmap = new QCPItemPixmap(mPlot);
|
||||
//mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片
|
||||
mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式
|
||||
mPixmap->setLayer("overlay"); // 确保在最上层
|
||||
|
||||
mItemTitle = new QCPItemText(mPlot);
|
||||
mItemTitle->setText(mstrTitle);
|
||||
//mItemTitle->setBrush(QBrush(Qt::red));
|
||||
mItemTitle->setFont(QFont("Arial", 12, QFont::Bold));
|
||||
mItemTitle->setColor(Qt::black);
|
||||
mItemTitle->setPositionAlignment(Qt::AlignTop | Qt::AlignHCenter);
|
||||
mItemTitle->position->setType(QCPItemPosition::ptPlotCoords);
|
||||
//mItemTitle->position->setType(QCPItemPosition::ptAxisRectRatio);
|
||||
mItemTitle->position->setCoords(0.5, 0);
|
||||
mItemTitle->setLayer("overlay");
|
||||
}
|
||||
|
||||
void TransparentDraggableImage::updateHandles()
|
||||
{
|
||||
// 左边界矩形控制点
|
||||
mLeftHandle->topLeft->setParentAnchor(mRect->topLeft);
|
||||
mLeftHandle->bottomRight->setParentAnchor(mRect->topRight);//(mRect->bottomLeft);
|
||||
mLeftHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
||||
mLeftHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
||||
|
||||
// 右边界矩形控制点
|
||||
mRightHandle->topLeft->setParentAnchor(mRect->bottomLeft);
|
||||
mRightHandle->bottomRight->setParentAnchor(mRect->bottomRight);
|
||||
mRightHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小
|
||||
mRightHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小
|
||||
|
||||
}
|
||||
|
||||
void TransparentDraggableImage::onDelRect()
|
||||
{
|
||||
//mDragMode = DragNone;
|
||||
//删除框图
|
||||
deleteRect();
|
||||
}
|
||||
|
||||
|
||||
void TransparentDraggableImage::onMousePress(QMouseEvent *event)
|
||||
{
|
||||
if(event->button() != Qt::LeftButton)//右键
|
||||
{
|
||||
double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度
|
||||
QCPRange currentRange = getRange();
|
||||
if(mLeftHandle->selectTest(event->pos(), false) < 5) {
|
||||
mDragMode = DragNone;
|
||||
}
|
||||
else if(mRightHandle->selectTest(event->pos(), false) < 5) {
|
||||
mDragMode = DragNone;
|
||||
}
|
||||
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
||||
else if(y >= currentRange.lower && y <= currentRange.upper) {
|
||||
mDragMode = DragNone;
|
||||
}
|
||||
else {
|
||||
mDragMode = DragNone;
|
||||
return;
|
||||
}
|
||||
|
||||
//event->accept();
|
||||
|
||||
QMenu menu(nullptr);
|
||||
QAction *delAction = menu.addAction("删除框图");
|
||||
//delAction->installEventFilter(this);
|
||||
connect(delAction, &QAction::triggered, this, &TransparentDraggableImage::onDelRect);
|
||||
|
||||
// QAction* pItem = menu.exec(event->globalPos());
|
||||
// if(pItem == delAction)
|
||||
// {
|
||||
// //event->accept();
|
||||
|
||||
// int ii=0;
|
||||
// ii++;
|
||||
// }
|
||||
menu.exec(event->globalPos());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
|
||||
// 检查点击了哪个部分
|
||||
//double x = mPlot->xAxis->pixelToCoord(event->pos().x());
|
||||
//double y = mPlot->yAxis->pixelToCoord(event->pos().y());
|
||||
|
||||
double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度
|
||||
|
||||
QCPRange currentRange = getRange();
|
||||
|
||||
if(mLeftHandle->selectTest(event->pos(), false) < 5) {
|
||||
mDragMode = DragLeft;
|
||||
}
|
||||
else if(mRightHandle->selectTest(event->pos(), false) < 5) {
|
||||
mDragMode = DragRight;
|
||||
}
|
||||
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
||||
else if(y >= currentRange.lower && y <= currentRange.upper) {
|
||||
mDragMode = DragRect;
|
||||
}
|
||||
else {
|
||||
mDragMode = DragNone;
|
||||
return;
|
||||
}
|
||||
|
||||
//mDragStartX = x;
|
||||
mDragStartY = y;
|
||||
mDragStartRange = currentRange;
|
||||
|
||||
}
|
||||
|
||||
void TransparentDraggableImage::onMouseMove(QMouseEvent *event)
|
||||
{
|
||||
if(mDragMode == DragNone) return;
|
||||
|
||||
event->accept();
|
||||
|
||||
//double x = mPlot->xAxis->pixelToCoord(event->pos().x());
|
||||
//double dx = x - mDragStartX;
|
||||
|
||||
double y = mPlot->xAxis->pixelToCoord(event->pos().y());
|
||||
double dy = y - mDragStartY;
|
||||
|
||||
QCPRange newRange = mDragStartRange;
|
||||
|
||||
switch(mDragMode) {
|
||||
case DragLeft: {
|
||||
//double proposedLeft = mDragStartRange.lower + dx;
|
||||
double proposedLeft = mDragStartRange.lower + dy;
|
||||
// 确保不超出轴范围且不使宽度小于最小值
|
||||
newRange.lower = qBound(
|
||||
//mPlot->xAxis->range().lower,
|
||||
getMyLower(),
|
||||
proposedLeft,
|
||||
mDragStartRange.upper - mMinWidth);
|
||||
break;
|
||||
}
|
||||
case DragRight: {
|
||||
//double proposedRight = mDragStartRange.upper + dx;
|
||||
double proposedRight = mDragStartRange.upper + dy;
|
||||
// 确保不超出轴范围且不使宽度小于最小值
|
||||
newRange.upper = qBound(
|
||||
mDragStartRange.lower + mMinWidth,
|
||||
proposedRight,
|
||||
getMyUpper());
|
||||
//mPlot->xAxis->range().upper);
|
||||
break;
|
||||
}
|
||||
case DragRect: {
|
||||
double width = mDragStartRange.size();
|
||||
//double center = mDragStartRange.center() + dx;
|
||||
double center = mDragStartRange.center() + dy;
|
||||
newRange.lower = center - width/2;
|
||||
newRange.upper = center + width/2;
|
||||
|
||||
// 检查是否超出轴范围
|
||||
if(newRange.lower < getMyLower()) {
|
||||
newRange.lower = getMyLower();
|
||||
newRange.upper = newRange.lower + width;
|
||||
}
|
||||
else if(newRange.upper > getMyUpper()) {
|
||||
newRange.upper = getMyUpper();
|
||||
newRange.lower = newRange.upper - width;
|
||||
}
|
||||
|
||||
// QCPRange axisRange = mPlot->xAxis->range();
|
||||
// if(newRange.lower < axisRange.lower) {
|
||||
// newRange.lower = axisRange.lower;
|
||||
// newRange.upper = newRange.lower + width;
|
||||
// }
|
||||
// else if(newRange.upper > axisRange.upper) {
|
||||
// newRange.upper = axisRange.upper;
|
||||
// newRange.lower = newRange.upper - width;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// //取整数(方便显示统计,左右边界整数显示。)
|
||||
// newRange.lower = (int)newRange.lower;
|
||||
// QCPRange rangeByFile = mPlot->xAxis->range();
|
||||
// if (std::fabs(rangeByFile.upper - (int)newRange.upper) >= 1.0)
|
||||
// {
|
||||
// newRange.upper = (int)newRange.upper;
|
||||
// }
|
||||
|
||||
// 最终确保宽度不小于最小值(针对整体拖动的情况)
|
||||
if(newRange.size() < mMinWidth) {
|
||||
if(mDragMode == DragRect) {
|
||||
// 如果是整体拖动,保持中心点不变
|
||||
double center = newRange.center();
|
||||
newRange.lower = center - mMinWidth/2;
|
||||
newRange.upper = center + mMinWidth/2;
|
||||
} else {
|
||||
// 如果是边界拖动,强制设置最小宽度
|
||||
if(mDragMode == DragLeft) {
|
||||
newRange.lower = newRange.upper - mMinWidth;
|
||||
} else if(mDragMode == DragRight) {
|
||||
newRange.upper = newRange.lower + mMinWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setRange(newRange.lower, newRange.upper);
|
||||
|
||||
}
|
||||
|
||||
void TransparentDraggableImage::onMouseRelease(QMouseEvent *event)
|
||||
{
|
||||
if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
|
||||
event->accept();
|
||||
//避免二次绘制框图
|
||||
mPlot->m_bDrawRect = false;
|
||||
//emit rangeChanged(getRange());
|
||||
mDragMode = DragNone;
|
||||
//取消选中状态
|
||||
// QCPDataSelection emptySelection;
|
||||
// mPlot->graph(0)->setSelection(emptySelection);
|
||||
// mPlot->replot();
|
||||
|
||||
//取消选中框
|
||||
mPlot->selectionRect()->cancel();
|
||||
mPlot->replot();
|
||||
mPlot->selectionRect()->mActive=true;
|
||||
}
|
||||
}
|
||||
|
||||
double TransparentDraggableImage::getMyLower()
|
||||
{
|
||||
double dLower = mPlot->xAxis->range().lower;
|
||||
double proposedLeft = mDragStartRange.lower;
|
||||
|
||||
TransparentDraggableImage *pDraggableRect =NULL;
|
||||
{
|
||||
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggable_Image.begin();
|
||||
while( it != mPlot->m_mapDraggable_Image.end() )
|
||||
{
|
||||
if(it.key() == m_strUuid)
|
||||
{
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
pDraggableRect = (TransparentDraggableImage*)it.value();
|
||||
//
|
||||
QCPRange tmpRange = pDraggableRect->getRange();
|
||||
if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
||||
{
|
||||
dLower = tmpRange.upper;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
return dLower;
|
||||
}
|
||||
|
||||
double TransparentDraggableImage::getMyUpper()
|
||||
{
|
||||
double dUpper = mPlot->xAxis->range().upper;
|
||||
double proposedRight = mDragStartRange.upper;
|
||||
|
||||
TransparentDraggableImage *pDraggableRect =NULL;
|
||||
{
|
||||
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggable_Image.begin();
|
||||
while( it != mPlot->m_mapDraggable_Image.end() )
|
||||
{
|
||||
if(it.key() == m_strUuid)
|
||||
{
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
pDraggableRect = (TransparentDraggableImage*)it.value();
|
||||
//
|
||||
QCPRange tmpRange = pDraggableRect->getRange();
|
||||
if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
||||
{
|
||||
dUpper = tmpRange.lower;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
return dUpper;
|
||||
}
|
||||
85
logPlus/transparentdraggableimage.h
Normal file
85
logPlus/transparentdraggableimage.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#ifndef TRANSPARENTDRAGGABLEIMAGE_H
|
||||
#define TRANSPARENTDRAGGABLEIMAGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qmycustomplot.h"
|
||||
#include <QString>
|
||||
#include <QMenu>
|
||||
#include "geometryutils.h"
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
|
||||
|
||||
class TransparentDraggableImage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TransparentDraggableImage(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = "");
|
||||
|
||||
|
||||
~TransparentDraggableImage();
|
||||
|
||||
|
||||
void DrawSVGNormal(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout);
|
||||
//拉伸
|
||||
void DrawSVGSteched(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout);
|
||||
//平铺
|
||||
void DrawSVGTiled(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout);
|
||||
//设置最小宽度
|
||||
void setMinWidth(double minWidth);
|
||||
//设置标题
|
||||
void setTitle(QString strTitle);
|
||||
|
||||
//设置解释结论
|
||||
void setResult(QString filePath);
|
||||
void drawResult(double left_Low, double right_Hight, double lY1, double lY2);
|
||||
|
||||
// 设置矩形范围
|
||||
void setRange(double left_Low, double right_Hight);
|
||||
// 获取当前范围
|
||||
QCPRange getRange();
|
||||
|
||||
// 设置矩形颜色
|
||||
void setColor(const QColor &color);
|
||||
|
||||
// 删除框图
|
||||
void deleteRect();
|
||||
|
||||
signals:
|
||||
void rangeChanged(QCPRange newRange);
|
||||
|
||||
private:
|
||||
void initRect();
|
||||
void updateHandles() ;
|
||||
|
||||
private slots:
|
||||
void onDelRect();
|
||||
void onMousePress(QMouseEvent *event);
|
||||
void onMouseMove(QMouseEvent *event);
|
||||
void onMouseRelease(QMouseEvent *event);
|
||||
double getMyLower();
|
||||
double getMyUpper();
|
||||
|
||||
private:
|
||||
QMyCustomPlot *mPlot;
|
||||
QCPItemRect *mRect;
|
||||
QCPItemRect *mLeftHandle;
|
||||
QCPItemRect *mRightHandle;
|
||||
|
||||
QCPItemPixmap *mPixmap;
|
||||
QCPItemText *mItemTitle;
|
||||
QString mstrTitle="";
|
||||
QString m_strUuid = "";
|
||||
QString m_Result;
|
||||
|
||||
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
||||
DragMode mDragMode = DragNone;
|
||||
//double mDragStartX = 0;
|
||||
double mDragStartY = 0;
|
||||
QCPRange mDragStartRange;
|
||||
|
||||
// 添加最小宽度成员变量
|
||||
double mMinWidth;
|
||||
};
|
||||
|
||||
#endif // TRANSPARENTDRAGGABLEIMAGE_H
|
||||
Loading…
Reference in New Issue
Block a user