Commit 7af7d661 authored by Jan Kremer's avatar Jan Kremer
Browse files

Cleanup. 2D diagrams now reduce brightness of brushed particles instead of...

Cleanup. 2D diagrams now reduce brightness of brushed particles instead of coloring them black. Added VR pawn to the repo instead of desktop pawn.
parent 0981d341
No preview for this file type
No preview for this file type
This diff is collapsed.
......@@ -50,12 +50,4 @@ bHQBuffer=False
bHQDistortion=False
bUpdateOnRT=True
[WindowsApplication.Accessibility]
StickyKeysHotkey=True
ToggleKeysHotkey=True
FilterKeysHotkey=True
StickyKeysConfirmation=True
ToggleKeysConfirmation=True
FilterKeysConfirmation=True
......@@ -6,7 +6,7 @@
#include "Components/ActorComponent.h"
#include "H5Cpp.h"
#include "Runtime/Engine/Classes/Curves/CurveVector.h"
#include "MyObject.h"
#include "SharedEnums.h"
#include "DataComponent.generated.h"
using namespace H5;
......
......@@ -7,7 +7,7 @@
#include "PointCloud.h"
#include "PointCloudActor.h"
#include "Runtime/Engine/Classes/Curves/CurveVector.h"
#include "MyObject.h"
#include "SharedEnums.h"
#include "Plot3D.generated.h"
UCLASS()
......
......@@ -106,57 +106,29 @@ void UPlotCanvas::SetYAxisType(EAxisType Type)
}
void UPlotCanvas::InitializeCanvas(const int32 pixelsH, const int32 pixelsV)
{
//dynamic texture initialization
canvasWidth = pixelsH;
canvasHeight = pixelsV;
CanvasWidth = pixelsH;
CanvasHeight = pixelsV;
dynamicCanvas = UTexture2D::CreateTransient(canvasWidth, canvasHeight);
DynamicCanvas = UTexture2D::CreateTransient(CanvasWidth, CanvasHeight);
#if WITH_EDITORONLY_DATA
dynamicCanvas->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
DynamicCanvas->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
#endif
dynamicCanvas->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
dynamicCanvas->SRGB = 1;
dynamicCanvas->AddToRoot();
dynamicCanvas->Filter = TextureFilter::TF_Nearest;
dynamicCanvas->UpdateResource();
DynamicCanvas->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
DynamicCanvas->SRGB = 1;
DynamicCanvas->AddToRoot();
DynamicCanvas->Filter = TextureFilter::TF_Nearest;
DynamicCanvas->UpdateResource();
echoUpdateTextureRegion = std::unique_ptr<FUpdateTextureRegion2D>(new FUpdateTextureRegion2D(0, 0, 0, 0, canvasWidth, canvasHeight));
EchoUpdateTextureRegion = std::unique_ptr<FUpdateTextureRegion2D>(new FUpdateTextureRegion2D(0, 0, 0, 0, CanvasWidth, CanvasHeight));
// buffers initialization
bytesPerPixel = 4; // r g b a
bufferPitch = canvasWidth * bytesPerPixel;
bufferSize = canvasWidth * canvasHeight * bytesPerPixel;
canvasPixelData = std::unique_ptr<uint8[]>(new uint8[bufferSize]);
BytesPerPixel = 4;
BufferPitch = CanvasWidth * BytesPerPixel;
BufferSize = CanvasWidth * CanvasHeight * BytesPerPixel;
CanvasPixelData = std::unique_ptr<uint8[]>(new uint8[BufferSize]);
ClearCanvas();
}
void UPlotCanvas::InitializeDrawingTools(const int32 brushRadius, uint8 r, uint8 g, uint8 b)
{
radius = brushRadius;
brushBufferSize = radius * radius * 4 * bytesPerPixel; //2r*2r * bpp
canvasBrushMask = std::unique_ptr<uint8[]>(new uint8[brushBufferSize]);
uint8* canvasBrushPixelPtr = canvasBrushMask.get();
for (int px = -radius; px < radius; ++px)
{
for (int py = -radius; py < radius; ++py)
{
int32 tx = px + radius;
int32 ty = py + radius;
canvasBrushPixelPtr = canvasBrushMask.get() + (tx + +ty * 2 * radius) * bytesPerPixel;
if (px*px + py * py < radius*radius)
{
setPixelColor(canvasBrushPixelPtr, r,g,b, 255); //black alpha 255 - bgra
}
else
{
setPixelColor(canvasBrushPixelPtr, 0, 0, 0, 0); // alpha 0
}
}
}
}
void UPlotCanvas::DrawScatterPlot()
{
ClearCanvas();
......@@ -166,15 +138,20 @@ void UPlotCanvas::DrawScatterPlot()
for (int i = 0; i < PawnBase->Plot3D->Points.Num(); ++i)
{
int32 x = ((*XArray)[i] - XMin) / (XMax - XMin) * CanvasWidth;
int32 y = ((*YArray)[i] - YMin) / (YMax - YMin) * CanvasHeight;
uint8 r = PawnBase->Plot3D->Points[i].Color.R;
uint8 g = PawnBase->Plot3D->Points[i].Color.G;
uint8 b = PawnBase->Plot3D->Points[i].Color.B;
if (PawnBase->Data->IsBrushed[i])
{
InitializeDrawingTools(1, 0, 0, 0);
DrawPixel(x, y, r/3, g/3, b/3, 255);
}
else
{
InitializeDrawingTools(1, PawnBase->Plot3D->Points[i].Color.R, PawnBase->Plot3D->Points[i].Color.G, PawnBase->Plot3D->Points[i].Color.B);
DrawPixel(x, y, r, g, b, 255);
}
DrawDot(((*XArray)[i] - XMin) / (XMax - XMin) * canvasWidth, ((*YArray)[i] - YMin) / (YMax - YMin) * canvasHeight);
}
UpdateCanvas();
......@@ -188,7 +165,7 @@ void UPlotCanvas::DrawHistogramPlot(int32 bins)
APawnBase* PawnBase = Cast<APawnBase>(Pawn);
float Diff = XMax - XMin;
float Thickness = canvasWidth / (float)bins;
float Thickness = CanvasWidth / (float)bins;
TArray<int32> XCount = TArray<int32>();
TArray<int32> XBrushedCount = TArray<int32>();
......@@ -223,12 +200,12 @@ void UPlotCanvas::DrawHistogramPlot(int32 bins)
int32 x1 = x0 + Thickness;
int32 y0 = 0;
int32 y1 = XCount[i] / (float)MaxCount * canvasHeight;
int32 y1 = XCount[i] / (float)MaxCount * CanvasHeight;
FVector ColorVec;
if (XBrushedCount[i] == XCount[i])
{
ColorVec = FVector(0, 0, 0);
ColorVec = PawnBase->Data->TransferFunction->GetVectorValue((i + 0.5) / (float)bins) / 3;
}
else
{
......@@ -266,17 +243,17 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
for (int i = 0; i < PawnBase->Plot3D->Points.Num(); ++i)
{
int32 x0 = 0;
int32 x1 = canvasWidth * 1 / 5;
int32 x2 = canvasWidth * 2 / 5;
int32 x3 = canvasWidth * 3 / 5;
int32 x4 = canvasWidth * 4 / 5;
int32 x5 = canvasWidth;
int32 x1 = CanvasWidth * 1 / 5;
int32 x2 = CanvasWidth * 2 / 5;
int32 x3 = CanvasWidth * 3 / 5;
int32 x4 = CanvasWidth * 4 / 5;
int32 x5 = CanvasWidth;
int32 y0;
float Diff = (PawnBase->Data->MaxX - PawnBase->Data->MinX);
if (Diff != 0)
{
y0 = (PawnBase->Data->X[i] - PawnBase->Data->MinX) / Diff * canvasHeight / 4;
y0 = (PawnBase->Data->X[i] - PawnBase->Data->MinX) / Diff * CanvasHeight / 4;
}
else
{
......@@ -287,7 +264,7 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
Diff = (PawnBase->Data->MaxY - PawnBase->Data->MinY);
if (Diff != 0)
{
y1 = (PawnBase->Data->Y[i] - PawnBase->Data->MinY) / Diff * canvasHeight / 4;
y1 = (PawnBase->Data->Y[i] - PawnBase->Data->MinY) / Diff * CanvasHeight / 4;
}
else
{
......@@ -298,7 +275,7 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
Diff = (PawnBase->Data->MaxZ - PawnBase->Data->MinZ);
if (Diff != 0)
{
y2 = (PawnBase->Data->Z[i] - PawnBase->Data->MinZ) / Diff * canvasHeight / 4;
y2 = (PawnBase->Data->Z[i] - PawnBase->Data->MinZ) / Diff * CanvasHeight / 4;
}
else
{
......@@ -309,7 +286,7 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
Diff = (PawnBase->Data->MaxU - PawnBase->Data->MinU);
if (Diff != 0)
{
y3 = (PawnBase->Data->U[i] - PawnBase->Data->MinU) / Diff * canvasHeight / 4;
y3 = (PawnBase->Data->U[i] - PawnBase->Data->MinU) / Diff * CanvasHeight / 4;
}
else
{
......@@ -320,7 +297,7 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
Diff = (PawnBase->Data->MaxV - PawnBase->Data->MinV);
if (Diff != 0)
{
y4 = (PawnBase->Data->V[i] - PawnBase->Data->MinV) / Diff * canvasHeight / 4;
y4 = (PawnBase->Data->V[i] - PawnBase->Data->MinV) / Diff * CanvasHeight / 4;
}
else
{
......@@ -331,7 +308,7 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
Diff = (PawnBase->Data->MaxW - PawnBase->Data->MinW);
if (Diff != 0)
{
y5 = (PawnBase->Data->W[i] - PawnBase->Data->MinW) / Diff * canvasHeight / 4;
y5 = (PawnBase->Data->W[i] - PawnBase->Data->MinW) / Diff * CanvasHeight / 4;
}
else
{
......@@ -362,57 +339,35 @@ void UPlotCanvas::DrawParallelCoordinatesPlot()
UpdateCanvas();
}
void UPlotCanvas::DrawDot(const int32 pixelCoordX, const int32 pixelCoordY)
{
uint8* canvasPixelPtr = canvasPixelData.get();
const uint8* canvasBrushPixelPtr = canvasBrushMask.get();
for (int px = -radius; px < radius; ++px)
{
for (int py = -radius; py < radius; ++py)
{
int32 tbx = px + radius;
int32 tby = py + radius;
canvasBrushPixelPtr = canvasBrushMask.get() + (tbx + tby * 2 * radius) * bytesPerPixel;
if (*(canvasBrushPixelPtr + 3) == 255) // check the alpha value of the pixel of the brush mask
{
int32 tx = pixelCoordX + px;
int32 ty = pixelCoordY + py;
DrawPixel(tx, ty, *(canvasBrushPixelPtr + 2), *(canvasBrushPixelPtr + 1), *(canvasBrushPixelPtr), *(canvasBrushPixelPtr + 3));
}
}
}
}
void UPlotCanvas::DrawPixel(const int32 x, const int32 y, const uint8 r, const uint8 g, const uint8 b, const uint8 a)
{
if (x >= 0 && x < canvasWidth && y >= 0 && y < canvasHeight)
if (x >= 0 && x < CanvasWidth && y >= 0 && y < CanvasHeight)
{
uint8* canvasPixelPtr = canvasPixelData.get() + (x + y * canvasWidth) * bytesPerPixel;
setPixelColor(canvasPixelPtr, r, g, b, a);
uint8* CanvasPixelPtr = CanvasPixelData.get() + (x + y * CanvasWidth) * BytesPerPixel;
SetPixelColor(CanvasPixelPtr, r, g, b, a);
}
}
void UPlotCanvas::ClearCanvas()
{
uint8* canvasPixelPtr = canvasPixelData.get();
for (int i = 0; i < canvasWidth * canvasHeight; ++i)
uint8* CanvasPixelPtr = CanvasPixelData.get();
for (int i = 0; i < CanvasWidth * CanvasHeight; ++i)
{
setPixelColor(canvasPixelPtr, 128, 128, 128, 0);
canvasPixelPtr += bytesPerPixel;
SetPixelColor(CanvasPixelPtr, 128, 128, 128, 0);
CanvasPixelPtr += BytesPerPixel;
}
UpdateCanvas();
}
void UPlotCanvas::UpdateCanvas()
{
if (echoUpdateTextureRegion)
if (EchoUpdateTextureRegion)
{
dynamicCanvas->UpdateTextureRegions((int32)0, (uint32)1, echoUpdateTextureRegion.get(), (uint32)bufferPitch, (uint32)bytesPerPixel, canvasPixelData.get());
DynamicCanvas->UpdateTextureRegions((int32)0, (uint32)1, EchoUpdateTextureRegion.get(), (uint32)BufferPitch, (uint32)BytesPerPixel, CanvasPixelData.get());
}
}
void UPlotCanvas::setPixelColor(uint8*& pointer, uint8 red, uint8 green, uint8 blue, uint8 alpha)
void UPlotCanvas::SetPixelColor(uint8*& pointer, uint8 red, uint8 green, uint8 blue, uint8 alpha)
{
*pointer = blue; //b
*(pointer + 1) = green; //g
......
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