diff --git a/GLLIBSRC/Arrow.cpp b/GLLIBSRC/Arrow.cpp new file mode 100644 index 0000000..84a5010 --- /dev/null +++ b/GLLIBSRC/Arrow.cpp @@ -0,0 +1,207 @@ + +#include +#include "Arrow.h" + +#define DEFAUT_NUMFAI 16 +#define DEFAUT_CONERAD 5 +#define DEFAUT_CONERATIO 2.5 +#define DEFAUT_R_R_Ratio 0.4 +void Arrow::Set(int nfai) +{ + int i; + double ang,step; + + if( m_nfai == nfai) return; + m_nfai = nfai; + + if(m_sinfai != NULL) delete m_sinfai; m_sinfai = NULL; + if(m_cosfai != NULL) delete m_cosfai; m_cosfai = NULL; + if(m_conetx != NULL) delete m_conetx; m_conetx = NULL; + if(m_conety != NULL) delete m_conety; m_conety = NULL; + if(m_cylindtx != NULL) delete m_cylindtx; m_cylindtx = NULL; + if(m_cylindty != NULL) delete m_cylindty; m_cylindty = NULL; + + m_sinfai = new float[m_nfai]; + m_cosfai = new float[m_nfai]; + m_conetx = new float[m_nfai]; + m_conety = new float[m_nfai]; + m_cylindtx = new float[m_nfai]; + m_cylindty = new float[m_nfai]; + + step = (2.*3.14159265359)/ (double) (m_nfai-1); + for(i=0; i=0; i--) + glVertex3f(m_cylindtx[i], m_cylindty[i], 0.f); + glEnd(); + + //Then draw the surround of cylinder + glBegin(GL_TRIANGLE_STRIP); + for(i=0; i=0; i--) + glVertex3f(m_conetx[i], m_conety[i], 0.f); + glEnd(); + + glBegin(GL_TRIANGLE_STRIP); + for(i=0; i=0; i--) + glVertex3f(m_conetx[i]*ratio, m_conety[i]*ratio, 0.f); + glEnd(); + + glBegin(GL_TRIANGLE_STRIP); + for(i=0; i +#include "Arrowline.h" + +#define DEFAUT_NUMFAI 8 +#define DEFAUT_CONERAD 5 +#define DEFAUT_CONERATIO 2.5 +#define DEFAUT_R_R_Ratio 0.4 +void Arrowline::Set(int nfai) +{ + int i; + double ang,step; + + if( m_nfai == nfai) return; + m_nfai = nfai; + + if(m_sinfai != NULL) delete m_sinfai; m_sinfai = NULL; + if(m_cosfai != NULL) delete m_cosfai; m_cosfai = NULL; + if(m_conetx != NULL) delete m_conetx; m_conetx = NULL; + if(m_conety != NULL) delete m_conety; m_conety = NULL; + + m_sinfai = new float[m_nfai]; + m_cosfai = new float[m_nfai]; + m_conetx = new float[m_nfai]; + m_conety = new float[m_nfai]; + + step = (2.*3.14159265359)/ (double) m_nfai; + for(i=0; ibmiHeader.biSizeImage) == 0) + bitsize = (info->bmiHeader.biWidth * + info->bmiHeader.biBitCount + 7) / 8 * + abs(info->bmiHeader.biHeight); + + if ((oldbits = malloc(bitsize)) == NULL) + { + /* + * Couldn't allocate memory - return NULL! + */ + + free(info); + fclose(fp); + return (-1); + }; + + if (fread(oldbits, 1, bitsize, fp) < bitsize) + { + /* + * Couldn't read bitmap - free memory and return NULL! + */ + + free(info); + free(oldbits); + fclose(fp); + return (-1); + }; + + /* + * OK, everything went fine - return the allocated bitmap... + */ + + fclose(fp); + bits = ConvertRGB(info, oldbits); + free(oldbits); + oldbits = NULL; + return 0; +} + +int Bitmap::SaveToFile(QString fname) +{ + + FILE *fp; /* Open file pointer */ + long size, /* Size of file */ + infosize, /* Size of bitmap info */ + bitsize; /* Size of bitmap pixels */ + BITMAPFILEHEADER header; /* File header */ + + + + if(info == NULL || bits == NULL) return -1; + /* + * Try opening the file; use "wb" mode to write this *binary* file. + */ + QFile file(fname); + file.open(QIODevice::WriteOnly); + + if (info->bmiHeader.biSizeImage == 0) /* Figure out the bitmap size */ + bitsize = (info->bmiHeader.biWidth * + info->bmiHeader.biBitCount + 7) / 8 * + abs(info->bmiHeader.biHeight); + else + bitsize = info->bmiHeader.biSizeImage; + + infosize = sizeof(BITMAPINFOHEADER); + switch (info->bmiHeader.biCompression) + { + case BI_BITFIELDS : + infosize += 12; /* Add 3 RGB doubleword masks */ + if (info->bmiHeader.biClrUsed == 0) + break; + case BI_RGB : + if (info->bmiHeader.biBitCount > 8 && + info->bmiHeader.biClrUsed == 0) + break; + case BI_RLE8 : + case BI_RLE4 : + if (info->bmiHeader.biClrUsed == 0) + infosize += (1 << info->bmiHeader.biBitCount) * 4; + else + infosize += info->bmiHeader.biClrUsed * 4; + break; + }; + + size = sizeof(BITMAPFILEHEADER) + infosize + bitsize; + + /* + * Write the file header, bitmap information, and bitmap pixel data... + */ + + header.bfType = 'MB'; /* Non-portable... sigh */ + header.bfSize = size; + header.bfReserved1 = 0; + header.bfReserved2 = 0; + header.bfOffBits = sizeof(BITMAPFILEHEADER) + infosize; + + if (fwrite(&header, 1, sizeof(BITMAPFILEHEADER), fp) < sizeof(BITMAPFILEHEADER)) + { + /* + * Couldn't write the file header - return... + */ + + fclose(fp); + return (-1); + }; + + if (fwrite(info, 1, infosize, fp) < infosize) + { + /* + * Couldn't write the bitmap header - return... + */ + + fclose(fp); + return (-1); + + } + return 0; +} + + +int Bitmap::SaveToFile(char*filename) +{ + FILE *fp; /* Open file pointer */ + long size, /* Size of file */ + infosize, /* Size of bitmap info */ + bitsize; /* Size of bitmap pixels */ + BITMAPFILEHEADER header; /* File header */ + + + + if(info == NULL || bits == NULL) return -1; + /* + * Try opening the file; use "wb" mode to write this *binary* file. + */ + if ((fp = fopen(filename, "wb")) == NULL) return (-1); + + if (info->bmiHeader.biSizeImage == 0) /* Figure out the bitmap size */ + bitsize = (info->bmiHeader.biWidth * + info->bmiHeader.biBitCount + 7) / 8 * + abs(info->bmiHeader.biHeight); + else + bitsize = info->bmiHeader.biSizeImage; + + infosize = sizeof(BITMAPINFOHEADER); + switch (info->bmiHeader.biCompression) + { + case BI_BITFIELDS : + infosize += 12; /* Add 3 RGB doubleword masks */ + if (info->bmiHeader.biClrUsed == 0) + break; + case BI_RGB : + if (info->bmiHeader.biBitCount > 8 && + info->bmiHeader.biClrUsed == 0) + break; + case BI_RLE8 : + case BI_RLE4 : + if (info->bmiHeader.biClrUsed == 0) + infosize += (1 << info->bmiHeader.biBitCount) * 4; + else + infosize += info->bmiHeader.biClrUsed * 4; + break; + }; + + size = sizeof(BITMAPFILEHEADER) + infosize + bitsize; + + /* + * Write the file header, bitmap information, and bitmap pixel data... + */ + + header.bfType = 'MB'; /* Non-portable... sigh */ + header.bfSize = size; + header.bfReserved1 = 0; + header.bfReserved2 = 0; + header.bfOffBits = sizeof(BITMAPFILEHEADER) + infosize; + + if (fwrite(&header, 1, sizeof(BITMAPFILEHEADER), fp) < sizeof(BITMAPFILEHEADER)) + { + /* + * Couldn't write the file header - return... + */ + + fclose(fp); + return (-1); + }; + + if (fwrite(info, 1, infosize, fp) < infosize) + { + /* + * Couldn't write the bitmap header - return... + */ + + fclose(fp); + return (-1); + }; + + if (fwrite(bits, 1, bitsize, fp) < bitsize) + { + /* + * Couldn't write the bitmap - return... + */ + + fclose(fp); + return (-1); + }; + + /* + * OK, everything went fine - return... + */ + + fclose(fp); + return (0); +} + + +long Bitmap::StoreSize() +{ + long size, /* Size of file */ + infosize, /* Size of bitmap info */ + bitsize; /* Size of bitmap pixels */ + + if(info == NULL || bits == NULL) return -1; + + if (info->bmiHeader.biSizeImage == 0) /* Figure out the bitmap size */ + bitsize = (info->bmiHeader.biWidth * + info->bmiHeader.biBitCount + 7) / 8 * + abs(info->bmiHeader.biHeight); + else + bitsize = info->bmiHeader.biSizeImage; + + infosize = sizeof(BITMAPINFOHEADER); + switch (info->bmiHeader.biCompression) + { + case BI_BITFIELDS : + infosize += 12; /* Add 3 RGB doubleword masks */ + if (info->bmiHeader.biClrUsed == 0) + break; + case BI_RGB : + if (info->bmiHeader.biBitCount > 8 && + info->bmiHeader.biClrUsed == 0) + break; + case BI_RLE8 : + case BI_RLE4 : + if (info->bmiHeader.biClrUsed == 0) + infosize += (1 << info->bmiHeader.biBitCount) * 4; + else + infosize += info->bmiHeader.biClrUsed * 4; + break; + }; + + size = sizeof(BITMAPFILEHEADER) + infosize + bitsize; + return size; +} + + +int Bitmap::SaveToClipBoard() +{ + long size, /* Size of file */ + infosize, /* Size of bitmap info */ + bitsize; /* Size of bitmap pixels */ + long i; + BYTE *p; + + + if(info == NULL || bits == NULL) return -1; + //*** to determine the size of clipboard + if (info->bmiHeader.biSizeImage == 0) /* Figure out the bitmap size */ + bitsize = (info->bmiHeader.biWidth * + info->bmiHeader.biBitCount + 7) / 8 * + abs(info->bmiHeader.biHeight); + else + bitsize = info->bmiHeader.biSizeImage; + + infosize = sizeof(BITMAPINFOHEADER); + switch (info->bmiHeader.biCompression) + { + case BI_BITFIELDS : + infosize += 12; /* Add 3 RGB doubleword masks */ + if (info->bmiHeader.biClrUsed == 0) + break; + case BI_RGB : + if (info->bmiHeader.biBitCount > 8 && + info->bmiHeader.biClrUsed == 0) + break; + case BI_RLE8 : + case BI_RLE4 : + if (info->bmiHeader.biClrUsed == 0) + infosize += (1 << info->bmiHeader.biBitCount) * 4; + else + infosize += info->bmiHeader.biClrUsed * 4; + break; + }; + + size = infosize + bitsize; + // allocate memory + HGLOBAL hClipBoard = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,size); + LPVOID bClipBoard = GlobalLock(hClipBoard); + + OpenClipboard(NULL); + EmptyClipboard(); + + p = (BYTE*)bClipBoard; + i = infosize; + memcpy(p, info, infosize); + p = p + i; + memcpy(p, (BYTE*)bits, bitsize); + + HANDLE pp = SetClipboardData(CF_DIB,hClipBoard); + CloseClipboard(); + + return (0); +} + + +/* + * 'ReadDIBitmap()' - Read the current OpenGL viewport into a + * 24-bit RGB bitmap. + * + * Returns the bitmap pixels if successful and NULL otherwise. + */ + +int Bitmap::ReadFromViewport( ) +{ + long i, j, /* Looping var */ + bitsize, /* Total size of bitmap */ + width; /* Aligned width of a scanline */ + GLint viewport[4]; /* Current viewport */ + GLubyte *rgb, /* RGB looping var */ + temp; /* Temporary var for swapping */ + + if(info != NULL ) + { + free(info); + info = NULL; + } + if(bits != NULL) + { + free(bits); + bits = NULL; + } + /* + * Grab the current viewport... + */ + glGetIntegerv(GL_VIEWPORT, viewport); + + /* + * Allocate memory for the header and bitmap... + */ + + if ((info = (BITMAPINFO *)malloc(sizeof(BITMAPINFOHEADER))) == NULL) + { + /* + * Couldn't allocate memory for bitmap info - return NULL... + */ + + return (-1); + }; + + width = viewport[2] * 3; /* Real width of scanline */ + width = (width + 3) & ~3; /* Aligned to 4 bytes */ + bitsize = width * viewport[3]; /* Size of bitmap, aligned */ + + if ((bits = calloc(bitsize, 1)) == NULL) + { + /* + * Couldn't allocate memory for bitmap pixels - return NULL... + */ + + free(info); + return (NULL); + }; + + /* + * Read pixels from the framebuffer... + */ + + glFinish(); /* Finish all OpenGL commands */ + glPixelStorei(GL_PACK_ALIGNMENT, 4); /* Force 4-byte alignment */ + glPixelStorei(GL_PACK_ROW_LENGTH, 0); + glPixelStorei(GL_PACK_SKIP_ROWS, 0); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + + glReadPixels(0, 0, viewport[2], viewport[3], GL_RGB, GL_UNSIGNED_BYTE, + bits); + + /* + * Swap red and blue for the bitmap... + */ + + for (i = 0; i < viewport[3]; i ++) + for (j = 0, rgb = ((GLubyte *)bits) + i * width; + j < viewport[2]; + j ++, rgb += 3) + { + temp = rgb[0]; + rgb[0] = rgb[2]; + rgb[2] = temp; + }; + + /* + * Finally, initialize the bitmap header information... + */ + + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biWidth = viewport[2]; + info->bmiHeader.biHeight = viewport[3]; + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 24; + info->bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biSizeImage = bitsize; + info->bmiHeader.biXPelsPerMeter = 2952; /* 75 DPI */ + info->bmiHeader.biYPelsPerMeter = 2952; /* 75 DPI */ + info->bmiHeader.biClrUsed = 0; + info->bmiHeader.biClrImportant = 0; + + return 0; +} + +int Bitmap::ReadFromViewport(int xPos, int yPos, int w, int h) +{ + long i, j, /* Looping var */ + bitsize, /* Total size of bitmap */ + width; /* Aligned width of a scanline */ + GLubyte *rgb, /* RGB looping var */ + temp; /* Temporary var for swapping */ + + if(info != NULL ) + { + free(info); + info = NULL; + } + if(bits != NULL) + { + free(bits); + bits = NULL; + } + /* + * Allocate memory for the header and bitmap... + */ + + if ((info = (BITMAPINFO *)malloc(sizeof(BITMAPINFOHEADER))) == NULL) + { + /* + * Couldn't allocate memory for bitmap info - return NULL... + */ + + return (-1); + }; + + width = w * 3; /* Real width of scanline */ + width = (width + 3) & ~3; /* Aligned to 4 bytes */ + bitsize = width * h; /* Size of bitmap, aligned */ + + if ((bits = calloc(bitsize, 1)) == NULL) + { + /* + * Couldn't allocate memory for bitmap pixels - return NULL... + */ + + free(info); + return (NULL); + }; + + /* + * Read pixels from the framebuffer... + */ + + glFinish(); /* Finish all OpenGL commands */ + glPixelStorei(GL_PACK_ALIGNMENT, 4); /* Force 4-byte alignment */ + glPixelStorei(GL_PACK_ROW_LENGTH, 0); + glPixelStorei(GL_PACK_SKIP_ROWS, 0); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + + glReadPixels(xPos, yPos, w, h, GL_RGB, GL_UNSIGNED_BYTE, bits); + + /* + * Swap red and blue for the bitmap... + */ + + for (i = 0; i < h; i ++) + for (j = 0, rgb = ((GLubyte *)bits) + i * width; + j < w; + j ++, rgb += 3) + { + temp = rgb[0]; + rgb[0] = rgb[2]; + rgb[2] = temp; + }; + + /* + * Finally, initialize the bitmap header information... + */ + + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biWidth = w; + info->bmiHeader.biHeight = h; + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 24; + info->bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biSizeImage = bitsize; + info->bmiHeader.biXPelsPerMeter = 2952; /* 75 DPI */ + info->bmiHeader.biYPelsPerMeter = 2952; /* 75 DPI */ + info->bmiHeader.biClrUsed = 0; + info->bmiHeader.biClrImportant = 0; + + return 0; +} + + + +/* + * 'PrintDIBitmap()' - Print a bitmap to a GDI printer. + */ + + int Bitmap::Print() +{ + PRINTDLG pd; /* Print dialog information */ + long xsize, /* Size of printed image */ + ysize, + xoffset, /* Offset from edges for image */ + yoffset; + RECT rect; /* Page rectangle */ + DOCINFO di; /* Document info */ + HDC hdc; /* Device context for bitmap */ + HBITMAP bitmap; /* Bitmap image */ + HBRUSH brush; /* Background brush for page */ + HCURSOR busy, /* Busy cursor */ + oldcursor; /* Old cursor */ + + + /* + * Range check... + */ + if (info == NULL || bits == NULL) + return (0); + + /* + * Initialize a PRINTDLG structure before displaying a standard Windows + * print dialog... + */ + + memset(&pd, 0, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.hwndOwner = NULL; + pd.Flags = PD_RETURNDC|PD_PRINTTOFILE|PD_PAGENUMS; + pd.hInstance = NULL; + //pd.nFromPage = 1; + //pd.nToPage = 1; + + if (!PrintDlg(&pd)) + return (0); /* User chose 'cancel'... */ + /* + * OK, user wants to print, so set the cursor to 'busy' and start the + * print job... + */ + busy = LoadCursor(NULL, IDC_WAIT); + oldcursor = SetCursor(busy); + + SetMapMode(pd.hDC, MM_TEXT); + di.cbSize = sizeof(DOCINFO); + //di.lpszDocName = "OpenGL Image"; + di.lpszOutput = NULL; + + StartDoc(pd.hDC, &di); + StartPage(pd.hDC); + /* + * Clear the background to white... + */ + rect.top = 0; + rect.left = 0; + rect.right = GetDeviceCaps(pd.hDC, HORZRES); + rect.bottom = GetDeviceCaps(pd.hDC, VERTRES); + brush = CreateSolidBrush(0x00ffffff); + FillRect(pd.hDC, &rect, brush); + /* + * Stretch the bitmap to fit the page... + */ + + hdc = CreateCompatibleDC(pd.hDC); + bitmap = CreateDIBitmap(hdc, &(info->bmiHeader), CBM_INIT, bits, info, + DIB_RGB_COLORS); + SelectObject(hdc, bitmap); + + xsize = rect.right; + ysize = xsize * info->bmiHeader.biHeight / info->bmiHeader.biWidth; + if (ysize > rect.bottom) + { + ysize = rect.bottom; + xsize = ysize * info->bmiHeader.biWidth / info->bmiHeader.biHeight; + }; + + xoffset = (rect.right - xsize) / 2; + yoffset = (rect.bottom - ysize) / 2; + /*StretchBlt(pd.hDC, xoffset, yoffset, xsize, ysize, + hdc, 0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight, + SRCCOPY); + */ + StretchBlt(pd.hDC, xoffset, yoffset, info->bmiHeader.biWidth, info->bmiHeader.biHeight, + hdc, 0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight, + SRCCOPY); + + /* + * That's it. End the print job and free anything we allocated... + */ + + EndPage(pd.hDC); + EndDoc(pd.hDC); + DeleteDC(pd.hDC); + + DeleteObject(bitmap); + DeleteObject(brush); + DeleteObject(busy); + DeleteDC(hdc); + + /* + * Restore the cursor and return... + */ + + SetCursor(oldcursor); + + return (1); +} + + int Bitmap::Print(PRINTDLG pd) +{ + long xsize, /* Size of printed image */ + ysize, + xoffset, /* Offset from edges for image */ + yoffset; + RECT rect; /* Page rectangle */ + DOCINFO di; /* Document info */ + HDC hdc; /* Device context for bitmap */ + HBITMAP bitmap; /* Bitmap image */ + HBRUSH brush; /* Background brush for page */ + + /* + * Range check... + */ + if (info == NULL || bits == NULL) + return (0); + + + SetMapMode(pd.hDC, MM_TEXT); + di.cbSize = sizeof(DOCINFO); + di.lpszDocName = (LPCWSTR)"OpenGL Image"; + di.lpszOutput = NULL; + + StartDoc(pd.hDC, &di); + StartPage(pd.hDC); + /* + * Clear the background to white... + */ + rect.top = 0; + rect.left = 0; + rect.right = GetDeviceCaps(pd.hDC, HORZRES); + rect.bottom = GetDeviceCaps(pd.hDC, VERTRES); + brush = CreateSolidBrush(0x00ffffff); + FillRect(pd.hDC, &rect, brush); + /* + * Stretch the bitmap to fit the page... + */ + + hdc = CreateCompatibleDC(pd.hDC); + bitmap = CreateDIBitmap(hdc, &(info->bmiHeader), CBM_INIT, bits, info, + DIB_RGB_COLORS); + SelectObject(hdc, bitmap); + + xsize = rect.right; + ysize = xsize * info->bmiHeader.biHeight / info->bmiHeader.biWidth; + if (ysize > rect.bottom) + { + ysize = rect.bottom; + xsize = ysize * info->bmiHeader.biWidth / info->bmiHeader.biHeight; + }; + + xoffset = (rect.right - xsize) / 2; + yoffset = (rect.bottom - ysize) / 2; + StretchBlt(pd.hDC, xoffset, yoffset, xsize, ysize, + hdc, 0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight, + SRCCOPY); + + /* + * That's it. End the print job and free anything we allocated... + */ + + EndPage(pd.hDC); + EndDoc(pd.hDC); + DeleteDC(pd.hDC); + + DeleteObject(bitmap); + DeleteObject(brush); + DeleteDC(hdc); + return (1); +} + + + +void Bitmap::Paintat(float xoffset, float yoffset, float zoffset, int w, int h) /* I - Client area rectangle */ +{ + GLfloat xscale, /* Scaling in X direction */ + yscale; /* Scaling in Y direction */ + + xscale = (float)w / (float)info->bmiHeader.biWidth; + yscale = (float)h / (float)info->bmiHeader.biHeight; + + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glPixelZoom(xscale, yscale); + glRasterPos3f(xoffset, yoffset, zoffset); + glDrawPixels(info->bmiHeader.biWidth, info->bmiHeader.biHeight, + GL_RGB, GL_UNSIGNED_BYTE, bits); + +// glFinish(); +} + + +void Bitmap::Paintat(float xoffset, float yoffset, float zoffset) +{ + int w, h; + + w = info->bmiHeader.biWidth; + h = info->bmiHeader.biHeight; + + Paintat(xoffset, yoffset, zoffset, w, h); +} + +GLubyte* Bitmap::ConvertRGB(BITMAPINFO *info, void *bits) +{ + int i, j, /* Looping vars */ + bitsize, /* Total size of bitmap */ + width; /* Aligned width of bitmap */ + GLubyte *newbits; /* New RGB bits */ + GLubyte *from, *to; /* RGB looping vars */ + + + /* + * Allocate memory for the RGB bitmap... + */ + + width = 3 * info->bmiHeader.biWidth; + width = (width + 3) & ~3; + bitsize = width * info->bmiHeader.biHeight; + if ((newbits = (GLubyte *)calloc(bitsize, 1)) == NULL) + return (NULL); + + /* + * Copy the original bitmap to the new array, converting as necessary. + */ + + switch (info->bmiHeader.biCompression) + { + case BI_RGB : + if (info->bmiHeader.biBitCount == 24) + { + /* + * Swap red & blue in a 24-bit image... + */ + + for (i = 0; i < info->bmiHeader.biHeight; i ++) + for (j = 0, from = ((GLubyte *)bits) + i * width, + to = newbits + i * width; + j < info->bmiHeader.biWidth; + j ++, from += 3, to += 3) + { + to[0] = from[2]; + to[1] = from[1]; + to[2] = from[0]; + }; + }; + break; + case BI_RLE4 : + case BI_RLE8 : + case BI_BITFIELDS : + break; + }; + + return (newbits); +} + +void Bitmap::MakeTexture() +{ + if(texture >=1 ) return; + glNewList(texture = glGenLists(1), GL_COMPILE); + if (info->bmiHeader.biHeight == 1||info->bmiHeader.biWidth == 1) + { + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT); + texDim = GL_TEXTURE_1D; + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + texDim = GL_TEXTURE_2D; + } + + if (info->bmiHeader.biHeight == 1) + { + glTexImage1D(GL_TEXTURE_1D, 0, 3, info->bmiHeader.biWidth, 0, GL_RGB, GL_UNSIGNED_BYTE, bits); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + else if (info->bmiHeader.biWidth == 1) + { + glTexImage1D(GL_TEXTURE_1D, 0, 3, info->bmiHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bits); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + else + { + glTexImage2D(GL_TEXTURE_2D, 0, 3, info->bmiHeader.biWidth, info->bmiHeader.biHeight, 0, + GL_RGB, GL_UNSIGNED_BYTE, bits); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + }; + glEndList(); + + return; +} + + + + + + + + + diff --git a/GLLIBSRC/Bitmap.h b/GLLIBSRC/Bitmap.h new file mode 100644 index 0000000..d8304b5 --- /dev/null +++ b/GLLIBSRC/Bitmap.h @@ -0,0 +1,39 @@ + +#ifndef _BITMAP_ +#define _BITMAP_ +#include "GlcObj.h" + +class Bitmap:public GlcObj +{ + private: + protected: + BITMAPINFO *info; + void *bits; + int texture; + int texDim; + GLubyte *ConvertRGB(BITMAPINFO *, void *); + public: + Bitmap(); + Bitmap(char*); + ~Bitmap(); + int LoadFromFile(char *); + int ReadFromViewport(); + int ReadFromViewport(int, int, int, int); + int SaveToFile(char *); + int SaveToFile(QString fname); + + int SaveToClipBoard(); + void Paintat(float, float, float, int, int); + void Paintat(float, float, float); + int Print(); + int Print(PRINTDLG); + void MakeTexture(); + int Texture(){ return texture;} + void PutonAsTexture(); + void PutonAsTexture(GlcObj*); + void* GetBits(){ return bits;}; + long StoreSize(); + BITMAPINFO * GetInfo(){ return info;}; + +}; +#endif diff --git a/GLLIBSRC/Circle.cpp b/GLLIBSRC/Circle.cpp new file mode 100644 index 0000000..4ae536d --- /dev/null +++ b/GLLIBSRC/Circle.cpp @@ -0,0 +1,152 @@ +#include + +#include "Circle.h" + + +#define c_MXNFAI 64 +#define DEFAUT_NUMFAI 12 +static float cosfai[c_MXNFAI], sinfai[c_MXNFAI]; + +int Circle::fai=0; + + +void Circle::Set(int Nf) +{ + int i; + double ang,step; + + if( fai == Nf) return; + + fai = Nf; + if(fai > c_MXNFAI) fai = c_MXNFAI; + + step = (2.*3.14159265359)/ (double) (fai-1); + for(i=0; i 0) glDeleteLists(list,1); +} + +Circle::Circle() +{ + x = 0.f; + y = 0.f; + size = 1.f; + borderThick = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Circle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; + +} + +Circle::Circle(float radiu) +{ + x = 0.f; + y = 0.f; + size = radiu; + borderThick = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Circle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + + +Circle::Circle(float X, float Y) +{ + x = X; + y = Y; + size = 1.f; + borderThick = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Circle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + +Circle::Circle(float radiu, float X, float Y) +{ + x = X; + y = Y; + size = radiu; + borderThick = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Circle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + + +Circle::Circle(float radiu, float X, float Y, float Red, float Green, float Blue) +{ + x = X; + y = Y; + size = radiu; + borderThick = 1.f; + R = Red; + G = Green; + B = Blue; + if(Circle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + + +void Circle::Paint() +{ + int i; + + glPushMatrix(); + glTranslatef(x,y,0.f); + + if(list > 0) + { + glScalef(size,size,size); + glCallList(list); + glPopMatrix(); + return; + } + glEnable(GL_LINE_SMOOTH); + glEnable(GL_COLOR_MATERIAL); + glColor4f(R,G,B,A); + glLineWidth(borderThick); + glBegin(GL_LINE_LOOP); + for(i=0; i // Standard windows include +#include // OpenGL library +#include "xyPoint.h" +#include "Texture.h" + +#ifndef _CIRCLE +#define _CIRCLE + +class Circle: public xyPoint +{ +private: + static int fai; + int list; +protected: + float borderThick; +public: + Circle(); + Circle(float); + Circle(float,float); + Circle(float,float,float); + Circle(float,float,float,float,float,float); + ~Circle(); + static void Set(int); + virtual void Paint(); + virtual int MakeList(); + int GetList(){return list;}; +//** + void SetBorderThick(float thick){borderThick = thick;}; + float GetBorderThick(){return borderThick;}; +}; +#endif \ No newline at end of file diff --git a/GLLIBSRC/GLCOBJ.h b/GLLIBSRC/GLCOBJ.h new file mode 100644 index 0000000..1781d76 --- /dev/null +++ b/GLLIBSRC/GLCOBJ.h @@ -0,0 +1,31 @@ +//#include // Standard windows include +//#include // OpenGL library + +#ifndef _GLCOBJ +#define _GLCOBJ +#include + +class GlcObj +{ +protected: +public: + GlcObj(){}; + virtual ~GlcObj(){}; + virtual void Paint(){}; + virtual void Move(float, float, float){}; + virtual void Translate(float, float, float){}; + virtual void ChangeColor(float, float, float){}; + virtual float MinX(){ return 0.f;}; + virtual float MinY(){ return 0.f;}; + virtual float MinZ(){ return 0.f;}; + virtual float MaxX(){ return 0.f;}; + virtual float MaxY(){ return 0.f;}; + virtual float MaxZ(){ return 0.f;}; + virtual void SetXscal(float xscal){}; + virtual void SetYscal(float yscal){}; + virtual void SetZscal(float zscal){}; + virtual void SetStyle(int NewStyle){}; + virtual int GetStyle(){ return 0;}; +}; + +#endif diff --git a/GLLIBSRC/Light.cpp b/GLLIBSRC/Light.cpp new file mode 100644 index 0000000..9bd5e3d --- /dev/null +++ b/GLLIBSRC/Light.cpp @@ -0,0 +1,187 @@ +#include + +#include "Light.h" + + +#define labelLight GL_LIGHT0+(n-1) + +int Light::number=0; + +Light::~Light() +{ + if(number > 0) number--; + glDisable(n); +} + +Light::Light() +{ + A_light[0] = 0.2f; + A_light[1] = 0.2f; + A_light[2] = 0.2f; + A_light[3] = 1.f; + + D_light[0] = 1.f; + D_light[1] = 1.f; + D_light[2] = 1.f; + D_light[3] = 1.f; + + S_light[0] = 1.f; + S_light[1] = 1.f; + S_light[2] = 1.f; + S_light[3] = 1.f; + + SPOT_light[0] = 1.f; + SPOT_light[1] = 1.f; + SPOT_light[2] = 1.f; + SPOT_light[3] = 1.f; + + Pos[0] = 1.f; + Pos[1] = 1.f; + Pos[2] = 1.f; + Pos[3] = 0.f; + + number ++; + n = number; + if(n > 8) n = 8; + n = labelLight; + + +} + + +Light::Light(int I) +{ + A_light[0] = 0.2f; + A_light[1] = 0.2f; + A_light[2] = 0.2f; + A_light[3] = 1.f; + + D_light[0] = 1.f; + D_light[1] = 1.f; + D_light[2] = 1.f; + D_light[3] = 1.f; + + S_light[0] = 1.f; + S_light[1] = 1.f; + S_light[2] = 1.f; + S_light[3] = 1.f; + + SPOT_light[0] = 1.f; + SPOT_light[1] = 1.f; + SPOT_light[2] = 1.f; + SPOT_light[3] = 1.f; + + Pos[0] = 1.f; + Pos[1] = 1.f; + Pos[2] = 1.f; + Pos[3] = 0.f; + + n = I; + n = labelLight; + +} + + +void Light::ChangeColorA(float Red, float Green, float Blue) +{ + A_light[0] = Red; + A_light[1] = Green; + A_light[2] = Blue; + A_light[3] = 1.f; + glLightfv(n, GL_AMBIENT,A_light); +} + +void Light::ChangeColorD(float Red, float Green, float Blue) +{ + D_light[0] = Red; + D_light[1] = Green; + D_light[2] = Blue; + D_light[3] = 1.f; + glLightfv(n, GL_DIFFUSE,D_light); +} + +void Light::ChangeColorS(float Red, float Green, float Blue) +{ + S_light[0] = Red; + S_light[1] = Green; + S_light[2] = Blue; + S_light[3] = 1.f; + glLightfv(n, GL_SPECULAR,S_light); +} + + +void Light::ChangeColorA(float color[3]) +{ + A_light[0] = color[0]; + A_light[1] = color[1]; + A_light[2] = color[2]; + A_light[3] = 1.f; + glLightfv(n, GL_AMBIENT,A_light); + +} + +void Light::ChangeColorD(float color[3]) +{ + D_light[0] = color[0]; + D_light[1] = color[1]; + D_light[2] = color[2]; + D_light[3] = 1.f; + glLightfv(n, GL_DIFFUSE,D_light); + +} + +void Light::ChangeColorS(float color[3]) +{ + S_light[0] = color[0]; + S_light[1] = color[1]; + S_light[2] = color[2]; + S_light[3] = 1.f; + glLightfv(n, GL_SPECULAR,S_light); + +} + + + +void Light::ChangePosition(float x, float y, float z) +{ + Pos[0] = x; + Pos[1] = y; + Pos[2] = z; + glLightfv(n, GL_POSITION, Pos); +} + +void Light::ChangePosition(float x, float y, float z, float a) +{ + Pos[0] = x; + Pos[1] = y; + Pos[2] = z; + Pos[3] = a; + glLightfv(n, GL_POSITION, Pos); + +} + + +void Light::Turnon() +{ + + glEnable(GL_LIGHTING); + glLightfv(n, GL_AMBIENT,A_light); + glLightfv(n, GL_DIFFUSE,D_light); + glLightfv(n, GL_SPECULAR,S_light); + glLightfv(n, GL_POSITION, Pos); + glLightfv(n, GL_SPOT_DIRECTION, SPOT_light); + glEnable(n); + return; +} + +void Light::Turnoff() +{ + + glDisable(n); +} + +void Light::KeepMove() +{ + glLightfv(n, GL_POSITION, Pos); + return; +} \ No newline at end of file diff --git a/GLLIBSRC/Light.h b/GLLIBSRC/Light.h new file mode 100644 index 0000000..fd2cf7e --- /dev/null +++ b/GLLIBSRC/Light.h @@ -0,0 +1,41 @@ +//#include // Standard windows include +//#include // OpenGL library + + +#ifndef _LIGHT +#define _LIGHT +#include "GlcObj.h" +class Light: public GlcObj +{ +private: + GLfloat Pos[4]; + GLfloat A_light[4]; + GLfloat D_light[4]; + GLfloat S_light[4]; + GLfloat SPOT_light[4]; + int n; + static int number; + +public: + Light(); + Light(int); + Light(float,float, float,float,float,float); + Light(float, float, float, float*); + Light(float*, float,float, float); + Light(float*, float*, float*); + ~Light(); + void Turnon(); + void Turnoff(); + void ChangeColorA(float, float, float); + void ChangeColorA(float*); + void ChangeColorD(float, float, float); + void ChangeColorD(float*); + void ChangeColorS(float, float, float); + void ChangeColorS(float*); + void ChangePosition(float, float, float); + void ChangePosition(float, float, float, float); + void KeepMove(); + +}; + +#endif diff --git a/GLLIBSRC/Line.cpp b/GLLIBSRC/Line.cpp new file mode 100644 index 0000000..76b7ca2 --- /dev/null +++ b/GLLIBSRC/Line.cpp @@ -0,0 +1,194 @@ +#include "math.h" +#include "Line.h" + + +Line::Line() +{ + Startx=0.f; + Starty=0.f; + Startz=0.f; + Endx=100.f; + Endy=100.f; + Endz=100.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; +} + +Line::Line(float x0, float y0, float x1, float y1) +{ + Startx=x0; + Starty=y0; + Startz=0.f; + Endx=x1; + Endy=y1; + Endz=0.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; +} + + +Line::Line(float x0, float y0, float z0, float x1, float y1, float z1) +{ + Startx=x0; + Starty=y0; + Startz=z0; + Endx=x1; + Endy=y1; + Endz=z1; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; +} + +void Line::Paint() +{ + //glLineSize(size); + glColor4f(R,G,B,A); + glBegin(GL_LINES); + glVertex3f(Startx, Starty, Startz); + glVertex3f(Endx, Endy, Endz); + glEnd(); +// glFlush(); + return; +} + + +void Line::Translate(float Newx, float Newy, float Newz) +{ + + Startx += Newx; + Starty += Newy; + Startz += Newz; + Endx += Newx; + Endy += Newy; + Endz += Newz; + return; +} + +void Line::MoveTo(float Newx, float Newy, float Newz) +{ + float dx, dy, dz; + + dx = Newx - Startx; + dy = Newy - Starty; + dz = Newz - Startz; + Startx = Newx; + Starty = Newy; + Startz = Newz; + Endx += dx; + Endy += dy; + Endz += dz; + return; +} + +void Line::GetStartPoint(float*x, float*y, float*z) +{ + + (*x) = Startx; + (*y) = Starty; + (*z) = Startz; + return; +} + + +void Line::ResetStartPoint(float x, float y, float z) +{ + + Startx = x; + Starty = y; + Startz = z; + return; +} + +void Line::ResetStartPoint(float v[3]) +{ + + Startx = v[0]; + Starty = v[1]; + Startz = v[2]; + return; +} + +void Line::GetEndPoint(float*x, float*y, float*z) +{ + + (*x) = Endx; + (*y) = Endy; + (*z) = Endz; + return; +} + +void Line::ResetEndPoint(float x, float y, float z) +{ + + Endx = x; + Endy = y; + Endz = z; + return; +} + +void Line::ResetEndPoint(float v[3]) +{ + + Endx = v[0]; + Endy = v[1]; + Endz = v[2]; + return; +} + + +void Line::ChangeColor(float NewR, float NewG, float NewB) +{ + + R = NewR; + G = NewG; + B = NewB; + return; +} + +void Line::ChangeColor(float NewR, float NewG, float NewB, float NewA) +{ + + R = NewR; + G = NewG; + B = NewB; + A = NewA; + return; +} + +void Line::ChangeColor(float Color[3]) +{ + + R = Color[0]; + G = Color[1]; + B = Color[2]; + return; +} + +void Line::ChangeSize(float NewSize) +{ + + size = NewSize; + return; +} + +float Line::GetLen() +{ + + float dx = Endx - Startx; + float dy = Endy - Starty; + float dz = Endz - Startz; + + return (float)sqrt(dx*dx+dy*dy+dz*dz); +} + + + diff --git a/GLLIBSRC/Line.h b/GLLIBSRC/Line.h new file mode 100644 index 0000000..5b1c349 --- /dev/null +++ b/GLLIBSRC/Line.h @@ -0,0 +1,44 @@ + +#include "GlcObj.h" + +#ifndef _LINE +#define _LINE + +class Line:public GlcObj +{ +protected: + GLfloat Startx,Starty,Startz; + GLfloat Endx,Endy,Endz; + GLfloat size; + GLfloat R,G,B,A; +public: + Line(); + Line(float,float,float,float); + Line(float,float,float,float,float,float); + virtual ~Line(){}; + virtual void Paint(); + void Translate(float, float, float); + void MoveTo(float, float, float); + void ChangeColor(float, float, float); + void ChangeColor(float, float, float, float); + void ChangeColor(float*); + void ChangeColorA(float a) {A=a;}; + float GetColorA(){return A;}; + void ChangeTransparency(float t) {A=t;}; + float GetTransparency() {return A;}; + void ChangeSize(float); + void GetStartPoint(float*, float*, float*); + void GetEndPoint(float*, float*, float*); + void ResetStartPoint(float, float, float); + void ResetStartPoint(float*); + void ResetEndPoint(float, float, float); + void ResetEndPoint(float*); + float GetLen(); + float GetLenX(){return Endx-Startx;}; + float GetLenY(){return Endy-Starty;}; + float GetLenZ(){return Endz-Startz;}; + float GetSize(){return size;}; + +}; + +#endif \ No newline at end of file diff --git a/GLLIBSRC/Point.cpp b/GLLIBSRC/Point.cpp new file mode 100644 index 0000000..93f6938 --- /dev/null +++ b/GLLIBSRC/Point.cpp @@ -0,0 +1,68 @@ +#include "Point.h" + +Point::Point() +{ + x=0.f; + y=0.f; + z=0.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; + +} + + +Point::Point(float x0, float y0) +{ + x=x0; + y=y0; + z=0.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; + +} + +Point::Point(float x0, float y0, float z0) +{ + x=x0; + y=y0; + z=z0; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; +} + +Point::Point(float x0, float y0, float z0, float r, float g, float b) +{ + x=x0; + y=y0; + z=z0; + size = 1.f; + R = r; + G = g; + B = b; + A = 1.f; +} + +void Point::Paint() +{ + glEnable(GL_POINT_SMOOTH); + glPointSize(size); + glColor4f(R,G,B,A); + glBegin(GL_POINTS); + glVertex3f(x, y, z); + glEnd(); +// glFlush(); + return; +} + + + + diff --git a/GLLIBSRC/Point.h b/GLLIBSRC/Point.h new file mode 100644 index 0000000..ba476fb --- /dev/null +++ b/GLLIBSRC/Point.h @@ -0,0 +1,41 @@ +//#include // Standard windows include +//#include // OpenGL library +#include "GlcObj.h" + +#ifndef _POINT +#define _POINT + +class Point:public GlcObj +{ +protected: + GLfloat x,y,z; + GLfloat size; + GLfloat R,G,B,A; +public: + Point(); + Point(float,float); + Point(float,float,float); + Point(float,float,float,float,float,float); + virtual ~Point(){}; + virtual void Paint(); + virtual int GetList(){return 0;}; + + + void ChangeAlpha(float NewA){A=NewA;}; + float GetAlpha(){ return A;}; + void ChangeSize(float NewSize){size = NewSize;}; + + void Moveto(float Newx, float Newy, float Newz) { x = Newx; y = Newy; z = Newz; return;} + void MoveTo(float Newx, float Newy, float Newz) {x = Newx; y = Newy; z = Newz; return;} + void Moveto(float Newv[3]) { x = Newv[0]; y = Newv[1]; z = Newv[2]; return;} + void Translate(float dx, float dy, float dz) { x += dx; y += dy; z += dz; return;} + void Translate(float dr[3]) { x += dr[0]; y += dr[1]; z += dr[2]; return;} + void GetPosition(float*x0, float*y0, float*z0) { *x0 = x; *y0 = y; *z0 = z; return;} + void ChangeColor(float NewR, float NewG, float NewB) {R = NewR; G = NewG; B = NewB; return; } + void ChangeColor(float Color[3]) {R = Color[0]; G = Color[1]; B = Color[2]; return;} + void InvertColor() { R = 1-R; G = 1-G; B = 1-B; return;} + void GetColor(float*oldR, float*oldG, float*oldB) { *oldR = R; *oldG = G; *oldB = B; return;} + +}; + +#endif \ No newline at end of file diff --git a/GLLIBSRC/Scene.cpp b/GLLIBSRC/Scene.cpp new file mode 100644 index 0000000..252d961 --- /dev/null +++ b/GLLIBSRC/Scene.cpp @@ -0,0 +1,2165 @@ +#include // Standard windows include +#include // OpenGL library +#include // OpenGL library + +#include + +#include "Scene.h" +#include "Style.h" + +Scene::~Scene() +{ + glDisable(GL_CLIP_PLANE0); + glDisable(GL_CLIP_PLANE1); + glDisable(GL_CLIP_PLANE2); + light1->Turnoff(); + light2->Turnoff(); + light3->Turnoff(); + delete light1; + delete light2; + delete light3; +} + + +Scene::Scene() +{ + m_viewportx0 = m_viewporty0 = 0; + m_viewportw = m_viewporth = 480; + m_x0= -0.5f; + m_x1= 0.5f; + m_y0= -0.5f; + m_y1= 0.5f; + m_z0= -0.5f; + m_z1= 0.5f; + m_dist= 0.f; + + m_showbox = true; + m_borderthick = 2.f; + m_showfrontface[0] = m_showfrontface[1] = m_showfrontface[2] = 1; + m_showbackface[0] = m_showbackface[1] = m_showbackface[2] = 1+2; + m_backfaceopacity[0] = m_backfaceopacity[1] = m_backfaceopacity[2] = 0.f; + + action = 0; + style = scene_Style_ShowVolume|scene_Style_Perspective; + update = 0; + system = scene_System_Relative; + + + m_zoomPercent = 0.9f; + m_zoomscal = 1.f; + m_rotationStepx = m_rotationStepy = m_rotationStepz = 10.f; + m_rotationCx= m_rotationCy= m_rotationCz= 0.5f; + m_itransStepx = m_itransStepy = m_itransStepz = 20.f; + m_itransX = m_itransY = m_itransZ = 0.f; + + iclipStepx = 20.f; //(x1-x0)/40.f; + iclipStepy = 20.f; //(x1-x0)/40.f; + iclipStepz = 20.f; // (x1-x0)/40.f; + + iclipThickx = iclipStepx; + iclipThicky = iclipStepy; + iclipThickz = iclipStepz; + clip1[0] = 1.f; clip1[1] = 0.f; clip1[2] = 0.f; clip1[3] = 0.f; + clip2[0] = 0.f; clip2[1] = 1.f; clip2[2] = 0.f; clip2[3] = 0.f; + clip3[0] = 0.f; clip3[1] = 0.f; clip3[2] = 1.f; clip3[3] = 0.f; + clip1p[0] = -1.f; clip1p[1] = 0.f; clip1p[2] = 0.f; clip1p[3] = (m_x1-m_x0)/(float)iclipThickx; + clip2p[0] = 0.f; clip2p[1] = -1.f; clip2p[2] = 0.f; clip2p[3] = (m_y1-m_y0)/(float)iclipThicky; + clip3p[0] = 0.f; clip3p[1] = 0.f; clip3p[2] = -1.f; clip3p[3] = (m_z1-m_z0)/(float)iclipThickz; + clipState[0] = 0; + clipState[1] = 0; + clipState[2] = 0; + clipState[3] = 0; + clipState[4] = 0; + clipState[5] = 0; + curclip = 0; + + light1 = new Light(1); + light2 = new Light(2); + light3 = new Light(3); + light1->Turnon(); + light2->Turnon(); + light2->ChangePosition(-1.f, -1.f, -1.f); + light2->ChangeColorD(0.5f, 0.5f, 0.5f); + light2->ChangeColorS(0.5f, 0.5f, 0.5f); + glLoadIdentity(); + +} + +Scene::Scene(float left, float right, float bottom, float top, float nearz, float farz, float dist) +{ + m_viewportx0 = m_viewporty0 = 0; + m_viewportw = m_viewporth = 480; + + m_x0= left; + m_x1= right; + m_y0= bottom; + m_y1= top; + m_z0= nearz; + m_z1= farz; + m_dist= dist; + + m_showbox = true; + m_borderthick = 2.f; + m_showfrontface[0] = m_showfrontface[1] = m_showfrontface[2] = 1; + m_showbackface[0] = m_showbackface[1] = m_showbackface[2] = 1+2; + m_backfaceopacity[0] = m_backfaceopacity[1] = m_backfaceopacity[2] = 0.5f; + + action = 0; + style = scene_Style_ShowVolume|scene_Style_Perspective; + update = 0; + system = scene_System_Relative; + + + m_zoomPercent = 0.9f; + m_zoomscal = 1.f; + m_rotationStepx = m_rotationStepy = m_rotationStepz = 10.f; + m_rotationCx= m_rotationCy= m_rotationCz= 0.f; + m_itransStepx = m_itransStepy = m_itransStepz = 20.f; + m_itransX = m_itransY = m_itransZ = 0.f; + + iclipStepx = 20.f; //(x1-x0)/40.f; + iclipStepy = 20.f; //(x1-x0)/40.f; + iclipStepz = 20.f; // (x1-x0)/40.f; + iclipThickx = iclipStepx; + iclipThicky = iclipStepy; + iclipThickz = iclipStepz; + clip1[0] = 1.f; clip1[1] = 0.f; clip1[2] = 0.f; clip1[3] = 0.f; + clip2[0] = 0.f; clip2[1] = 1.f; clip2[2] = 0.f; clip2[3] = 0.f; + clip3[0] = 0.f; clip3[1] = 0.f; clip3[2] = 1.f; clip3[3] = 0.f; + clip1p[0] = -1.f; clip1p[1] = 0.f; clip1p[2] = 0.f; clip1p[3] = (m_x1-m_x0)/(float)iclipThickx; + clip2p[0] = 0.f; clip2p[1] = -1.f; clip2p[2] = 0.f; clip2p[3] = (m_y1-m_y0)/(float)iclipThicky; + clip3p[0] = 0.f; clip3p[1] = 0.f; clip3p[2] = -1.f; clip3p[3] = (m_z1-m_z0)/(float)iclipThickz; + clipState[0] = 0; + clipState[1] = 0; + clipState[2] = 0; + clipState[3] = 0; + clipState[4] = 0; + clipState[5] = 0; + curclip = 0; + + light1 = new Light(1); + light2 = new Light(2); + light3 = new Light(3); + light1->Turnon(); + light2->Turnon(); + light2->ChangePosition(-1.f, -1.f, -1.f); + light2->ChangeColorD(0.5f, 0.5f, 0.5f); + light2->ChangeColorS(0.5f, 0.5f, 0.5f); + glLoadIdentity(); +} + + +void Scene::CreateScene( ) +{ + + GLint viewport[4]; /* Current viewport */ + float w, h; + double nearz, farz, ang,width,height; + + glGetIntegerv(GL_VIEWPORT, viewport); + w =(float)viewport[2]; + h =(float)viewport[3]; + if(w == 0 ) w = 1.f; + if(h == 0) h = 1.f; + + width = (m_x1 - m_x0); + if(width < 0.0) width = -width; + height = (m_y1 - m_y0); + if(height < 0.0) height = -height; + width = std::max(width, height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if((style&scene_Style_Perspective) != scene_Style_Perspective) + { + if (w <= h) + glOrtho (m_x0, m_x0+width, m_y0*h/w, (m_y0+width)*h/w, m_z0, m_z1); + + else + glOrtho (m_x0*w/h, (m_x0+width)*w/h, m_y0, (m_y0+width), m_z0, m_z1); + //glMatrixMode(GL_MODELVIEW); + //glLoadIdentity(); + } + else + { + nearz = m_z0; + if(nearz < 0.0) nearz = -nearz; + if(nearz == 0.0 ) nearz = 1.0; + nearz = nearz+m_dist; + farz = 10.*(m_z1 - m_z0)+nearz; + ang = atan((m_y1 - m_y0)/nearz/2.0)*180.0/3.1415926; + gluPerspective(ang, w/h, nearz, farz); + + //glMatrixMode(GL_MODELVIEW); + //glLoadIdentity(); + + glTranslatef(0.f, 0.f, (float)(-2.5*nearz + m_z0)); + + } + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); +} + + +void Scene::CreateScene(float left, float right, float bottom, float top, float nearz, float farz, float dist) +{ + + m_x0 = left; + m_x1 = right; + m_y0 = bottom; + m_y1 = top; + m_z0 = nearz; + m_z1 = farz; + m_dist = dist; + + clip1[3] = 0.f; + clip2[3] = 0.f; + clip3[3] = 0.f; + clip1p[3] = (m_x1 - m_x0)/(float)iclipThickx; + clip2p[3] = (m_y1 - m_y0)/(float)iclipThicky; + clip3p[3] = (m_z1 - m_z0)/(float)iclipThickz; + CreateScene(); +} + + +int Scene::Response(int char1) +{ + + int flag; + + flag = 0; + switch(char1) + { + case action_None: + action = action_None; + break; + case action_Object_RotationX: + action = action_Object_RotationX; + break; + case action_Object_RotationY: + action = action_Object_RotationY; + break; + case action_Object_RotationZ: + action = action_Object_RotationZ; + break; + case action_Object_TranslateX: + action = action_Object_TranslateX; + break; + case action_Object_TranslateY: + action = action_Object_TranslateY; + break; + case action_Object_TranslateZ: + action = action_Object_TranslateZ; + break; + case action_Object_Zoom: + action = action_Object_Zoom; + break; + case action_Object_Clipx: + action = action_Object_Clipx; + curclip = 1; + break; + case action_Object_Clipy: + action = action_Object_Clipy; + curclip = 2; + break; + case action_Object_Clipz: + action = action_Object_Clipz; + curclip = 3; + break; + case action_Object_ClipR: + ChangeClipPlane(); + flag = 1; + break; + case action_Object_ClipE: + EnableClipPlane(); + flag = 1; + break; + case action_Object_ClipEP: + EnableClipPlanePair(); + flag = 1; + break; + case action_Object_ClipD: + DisableClipPlane(); + flag = 1; + break; + case action_Object_ClipDP: + DisableClipPlanePair(); + flag = 1; + break; + } + + + if((char1 ==Key_UP)|(char1 ==Key_DOWN)|(char1 ==Key_LEFT)|(char1 ==Key_RIGHT)) + { + switch (action) + { + case action_None: + break; + case action_Object_Select: + break; + case action_Object_RotationX: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { RotateXf(); flag = 1; } + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) {RotateXb(); flag = 1;} + break; + case action_Object_RotationY: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { RotateYf(); flag = 1;} + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) { RotateYb(); flag = 1;} + break; + case action_Object_RotationZ: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { RotateZf(); flag = 1;} + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) { RotateZb(); flag = 1;} + break; + case action_Object_TranslateX: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { TransR(); flag = 1;} + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) { TransL(); flag = 1;} + break; + case action_Object_TranslateY: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { TransU(); flag =1;} + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) { TransD(); flag = 1;} + break; + case action_Object_TranslateZ: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { TransN(); flag =1;} + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) { TransF(); flag = 1;} + break; + case action_Object_Zoom: + if((char1 ==Key_UP)|(char1 ==Key_RIGHT)) { ZoomOut(); flag = 1;} + else if((char1 ==Key_DOWN)|(char1 ==Key_LEFT)) { ZoomIn(); flag = 1;} + break; + case action_Object_Clipx: + case action_Object_Clipy: + case action_Object_Clipz: + switch(char1) + { + case Key_UP: + case Key_RIGHT: + if(MoveClipPlaneP()) flag = 1; + break; + case Key_DOWN: + case Key_LEFT: + if(MoveClipPlaneM()) flag = 1; + break; + } + break; + } + //light[0].Turnon(); + //light[1].Turnon(); + } + return flag; +} + +void Scene::ZoomIn( ) +{ + + float p2; + + /*x0 = x0*zoomPercent; + x1 = x1*zoomPercent; + y0 = y0*zoomPercent; + y1 = y1*zoomPercent; + z0 = z0*zoomPercent; + z1 = z1*zoomPercent; */ + /*p2 = 1.f/zoomPercent; + if(p2 < 1.f) p2 = 1.f/p2; + + glOrtho (-p2, p2, -p2, p2, p2, -p2); + x0 = x0/p2; + x1 = x1/p2; + y0 = y0/p2; + y1 = y1/p2; + z0 = z0/p2; + z1 = z1/p2; */ + + + p2 = m_zoomPercent; + if(p2>1.f) p2 = 1.f/p2; + m_zoomscal = m_zoomscal*p2; + glScalef(p2,p2,p2); + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); + +} + +void Scene::ZoomOut( ) +{ + + float p2; + + /*x0 = x0*zoomPercent; + x1 = x1*zoomPercent; + y0 = y0*zoomPercent; + y1 = y1*zoomPercent; + z0 = z0*zoomPercent; + z1 = z1*zoomPercent; */ + /*p2 = 1.f/zoomPercent; + if(p2 > 1.f) p2 = 1.f/p2; + + glOrtho (-p2, p2, -p2, p2, p2, -p2); + x0 = x0/p2; + x1 = x1/p2; + y0 = y0/p2; + y1 = y1/p2; + z0 = z0/p2; + z1 = z1/p2; */ + + p2 = m_zoomPercent; + if(p2<1.f) p2 = 1.f/p2; + m_zoomscal = m_zoomscal*p2; + glScalef(p2,p2,p2); + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); + +} + +void Scene::GetLabX(float*xl, float*yl, float*zl) +{ + + double len; + double vx[3], vy[3], vz[3]; + double mat[16]; + + //to get current transform matrix + glGetDoublev(GL_MODELVIEW_MATRIX, mat); + + //to transform the coodrinate of atoms to current coordinate + vx[0] = mat[0]; + vx[1] = mat[1]; + vx[2] = mat[2]; + /*len = vx[0]*vx[0]+vx[1]*vx[1]+vx[2]*vx[2]; + len = sqrt(len); + vx[0] = vx[0]/len; + vx[1] = vx[1]/len; + vx[2] = vx[2]/len; + */ + + vy[0] = mat[4]; + vy[1] = mat[5]; + vy[2] = mat[6]; + /*len = vy[0]*vy[0]+vy[1]*vy[1]+vy[2]*vy[2]; + len = sqrt(len); + vy[0] = vy[0]/len; + vy[1] = vy[1]/len; + vy[2] = vy[2]/len; + */ + vz[0] = mat[8]; + vz[1] = mat[9]; + vz[2] = mat[10]; + len = vz[0]*vz[0]+vz[1]*vz[1]+vz[2]*vz[2]; + len = sqrt((double)len); + /*vz[0] = vz[0]/len; + vz[1] = vz[1]/len; + vz[2] = vz[2]/len; + */ + *xl = (float)vx[0]; + *yl = (float)vy[0]; + *zl = (float)vz[0]; + + return; +} + + +void Scene::GetLabY(float*xl, float*yl, float*zl) +{ + + double vx[3], vy[3], vz[3]; + double mat[16]; + + //to get current transform matrix + glGetDoublev(GL_MODELVIEW_MATRIX, mat); + + //to transform the coodrinate of atoms to current coordinate + vx[0] = mat[0]; + vx[1] = mat[1]; + vx[2] = mat[2]; + /* len = vx[0]*vx[0]+vx[1]*vx[1]+vx[2]*vx[2]; + len = sqrt((double)len); + vx[0] = vx[0]/len; + vx[1] = vx[1]/len; + vx[2] = vx[2]/len; + */ + vy[0] = mat[4]; + vy[1] = mat[5]; + vy[2] = mat[6]; + /*len = vy[0]*vy[0]+vy[1]*vy[1]+vy[2]*vy[2]; + len = sqrt((double)len); + vy[0] = vy[0]/len; + vy[1] = vy[1]/len; + vy[2] = vy[2]/len; + */ + vz[0] = mat[8]; + vz[1] = mat[9]; + vz[2] = mat[10]; + /*len = vz[0]*vz[0]+vz[1]*vz[1]+vz[2]*vz[2]; + len = sqrt((double)len); + vz[0] = vz[0]/len; + vz[1] = vz[1]/len; + vz[2] = vz[2]/len; + */ + *xl = (float)vx[1]; + *yl = (float)vy[1]; + *zl = (float)vz[1]; + + return; +} + + +void Scene::GetLabZ(float*xl, float*yl, float*zl) +{ + + double len; + double vx[3], vy[3], vz[3]; + GLdouble mat[16]; + + //to get current transform matrix + glGetDoublev(GL_MODELVIEW_MATRIX, mat); + + //to transform the coodrinate of atoms to current coordinate + vx[0] = mat[0]; + vx[1] = mat[1]; + vx[2] = mat[2]; + len = vx[0]*vx[0]+vx[1]*vx[1]+vx[2]*vx[2]; + len = sqrt((double)len); + vx[0] = vx[0]/len; + vx[1] = vx[1]/len; + vx[2] = vx[2]/len; + + vy[0] = mat[4]; + vy[1] = mat[5]; + vy[2] = mat[6]; + len = vy[0]*vy[0]+vy[1]*vy[1]+vy[2]*vy[2]; + len = sqrt((double)len); + vy[0] = vy[0]/len; + vy[1] = vy[1]/len; + vy[2] = vy[2]/len; + + vz[0] = mat[8]; + vz[1] = mat[9]; + vz[2] = mat[10]; + len = vz[0]*vz[0]+vz[1]*vz[1]+vz[2]*vz[2]; + len = sqrt((double)len); + vz[0] = vz[0]/len; + vz[1] = vz[1]/len; + vz[2] = vz[2]/len; + + *xl = (float)vx[2]; + *yl = (float)vy[2]; + *zl = (float)vz[2]; + + return; +} + + +void Scene::RotateX(float theta) +{ + if(system&scene_System_Labrotary) + { + //to get the lab x axsis in current coordinate + float xo,yo,zo; + + GetLabX(&xo, &yo, &zo); + glTranslatef(m_rotationCx, m_rotationCy, m_rotationCz); + glRotatef(theta, xo, yo, zo); + glTranslatef(-m_rotationCx, -m_rotationCy, -m_rotationCz); + } + else + { + glTranslatef(m_rotationCx, m_rotationCy, m_rotationCz); + glRotatef(theta, 1.f, 0.f, 0.f); + glTranslatef(-m_rotationCx, -m_rotationCy, -m_rotationCz); + } + + + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); + + +} + +void Scene::RotateXf() +{ + RotateX(m_rotationStepx); +} +void Scene::RotateXb() +{ + RotateX(-m_rotationStepx); +} + +void Scene::RotateY(float theta) +{ + + if(system&scene_System_Labrotary) + { + //to get the lab y axsis in current coordinate + float xo,yo,zo; + + GetLabY(&xo, &yo, &zo); + glTranslatef(m_rotationCx, m_rotationCy, m_rotationCz); + glRotatef(theta, xo, yo, zo); + glTranslatef(-m_rotationCx, -m_rotationCy, -m_rotationCz); + } + else + { + glTranslatef(m_rotationCx, m_rotationCy, m_rotationCz); + glRotatef(theta, 0.f, 1.f, 0.f); + glTranslatef(-m_rotationCx, -m_rotationCy, -m_rotationCz); + } + + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); +} + +void Scene::RotateYf() +{ + RotateY(m_rotationStepy); + +} + +void Scene::RotateYb() +{ + RotateY(-m_rotationStepy); + +} + +void Scene::RotateZ(float theta) +{ + if(system&scene_System_Labrotary) + { + //to get the lab z axsis in current coordinate + float xo,yo,zo; + + GetLabZ(&xo, &yo, &zo); + glTranslatef(m_rotationCx, m_rotationCy, m_rotationCz); + glRotatef(theta, xo, yo, zo); + glTranslatef(-m_rotationCx, -m_rotationCy, -m_rotationCz); + + } + else + { + glTranslatef(m_rotationCx, m_rotationCy, m_rotationCz); + glRotatef(theta, 0.f, 0.f, 1.f); + glTranslatef(-m_rotationCx, -m_rotationCy, -m_rotationCz); + } + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); +} + +void Scene::RotateZf() +{ + RotateZ(m_rotationStepz); + +} + +void Scene::RotateZb() +{ + RotateZ(-m_rotationStepz); + +} + + +void Scene::TransL(float d) +{ + + float xo,yo,zo,len; + + if(system&scene_System_Labrotary) + { + //to get the lab x axsis in current coordinate + GetLabX(&xo, &yo, &zo); + } + else + { + xo = 1.f; + yo = 0.f; + zo = 0.f; + } + + len = xo*xo+yo*yo+zo*zo; + len = (float)sqrt((double)len); + len = -d/len; + xo = len*xo; + yo = len*yo; + zo = len*zo; + glTranslatef(xo, yo, zo); + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); + +} + +void Scene::TransL() +{ + TransL((float)(m_x1 - m_x0)/(float)m_itransStepx); +} + +void Scene::TransR(float d) +{ + TransL(-d); +} + +void Scene::TransR() +{ + TransR((float)(m_x1 - m_x0)/(float)m_itransStepx); +} + +void Scene::TransU(float d) +{ + + float xo,yo,zo,len; + + //to get the lab x axsis in current coordinate + if(system&scene_System_Labrotary) + { + //to get the lab x axsis in current coordinate + GetLabY(&xo, &yo, &zo); + } + else + { + xo = 0.f; + yo = 1.f; + zo = 0.f; + } + len = xo*xo+yo*yo+zo*zo; + len = (float)sqrt((double)len); + len = d/len; + xo = len*xo; + yo = len*yo; + zo = len*zo; + glTranslatef(xo, yo, zo); + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); +} + +void Scene::TransU() +{ + TransU((float)(m_y1 - m_y0)/(float)m_itransStepy); +} + +void Scene::TransD(float d) +{ + TransU(-d); +} + +void Scene::TransD() +{ + TransD((float)(m_y1 - m_y0)/(float)m_itransStepy); +} + +void Scene::TransN(float d) +{ + + float xo,yo,zo,len; + + if(system&scene_System_Labrotary) + { + //to get the lab x axsis in current coordinate + GetLabZ(&xo, &yo, &zo); + } + else + { + xo = 0.f; + yo = 0.f; + zo = 1.f; + } + + len = xo*xo+yo*yo+zo*zo; + len = (float)sqrt((double)len); + len = -d/len; + xo = len*xo; + yo = len*yo; + zo = len*zo; + glTranslatef(xo, yo, zo); + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); + +} + +void Scene::TransN() +{ + TransN((float)(m_z1 - m_z0)/(float)m_itransStepz); +} + +void Scene::TransF(float d) +{ + TransN(-d); +} + +void Scene::TransF() +{ + TransF((float)(m_z1 - m_z0)/(float)m_itransStepz); +} + + +// the function concerning clip planes +void Scene::EnableClipPlanePair() +{ + switch (curclip) + { + case 1: + clipState[0]=clipState[0]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE0, clip1); + glEnable(GL_CLIP_PLANE0); + clipState[3]=clipState[3]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE3, clip1p); + glEnable(GL_CLIP_PLANE3); + break; + case 2: + clipState[1]=clipState[1]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE1, clip2); + glEnable(GL_CLIP_PLANE1); + clipState[4]=clipState[4]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE4, clip2p); + glEnable(GL_CLIP_PLANE4); + break; + case 3: + clipState[2]=clipState[2]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE2, clip3); + glEnable(GL_CLIP_PLANE2); + clipState[5]=clipState[5]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE5, clip3p); + glEnable(GL_CLIP_PLANE5); + break; + } +} + +void Scene::EnableClipPlane() +{ + switch (curclip) + { + case 1: + clipState[0]=clipState[0]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE0, clip1); + glEnable(GL_CLIP_PLANE0); + break; + case 2: + clipState[1]=clipState[1]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE1, clip2); + glEnable(GL_CLIP_PLANE1); + break; + case 3: + clipState[2]=clipState[2]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE2, clip3); + glEnable(GL_CLIP_PLANE2); + break; + case 4: + clipState[3]=clipState[3]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE3, clip1p); + glEnable(GL_CLIP_PLANE3); + break; + case 5: + clipState[4]=clipState[4]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE4, clip2p); + glEnable(GL_CLIP_PLANE5); + break; + case 6: + clipState[5]=clipState[5]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE5, clip3p); + glEnable(GL_CLIP_PLANE5); + break; + } +} + + +void Scene::DisableClipPlane() +{ + int i; + switch (curclip) + { + case 1: + i = clipState[0]>>1; + clipState[0] = i<<1; + glDisable(GL_CLIP_PLANE0); + break; + case 2: + i = clipState[1]>>1; + clipState[1] = i<<1; + glDisable(GL_CLIP_PLANE1); + break; + case 3: + i = clipState[2]>>1; + clipState[2] = i<<1; + glDisable(GL_CLIP_PLANE2); + break; + case 4: + i = clipState[3]>>1; + clipState[3] = i<<1; + glDisable(GL_CLIP_PLANE3); + break; + case 5: + i = clipState[4]>>1; + clipState[4] = i<<1; + glDisable(GL_CLIP_PLANE4); + break; + case 6: + i = clipState[5]>>1; + clipState[5] = i<<1; + glDisable(GL_CLIP_PLANE5); + break; + } +} + +void Scene::DisableClipPlanePair() +{ + int i; + switch (curclip) + { + case 1: + i = clipState[0]>>1; + clipState[0] = i<<1; + glDisable(GL_CLIP_PLANE0); + i = clipState[3]>>1; + clipState[3] = i<<1; + glDisable(GL_CLIP_PLANE3); + break; + break; + case 2: + i = clipState[1]>>1; + clipState[1] = i<<1; + glDisable(GL_CLIP_PLANE1); + i = clipState[4]>>1; + clipState[4] = i<<1; + glDisable(GL_CLIP_PLANE4); + break; + break; + case 3: + i = clipState[2]>>1; + clipState[2] = i<<1; + glDisable(GL_CLIP_PLANE2); + i = clipState[5]>>1; + clipState[5] = i<<1; + glDisable(GL_CLIP_PLANE5); + break; + } +} + + +int Scene::IsClipPlaneEnabled(int id) +{ + int i=0; + switch (id) + { + case 1: + if(clipState[0]&clip_State_Enabled) i++; + if(clipState[3]&clip_State_Enabled) i++; + break; + case 2: + if(clipState[1]&clip_State_Enabled) i++; + if(clipState[4]&clip_State_Enabled) i++; + break; + case 3: + if(clipState[2]&clip_State_Enabled) i++; + if(clipState[5]&clip_State_Enabled) i++; + break; + case 4: + if(clipState[0]&clip_State_Enabled) i++; + if(clipState[3]&clip_State_Enabled) i++; + break; + case 5: + if(clipState[1]&clip_State_Enabled) i++; + if(clipState[4]&clip_State_Enabled) i++; + break; + case 6: + if(clipState[2]&clip_State_Enabled) i++; + if(clipState[5]&clip_State_Enabled) i++; + break; + } + return i; +} + +int Scene::IsClipPlaneEnabled() +{ + int i; + + for(i=1; i<7; i++) + if(IsClipPlaneEnabled(i) > 0) return IsClipPlaneEnabled(i); + return 0; +} + + +int Scene::IsCurrentClipPlaneEnabled() +{ + return IsClipPlaneEnabled(curclip); +} + + +int Scene::MoveClipPlaneP() +{ + int i=0; + float d; + + switch (curclip) + { + case 1: + if( (clipState[0]&clip_State_Enabled)||clipState[3]&clip_State_Enabled ) + { + d = (m_x1 - m_x0)/(float)iclipStepx; + clip1[3]=clip1[3]+d; + clip1p[3]=clip1p[3]-d; + //if(clip1[3]>x1)clip1[3]=x1; + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE3, clip1p); + i = clipState[0]&clip_State_Enabled; + i = clipState[3]&clip_State_Enabled; + if(clipState[0]&clip_State_Enabled) glEnable(GL_CLIP_PLANE0); + if(clipState[3]&clip_State_Enabled) glEnable(GL_CLIP_PLANE3); + i = 1; + } + break; + case 2: + if( (clipState[1]&clip_State_Enabled)||(clipState[4]&clip_State_Enabled)) + { + d = (m_y1 - m_y0)/(float)iclipStepy; + clip2[3]=clip2[3]+d; + clip2p[3]=clip2p[3]-d; + //if(clip2[3]>y1)clip2[3]=y1; + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE4, clip2p); + if(clipState[1]&clip_State_Enabled) glEnable(GL_CLIP_PLANE1); + if(clipState[4]&clip_State_Enabled) glEnable(GL_CLIP_PLANE4); + i = 1; + } + break; + case 3: + if( (clipState[2]&clip_State_Enabled) ||(clipState[5]&clip_State_Enabled)) + { + d = (m_z1 - m_z0)/(float)iclipStepz; + clip3[3]=clip3[3]+d; + clip3p[3]=clip3p[3]-d; + //if(clip3[3]>z1)clip3[3]=z1; + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE5, clip3p); + if(clipState[2]&clip_State_Enabled) glEnable(GL_CLIP_PLANE2); + if(clipState[5]&clip_State_Enabled) glEnable(GL_CLIP_PLANE5); + i = 1; + } + break; + } + return i; +} + +int Scene::MoveClipPlaneM() +{ + int i=0; + float d; + + switch (curclip) + { + case 1: + if( (clipState[0]&clip_State_Enabled)||clipState[3]&clip_State_Enabled ) + { + d = -(m_x1 - m_x0)/(float)iclipStepx; + clip1[3]=clip1[3]+d; + clip1p[3]=clip1p[3]-d; + //if(clip1[3]>x1)clip1[3]=x1; + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE3, clip1p); + if(clipState[0]&clip_State_Enabled) glEnable(GL_CLIP_PLANE0); + if(clipState[3]&clip_State_Enabled) glEnable(GL_CLIP_PLANE3); + i = 1; + } + break; + case 2: + if( (clipState[1]&clip_State_Enabled)||(clipState[4]&clip_State_Enabled)) + { + d = -(m_y1 - m_y0)/(float)iclipStepy; + clip2[3]=clip2[3]+d; + clip2p[3]=clip2p[3]-d; + //if(clip2[3]>y1)clip2[3]=y1; + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE4, clip2p); + if(clipState[1]&clip_State_Enabled) glEnable(GL_CLIP_PLANE1); + if(clipState[4]&clip_State_Enabled) glEnable(GL_CLIP_PLANE4); + i = 1; + } + break; + case 3: + if( (clipState[2]&clip_State_Enabled) ||(clipState[5]&clip_State_Enabled)) + { + d = -(m_z1 - m_z0)/(float)iclipStepz; + clip3[3]=clip3[3]+d; + clip3p[3]=clip3p[3]-d; + //if(clip3[3]>z1)clip3[3]=z1; + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE5, clip3p); + if(clipState[2]&clip_State_Enabled) glEnable(GL_CLIP_PLANE2); + if(clipState[5]&clip_State_Enabled) glEnable(GL_CLIP_PLANE5); + i = 1; + } + break; + } + return i; +} + + +int Scene::ChangeClipPlane() +{ + int i=0; + + switch (curclip) + { + case 1: + if( (clipState[0]&clip_State_Enabled)&&(clipState[3]&clip_State_Enabled)) return i; + if( clipState[0]&clip_State_Enabled) + { + i = clipState[0] >>1; + clipState[0] = i<<1; + clipState[3] = clipState[3]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glDisable(GL_CLIP_PLANE0); + glEnable(GL_CLIP_PLANE3); + i = 1; + break; + } + if( clipState[3]&clip_State_Enabled) + { + i = clipState[3] >>1; + clipState[3] = i<<1; + clipState[0] = clipState[0]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glDisable(GL_CLIP_PLANE3); + glEnable(GL_CLIP_PLANE0); + i = 1; + break; + } + break; + case 2: + if( (clipState[1]&clip_State_Enabled)&&(clipState[4]&clip_State_Enabled)) return i; + if( clipState[1]&clip_State_Enabled) + { + i = clipState[1] >>1; + clipState[1] = i<<1; + clipState[4] = clipState[4]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glDisable(GL_CLIP_PLANE1); + glEnable(GL_CLIP_PLANE4); + i = 1; + break; + } + if( clipState[4]&clip_State_Enabled) + { + i = clipState[4] >>1; + clipState[4] = i<<1; + clipState[1] = clipState[1]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glDisable(GL_CLIP_PLANE4); + glEnable(GL_CLIP_PLANE1); + i = 1; + break; + } + break; + case 3: + if( (clipState[2]&clip_State_Enabled)&&(clipState[5]&clip_State_Enabled)) return i; + if( clipState[2]&clip_State_Enabled) + { + i = clipState[2] >>1; + clipState[2] = i<<1; + clipState[5] = clipState[5]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE5, clip3p); + glDisable(GL_CLIP_PLANE2); + glEnable(GL_CLIP_PLANE5); + i = 1; + break; + } + if( clipState[5]&clip_State_Enabled) + { + i = clipState[5] >>1; + clipState[5] = i<<1; + clipState[2] = clipState[2]|clip_State_Enabled; + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE5, clip3p); + glDisable(GL_CLIP_PLANE5); + glEnable(GL_CLIP_PLANE2); + i = 1; + break; + } + break; + + } + return i; +} + +void Scene::ChangeClipPairThickx(float iclipThick) +{ + int i=0; + + double od = (m_x1 - m_x0)/(float)iclipThickx; + double nd = (m_x1 - m_x0)/(float)iclipThick; + + clip1p[3]=clip1p[3]+(nd-od); + iclipThickx = iclipThick; +} + +void Scene::ChangeClipPairThicky(float iclipThick) +{ + int i=0; + + double od = (m_y1 - m_y0)/(float)iclipThicky; + double nd = (m_y1 - m_y0)/(float)iclipThick; + + clip2p[3]=clip2p[3]+(nd-od); + iclipThicky = iclipThick; +} + +void Scene::ChangeClipPairThickz(float iclipThick) +{ + int i=0; + + double od = (m_z1 - m_z0)/(float)iclipThickz; + double nd = (m_z1 - m_z0)/(float)iclipThick; + + clip3p[3]=clip3p[3]+(nd-od); + iclipThickz = iclipThick; +} + +void Scene::TurnLighton(int n) +{ + if(n>3) return; + switch(n) + { + case 1: + light1->Turnon(); + break; + case 2: + light2->Turnon(); + break; + case 3: + light3->Turnon(); + break; + } +} + +void Scene::TurnLightoff(int n) +{ + if(n>3) return; + switch (n) + { + case 1: + light1->Turnoff(); + break; + case 2: + light2->Turnoff(); + break; + case 3: + light3->Turnoff(); + break; + } + +} + +void Scene::ChangeLightColorA(int n, float R, float G, float B) +{ + if(n>3) return; + switch (n) + { + case 1: + light1->ChangeColorA(R,G,B); + break; + case 2: + light2->ChangeColorA(R,G,B); + break; + case 3: + light3->ChangeColorA(R,G,B); + break; + } +} + +void Scene::ChangeLightColorD(int n, float R, float G, float B) +{ + if(n>3) return; + switch (n) + { + case 1: + light1->ChangeColorD(R,G,B); + break; + case 2: + light2->ChangeColorD(R,G,B); + break; + case 3: + light3->ChangeColorD(R,G,B); + break; + } +} + +void Scene::ChangeLightColorS(int n, float R, float G, float B) +{ + if(n>3) return; + switch (n) + { + case 1: + light1->ChangeColorS(R,G,B); + break; + case 2: + light2->ChangeColorS(R,G,B); + break; + case 3: + light3->ChangeColorS(R,G,B); + break; + } +} + + +void Scene::ChangeLightPosition(int n, float x, float y, float z) +{ + if(n>3) return; + switch (n) + { + case 1: + light1->ChangePosition(x,y,z); + break; + case 2: + light2->ChangePosition(x,y,z); + break; + case 3: + light3->ChangePosition(x,y,z); + break; + } +} + + +void Scene::Paint() +{ + Style Sty; + Sty.TranspSolid(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glLineWidth(this->m_borderthick); + + //if(style&scene_Style_ShowVolume) +/* if(this->m_showbox) + { + + glBegin(GL_LINES); + //glColor4f(0.8f, 0.40f,0.4f,0.6f); + glColor4f(1.f, 0.f, 0.f, 0.6f); + glVertex3d(m_x0*0.995f, m_y0*0.995f, m_z0*0.995f); + glVertex3d(m_x1*0.995f, m_y0*0.995f, m_z0*0.995f); + glVertex3d(m_x0*0.995f, m_y1*0.995f, m_z0*0.995f); + glVertex3d(m_x1*0.995f, m_y1*0.995f, m_z0*0.995f); + glVertex3d(m_x0*0.995f, m_y0*0.995f, m_z1*0.995f); + glVertex3d(m_x1*0.995f, m_y0*0.995f, m_z1*0.995f); + glVertex3d(m_x0*0.995f, m_y1*0.995f, m_z1*0.995f); + glVertex3d(m_x1*0.995f, m_y1*0.995f, m_z1*0.995f); + + //glColor4f(0.4f, 0.80f,0.40f,0.6f); + glColor4f(0.f, 1.f, 0.f, 0.6f); + glVertex3d(m_x0*0.995f, m_y0*0.995f, m_z0*0.995f); + glVertex3d(m_x0*0.995f, m_y1*0.995f, m_z0*0.995f); + glVertex3d(m_x1*0.995f, m_y0*0.995f, m_z0*0.995f); + glVertex3d(m_x1*0.995f, m_y1*0.995f, m_z0*0.995f); + glVertex3d(m_x0*0.995f, m_y0*0.995f, m_z1*0.995f); + glVertex3d(m_x0*0.995f, m_y1*0.995f, m_z1*0.995f); + glVertex3d(m_x1*0.995f, m_y0*0.995f, m_z1*0.995f); + glVertex3d(m_x1*0.995f, m_y1*0.995f, m_z1*0.995f); + + + //glColor4f(0.4f, 0.4f,0.8f,0.6f); + glColor4f(0.f, 0.f, 1.f, 0.6f); + glVertex3d(m_x0*0.995f, m_y0*0.995f, m_z0*0.995f); + glVertex3d(m_x0*0.995f, m_y0*0.995f, m_z1*0.995f); + glVertex3d(m_x1*0.995f, m_y0*0.995f, m_z0*0.995f); + glVertex3d(m_x1*0.995f, m_y0*0.995f, m_z1*0.995f); + glVertex3d(m_x0*0.995f, m_y1*0.995f, m_z0*0.995f); + glVertex3d(m_x0*0.995f, m_y1*0.995f, m_z1*0.995f); + glVertex3d(m_x1*0.995f, m_y1*0.995f, m_z0*0.995f); + glVertex3d(m_x1*0.995f, m_y1*0.995f, m_z1*0.995f); + + glEnd(); + }*/ + + if(this->m_showbackface[0]) + { + if (m_showbackface[0] & 1) + { + glBegin(GL_LINES); + glColor4f(0.f, 1.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x0, m_y1, m_z1); + + glColor4f(0.f, 0.f, 1.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x0, m_y1, m_z1); + glEnd(); + } + } + + if(this->m_showfrontface[0]) + { + if (m_showfrontface[0] & 1) + { + glBegin(GL_LINES); + glColor4f(0.f, 1.f, 0.f, 0.6f); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x1, m_y1, m_z0); + glVertex3d(m_x1, m_y0, m_z1); + glVertex3d(m_x1, m_y1, m_z1); + + glColor4f(0.f, 0.f, 1.f, 0.6f); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x1, m_y0, m_z1); + glVertex3d(m_x1, m_y1, m_z0); + glVertex3d(m_x1, m_y1, m_z1); + glEnd(); + + } + } + + if(this->m_showbackface[1]) + { + if (m_showbackface[1] & 1) + { + glBegin(GL_LINES); + glColor4f(0.f, 0.f, 1.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x1, m_y0, m_z1); + + glColor4f(1.f, 0.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x1, m_y0, m_z1); + glEnd(); + + } + } + if(this->m_showfrontface[1]) + { + if (m_showfrontface[1] & 1) + { + glBegin(GL_LINES); + glColor4f(0.f, 0.f, 1.f, 0.6f); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x0, m_y1, m_z1); + glVertex3d(m_x1, m_y1, m_z0); + glVertex3d(m_x1, m_y1, m_z1); + + glColor4f(1.f, 0.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x1, m_y1, m_z0); + glVertex3d(m_x0, m_y1, m_z1); + glVertex3d(m_x1, m_y1, m_z1); + glEnd(); + } + } + if(this->m_showbackface[2]) + { + if (this->m_showbackface[2] & 1) + { + glBegin(GL_LINES); + glColor4f(1.f, 0.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x1, m_y1, m_z0); + + glColor4f(0.f, 1.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x1, m_y1, m_z0); + glEnd(); + + } + } + + if(this->m_showfrontface[2]) + { + if (this->m_showfrontface[2] & 1) + { + glBegin(GL_LINES); + glColor4f(1.f, 0.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x1, m_y0, m_z1); + glVertex3d(m_x0, m_y1, m_z1); + glVertex3d(m_x1, m_y1, m_z1); + + glColor4f(0.f, 1.f, 0.f, 0.6f); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x0, m_y1, m_z1); + glVertex3d(m_x1, m_y0, m_z1); + glVertex3d(m_x1, m_y1, m_z1); + glEnd(); + } + } + + if (m_showbackface[0] & 2) + { + glColor4f(1.f, 0.0f, 0.0f, 0.1f); + glBegin(GL_POLYGON); + glNormal3d(-1.0, 0.0, 0.0); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x0, m_y1, m_z1); + glVertex3d(m_x0, m_y0, m_z1); + glEnd(); + } + if (m_showbackface[1] & 2) + { + glColor4f(0.0f, 1.0f, 0.0f, 0.1f); + glBegin(GL_POLYGON); + glNormal3d(0.0, -1.0, 0.0); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x1, m_y0, m_z1); + glVertex3d(m_x1, m_y0, m_z0); + glEnd(); + } + if (this->m_showbackface[2] & 2) + { + glColor4f(0.0f, 0.0f, 1.0f, 0.1f); + glBegin(GL_POLYGON); + glNormal3d(0.0, 0.0, -1.0); + glVertex3d(m_x0, m_y0, m_z0); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x1, m_y1, m_z0); + glVertex3d(m_x0, m_y1, m_z0); + glEnd(); + } + if (m_showfrontface[0] & 2) + { + glColor4f(1.f, 0.0f, 0.0f, 0.1f); + glBegin(GL_POLYGON); + glNormal3d(1.0, 0.0, 0.0); + glVertex3d(m_x1, m_y0, m_z0); + glVertex3d(m_x1, m_y1, m_z0); + glVertex3d(m_x1, m_y1, m_z1); + glVertex3d(m_x1, m_y0, m_z1); + glEnd(); + } + if (m_showfrontface[1] & 2) + { + glColor4f(0.0f, 1.0f, 0.0f, 0.1f); + glBegin(GL_POLYGON); + glNormal3d(0.0, 1.0, 0.0); + glVertex3d(m_x0, m_y1, m_z0); + glVertex3d(m_x0, m_y1, m_z1); + glVertex3d(m_x1, m_y1, m_z1); + glVertex3d(m_x1, m_y1, m_z0); + glEnd(); + } + if (this->m_showfrontface[2] & 2) + { + glColor4f(0.0f, 0.0f, 1.0f, 0.1f); + glBegin(GL_POLYGON); + glNormal3d(0.0, 0.0, 1.0); + glVertex3d(m_x0, m_y0, m_z1); + glVertex3d(m_x1, m_y0, m_z1); + glVertex3d(m_x1, m_y1, m_z1); + glVertex3d(m_x0, m_y1, m_z1); + glEnd(); + } + + + PaintClipPlane(); + glDisable(GL_BLEND); + +} + +void Scene::PaintClipPlane() +{ + // to draw clipplane if they are enabled and shown + float d; + + glColor4f(0.8f, 0.4f,0.4f,0.6f); + if( (clipState[0]&clip_State_Enabled)&&(clipState[0]&clip_State_Shown) ) + { + if(clip1[0]>0) d = -clip1[3]*0.995f; + else d = clip1[3]*0.995f; + glBegin(GL_LINE_LOOP); + glVertex3d(d, m_y0*0.995f, m_z0*0.995f); + glVertex3d(d, m_y1*0.995f, m_z0*0.995f); + glVertex3d(d, m_y1*0.995f, m_z1*0.995f); + glVertex3d(d, m_y0*0.995f, m_z1*0.995f); + glEnd(); + if(clipState[3]&clip_State_Enabled) + { + if(clip1p[0]>0) d = -clip1p[3]*0.995f; + else d = clip1p[3]*0.995f; + glBegin(GL_LINE_LOOP); + glVertex3d(d, m_y0*0.995f, m_z0*0.995f); + glVertex3d(d, m_y1*0.995f, m_z0*0.995f); + glVertex3d(d, m_y1*0.995f, m_z1*0.995f); + glVertex3d(d, m_y0*0.995f, m_z1*0.995f); + glEnd(); + + } + } + + glColor4f(0.4f, 0.8f,0.4f,0.6f); + if( (clipState[1]&clip_State_Enabled)&&(clipState[1]&clip_State_Shown) ) + { + if(clip2[1]>0) d = -clip2[3]*0.995f; + else d = clip2[3]*0.995f; + glBegin(GL_LINE_LOOP); + glVertex3d(m_x0*0.995f, d, m_z0*0.995f); + glVertex3d(m_x1*0.995f, d, m_z0*0.995f); + glVertex3d(m_x1*0.995f, d, m_z1*0.995f); + glVertex3d(m_x0*0.995f, d, m_z1*0.995f); + glEnd(); + if (clipState[4]&clip_State_Enabled) + { + if(clip2p[1]>0) d = -clip2p[3]*0.995f; + else d = clip2p[3]*0.995f; + glBegin(GL_LINE_LOOP); + glVertex3d(m_x0*0.995f, d, m_z0*0.995f); + glVertex3d(m_x1*0.995f, d, m_z0*0.995f); + glVertex3d(m_x1*0.995f, d, m_z1*0.995f); + glVertex3d(m_x0*0.995f, d, m_z1*0.995f); + glEnd(); + } + + } + + glColor4f(0.4f, 0.4f,0.8f,0.6f); + if( (clipState[2]&clip_State_Enabled)&&(clipState[2]&clip_State_Shown) ) + { + if(clip3[2]>0) d = -clip3[3]*0.995f; + else d = clip3[3]*0.995f; + glBegin(GL_LINE_LOOP); + glVertex3d(m_x0*0.995f, m_y0*0.995f, d); + glVertex3d(m_x1*0.995f, m_y0*0.995f, d); + glVertex3d(m_x1*0.995f, m_y1*0.995f, d); + glVertex3d(m_x0*0.995f, m_y1*0.995f, d); + glEnd(); + if(clipState[5]&clip_State_Enabled) + { + if(clip3[2]>0) d = -clip3p[3]*0.995f; + else d = clip3p[3]*0.995f; + glBegin(GL_LINE_LOOP); + glVertex3d(m_x0*0.995f, m_y0*0.995f, d); + glVertex3d(m_x1*0.995f, m_y0*0.995f, d); + glVertex3d(m_x1*0.995f, m_y1*0.995f, d); + glVertex3d(m_x0*0.995f, m_y1*0.995f, d); + glEnd(); + } + } +} + +void Scene::SetClipPlaneShown(int id) +{ + + switch (id) + { + case 1: + clipState[0]= clipState[0]|clip_State_Shown; + break; + case 2: + clipState[1]= clipState[1]|clip_State_Shown; + break; + case 3: + clipState[2]= clipState[2]|clip_State_Shown; + break; + } +} + + +int Scene::IfClipPlaneVisiable(int id) +{ + + int i = id-1; + return (clipState[i]&clip_State_Shown); +} + + +void Scene::SetClipPlaneHiden(int id) +{ + switch (id) + { + case 1: + clipState[0] = clipState[0]&clip_State_Enabled; + break; + case 2: + clipState[1] = clipState[1]&clip_State_Enabled; + break; + case 3: + clipState[2] = clipState[2]&clip_State_Enabled; + break; + } +} + + +void Scene::SetVolumeShown() +{ + + style = style|scene_Style_ShowVolume; +} + +void Scene::SetVolumeHiden() +{ + int I = style&scene_Style_Perspective; + style = I; +} + +void Scene::SetAsPerspective() +{ + style = style|scene_Style_Perspective; +} + + +void Scene::SetAsOrtho() +{ + style = style&scene_Style_ShowVolume; +} + +void Scene::Save(FILE*pFile) +{ + + fprintf(pFile, "x0 = %f\n",m_x0); + fprintf(pFile, "y0 = %f\n",m_y0); + fprintf(pFile, "z0 = %f\n",m_z0); + fprintf(pFile, "x1 = %f\n",m_x1); + fprintf(pFile, "y1 = %f\n",m_y1); + fprintf(pFile, "z1 = %f\n",m_z1); + + fprintf(pFile, "zoom percentage= %f\n",m_zoomPercent); + fprintf(pFile, "Rotation step along x axsis = %f\n",m_rotationStepx); + fprintf(pFile, "Rotation step along y axsis = %f\n",m_rotationStepy); + fprintf(pFile, "Rotation step along z axsis = %f\n",m_rotationStepz); + + fprintf(pFile, "Translate step horizontally = %f\n",m_itransStepx); + fprintf(pFile, "Translation step vertically = %f\n",m_itransStepy); + + fprintf(pFile, "Clipplane move step along x = %f\n",iclipStepx); + fprintf(pFile, "Clipplane move step along y = %f\n",iclipStepy); + fprintf(pFile, "Clipplane move step along z = %f\n",iclipStepz); + + fprintf(pFile, "Clipplane pair thick along x = %f\n",iclipThickx); + fprintf(pFile, "Clipplane pair thick along y = %f\n",iclipThicky); + fprintf(pFile, "Clipplane pair thick along z = %f\n",iclipThickz); +} + + +#define slen 80 +void Scene::Read(FILE*pFile) +{ + + char str[slen], nstr[slen]; + int c, i,j, len; + + + // to get X0 + for(i=0; im_rotationCx; + float dy = newy - this->m_rotationCy; + float dz = newz - this->m_rotationCz; + + glTranslatef(dx, dy, dz); + glClipPlane(GL_CLIP_PLANE0, clip1); + glClipPlane(GL_CLIP_PLANE1, clip2); + glClipPlane(GL_CLIP_PLANE2, clip3); + glClipPlane(GL_CLIP_PLANE3, clip1p); + glClipPlane(GL_CLIP_PLANE4, clip2p); + glClipPlane(GL_CLIP_PLANE5, clip3p); + + this->m_rotationCx = newx; + this->m_rotationCy = newy; + this->m_rotationCz = newz; + return; +} \ No newline at end of file diff --git a/GLLIBSRC/Scene.h b/GLLIBSRC/Scene.h new file mode 100644 index 0000000..9b8c103 --- /dev/null +++ b/GLLIBSRC/Scene.h @@ -0,0 +1,249 @@ + +#ifndef _SCENE +#define _SCENE +#include "Light.h" + +#define action_None 0 +#define action_Object_Select 1 +#define action_Object_RotationX 2001 +#define action_Object_RotationY 2010 +#define action_Object_RotationZ 2100 +#define action_Object_Translate 3 +#define action_Object_TranslateX 3001 +#define action_Object_TranslateY 3010 +#define action_Object_TranslateZ 3100 +#define action_Object_Zoom 4 +#define action_Object_Zoomin 4001 +#define action_Object_Zoomout 4002 +#define action_Object_ClipE 61 +#define action_Object_ClipD 62 +#define action_Object_ClipEP 612 +#define action_Object_ClipDP 622 +#define action_Object_Clipx 6001 +#define action_Object_Clipy 6010 +#define action_Object_Clipz 6100 +#define action_Object_ClipR 6111 +#define action_Object_Light 7 +#define action_Object_Light1 7001 +#define action_Object_Light2 7002 +#define action_Object_Light3 7003 + +#define clip_State_Enabled 1 +#define clip_State_Shown 2 + +#define scene_Style_ShowNone 0 +#define scene_Style_ShowVolume 1 +#define scene_Style_Perspective 2 + +#define scene_Update_Automatic 0 +#define scene_Update_ByRequire 1 + +#define scene_System_Relative 0 +#define scene_System_Labrotary 1 + + +#define Key_LEFT 0x25 +#define Key_UP 0x26 +#define Key_RIGHT 0x27 +#define Key_DOWN 0x28 + + +class Scene:public GlcObj +{ + private: + protected: + int m_viewportx0, m_viewporty0, m_viewportw, m_viewporth; + double m_x0, m_x1, m_y0, m_y1, m_z0, m_z1, m_dist; + int action; + int style; + int update; + int system; + float m_zoomPercent, m_zoomscal; + float m_rotationStepx, m_rotationStepy, m_rotationStepz; + float m_rotationCx, m_rotationCy, m_rotationCz; //center for rotation + float m_itransStepx, m_itransStepy, m_itransStepz; + float m_itransX, m_itransY, m_itransZ; + float iclipStepx, iclipStepy, iclipStepz; + float iclipThickx, iclipThicky, iclipThickz; + double clip1[4],clip2[4],clip3[4]; + double clip1p[4],clip2p[4],clip3p[4]; + int clipState[6], curclip; + + Light*light1, *light2, *light3; + int curlight; + + //Display property + int m_showbox, m_showbackface[3],m_showfrontface[3]; + float m_borderthick, m_backfaceopacity[3]; + public: + void ShowBoxBorder(bool show=true){m_showbox = show;} + bool IsShowBoxborder(){ return m_showbox;} + + void ShowBackfaceX(int show){ m_showbackface[0] = show;} + int IsShowBackfaceX(){ return m_showbackface[0];} + void ShowBackfaceY(int show){ m_showbackface[1] = show;} + int IsShowBackfaceY(){ return m_showbackface[1];} + void ShowBackfaceZ(int show){ m_showbackface[2] = show;} + int IsShowBackfaceZ(){ return m_showbackface[2];} + void ShowAllBackfaces(int show){m_showbackface[0]=m_showbackface[1]=m_showbackface[2]=show;} + + + void ShowFrontfaceX(int show){ m_showfrontface[0] = show;} + int IsShowFrontfaceX(){ return m_showfrontface[0];} + void ShowFrontfaceY(int show){ m_showfrontface[1] = show;} + int IsShowFrontfaceY(){ return m_showfrontface[1];} + void ShowFrontfaceZ(int show){ m_showfrontface[2] = show;} + int IsShowFrontfaceZ(){ return m_showfrontface[2];} + void ShowAllFrontfaces(int show){m_showfrontface[0]=m_showfrontface[1]=m_showfrontface[2]=show;} + + public: + Scene(); + Scene(float left, float right, float bottom, float top, float nearz, float farz, float dist=0); + ~Scene(); + + void SetViewport( int x0, int y0, int w, int h) + { + m_viewportx0 = x0; m_viewporty0 = y0; + m_viewportw = w; m_viewporth = h; + } + + void GetViewport( int&x0, int&y0, int&w, int&h) + { + x0 = m_viewportx0; y0 = m_viewporty0; + w = m_viewportw; h = m_viewporth; + } + + void MakeCurrent() + { + glViewport(m_viewportx0, m_viewporty0, m_viewportw, m_viewporth); + } + + void CreateScene(); + void CreateScene(float left, float right, float bottom, float top, float nearz, float farz, float dist=0); + int GetStyle(){ return style;}; + float GetVolumeX0(){ return (float)m_x0;}; + float GetVolumeY0(){ return (float)m_y0;}; + float GetVolumeZ0(){ return (float)m_z0;}; + float GetVolumeX1(){ return (float)m_x1;}; + float GetVolumeY1(){ return (float)m_y1;}; + float GetVolumeZ1(){ return (float)m_z1;}; + void SetVolumeX0(float X0){ m_x0 = X0;}; + void SetVolumeX1(float X1){ m_x1 = X1;}; + void SetVolumeY0(float Y0){ m_y0 = Y0;}; + void SetVolumeY1(float Y1){ m_y1 = Y1;}; + void SetVolumeZ0(float Z0){ m_z0 = Z0;}; + void SetVolumeZ1(float Z1){ m_z1 = Z1;}; + float GetDistance(){ return (float)m_dist;}; + void SetDistance(float dist) { m_dist = dist;}; + + + void SetAsPerspective(); + void SetAsOrtho(); + void SetAsUpdateAuto(){update = scene_Update_Automatic;}; + void SetAsUpdateByRequire(){update = scene_Update_ByRequire;}; + int GetUpdateStyle(){ return update;}; + void SetAsLaboratorySystem(){system = scene_System_Labrotary;}; + void SetAsRelativeSystem(){system = scene_System_Relative;}; + int GetSystemStyle(){ return system;}; + + + void GetLabX(float*, float*, float*); + void GetLabY(float*, float*, float*); + void GetLabZ(float*, float*, float*); + void RotateX(float); + void RotateY(float); + void RotateZ(float); + void RotateXf(); + void RotateYf(); + void RotateZf(); + void RotateXb(); + void RotateYb(); + void RotateZb(); + void TransL(); + void TransR(); + void TransU(); + void TransD(); + void TransN(); + void TransF(); + void TransL(float); + void TransR(float); + void TransU(float); + void TransD(float); + void TransN(float); + void TransF(float); + void ResetFocus(float,float,float); //reset the rotation center + void GetFocus(float&,float&,float&); //get the rotation center + void TransDevice(int, int, int, int); + void TransDevice(int, int); + void TransDevice(); + void ZoomIn(); + void ZoomOut(); + int MoveClipPlaneP(); + int MoveClipPlaneM(); + int ChangeClipPlane(); + void EnableClipPlane(); + void EnableClipPlanePair(); + void DisableClipPlane(); + void DisableClipPlanePair(); + int IsCurrentClipPlaneEnabled(); + int IsClipPlaneEnabled(); + int IsClipPlaneEnabled(int); + int IfClipPlaneVisiable(int); + void SetClipPlaneShown(int); + void SetClipPlaneHiden(int); + void SetVolumeShown(); + void SetVolumeHiden(); + + int Response(int); + + void ChangeLightColorA(int, float, float, float); + void ChangeLightColorD(int, float, float, float); + void ChangeLightColorS(int, float, float, float); + void ChangeLightPosition(int, float, float, float); + void TurnLighton(int); + void TurnLightoff(int); + + virtual void Paint(); + void PaintClipPlane(); + + void ChangeAction(int Action){ action = Action; }; + int CurrentAction(){ return action; }; + + void ChangeZoomPercent(float ZoomP ){ m_zoomPercent = ZoomP; }; + float CurrentZoomPercent(){ return m_zoomPercent; }; + float CurrentZoomScale(){ return m_zoomscal; }; + void ChangeZoomScale(float zoomscal){ m_zoomscal = zoomscal; }; + + void ChangeRotationStepx(float Rstep ){ m_rotationStepx = Rstep; }; + float CurrentRotationStepx(){ return m_rotationStepx; }; + void ChangeRotationStepy(float Rstep ){ m_rotationStepy = Rstep; }; + float CurrentRotationStepy(){ return m_rotationStepy; }; + void ChangeRotationStepz(float Rstep ){ m_rotationStepz = Rstep; }; + float CurrentRotationStepz(){ return m_rotationStepz; }; + void ChangeTransStepx(float Tstep ){ m_itransStepx = Tstep; }; + float CurrentTransStepx(){ return m_itransStepx; }; + void ChangeTransStepy(float Tstep ){ m_itransStepy = Tstep; }; + float CurrentTransStepy(){ return m_itransStepy; }; + void ChangeTransStepz(float Tstep ){ m_itransStepz = Tstep; }; + float CurrentTransStepz(){ return m_itransStepz; }; + + void ChangeClipStepx(float Cstep ){ iclipStepx = Cstep; }; + float CurrentClipStepx(){ return iclipStepx; }; + void ChangeClipStepy(float Cstep ){ iclipStepy = Cstep; }; + float CurrentClipStepy(){ return iclipStepy; }; + void ChangeClipStepz(float Cstep ){ iclipStepz = Cstep; }; + float CurrentClipStepz(){ return iclipStepz; }; + + void ChangeClipPairThickx(float); + float CurrentClipPairThickx(){ return iclipThickx; }; + void ChangeClipPairThicky(float); + float CurrentClipPairThicky(){ return iclipThicky; }; + void ChangeClipPairThickz(float); + float CurrentClipPairThickz(){ return iclipThickz; }; + + + void Save(FILE*); + void Read(FILE*); +}; + +#endif \ No newline at end of file diff --git a/GLLIBSRC/SolidCircle.cpp b/GLLIBSRC/SolidCircle.cpp new file mode 100644 index 0000000..a392321 --- /dev/null +++ b/GLLIBSRC/SolidCircle.cpp @@ -0,0 +1,145 @@ +#include + +#include "SolidCircle.h" + + +#define c_MXNFAI 64 +#define DEFAUT_NUMFAI 12 +static float cosfai[c_MXNFAI], sinfai[c_MXNFAI]; +int SolidCircle::fai=0; + +void SolidCircle::Set(int Nf) +{ + int i; + double ang,step; + + if( fai == Nf) return; + + fai = Nf; + if(fai > c_MXNFAI) fai = c_MXNFAI; + + step = (2.*3.14159265359)/ (double) (fai-1); + for(i=0; i 0) glDeleteLists(list,1); +} + +SolidCircle::SolidCircle() +{ + x = 0.f; + y = 0.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(SolidCircle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; + +} + +SolidCircle::SolidCircle(float radiu) +{ + x = 0.f; + y = 0.f; + size = radiu; + R = 1.f; + G = 1.f; + B = 1.f; + if(SolidCircle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + + +SolidCircle::SolidCircle(float X, float Y) +{ + x = X; + y = Y; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(SolidCircle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + +SolidCircle::SolidCircle(float radiu, float X, float Y) +{ + x = X; + y = Y; + size = radiu; + R = 1.f; + G = 1.f; + B = 1.f; + if(SolidCircle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + + +SolidCircle::SolidCircle(float radiu, float X, float Y, float Red, float Green, float Blue) +{ + x = X; + y = Y; + size = radiu; + R = Red; + G = Green; + B = Blue; + if(SolidCircle::fai <= 0) Set(DEFAUT_NUMFAI); + list = 0; +} + + +void SolidCircle::Paint() +{ + int i; + + glPushMatrix(); + glTranslatef(x,y,0.f); + + if(list > 0) + { + glScalef(size,size,size); + glCallList(list); + glPopMatrix(); + return; + } + glEnable(GL_COLOR_MATERIAL); + glColor4f(R,G,B,A); + glBegin(GL_TRIANGLE_FAN); + glVertex2d(0.f, 0.f); + for(i=0; i // Standard windows include +#include // OpenGL library +#include "xyPoint.h" +#include "Texture.h" + +#ifndef _SOLIDCIRCLE +#define _SOLIDCIRCLE + +class SolidCircle: public xyPoint +{ +private: + static int fai; + int list; +protected: +public: + SolidCircle(); + SolidCircle(float); + SolidCircle(float,float); + SolidCircle(float,float,float); + SolidCircle(float,float,float,float,float,float); + ~SolidCircle(); + static void Set(int); + virtual void Paint(); + virtual int MakeList(); + int GetList(){return list;}; +}; + +#endif \ No newline at end of file diff --git a/GLLIBSRC/Sphere.cpp b/GLLIBSRC/Sphere.cpp new file mode 100644 index 0000000..ca7c6da --- /dev/null +++ b/GLLIBSRC/Sphere.cpp @@ -0,0 +1,362 @@ +#include + +#include "Sphere.h" + +int Sphere::fai=0; +int Sphere::theta=0; + +#define c_MXNFAI 64 +#define c_MXNTHETA 64 +#define DEFAUT_NUMFAI 12 +#define DEFAUT_NUMTHETA 12 + +static float cosfai[c_MXNFAI], sinfai[c_MXNFAI]; +static float costheta[c_MXNTHETA],sintheta[c_MXNTHETA]; +static float tx1[c_MXNFAI], tx2[c_MXNFAI]; +static float ty1[c_MXNFAI], ty2[c_MXNFAI]; +static float tz1[c_MXNFAI], tz2[c_MXNFAI]; +static float pjx[c_MXNTHETA][c_MXNFAI]; +static float pjy[c_MXNTHETA][c_MXNFAI]; + +void Sphere::Set(int Nf, int Nt) +{ + int i, j; + double ang,step; + + if( (fai == Nf) && (theta == Nt)) return; + + fai = Nf; + theta = Nt; + if(fai > c_MXNFAI) fai = c_MXNFAI; + if(theta > c_MXNTHETA) theta = c_MXNTHETA; + + step = (2.*3.14159265359)/ (double) (fai-1); + for(i=0; i 0) glDeleteLists(list,1); +} + +Sphere::Sphere() +{ + x = 0.f; + y = 0.f; + z = 0.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; + +} + +Sphere::Sphere(float radiu) +{ + x = 0.f; + y = 0.f; + z = 0.f; + size = radiu; + R = 1.f; + G = 1.f; + B = 1.f; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + +Sphere::Sphere(float center[3]) +{ + x = center[0]; + y = center[1]; + z = center[2]; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + +Sphere::Sphere(float radiu, float center[3]) +{ + x = center[0]; + y = center[1]; + z = center[2]; + size = radiu; + R = 1.f; + G = 1.f; + B = 1.f; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + +Sphere::Sphere(float X, float Y, float Z) +{ + x = X; + y = Y; + z = Z; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + +Sphere::Sphere(float radiu, float X, float Y, float Z) +{ + x = X; + y = Y; + z = Z; + size = radiu; + R = 1.f; + G = 1.f; + B = 1.f; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + +Sphere::Sphere(float radiu, float center[3], float color[3]) +{ + x = center[0]; + y = center[1]; + z = center[2]; + size = radiu; + R = color[0]; + G = color[1]; + B = color[2]; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + + +Sphere::Sphere(float radiu, float X, float Y, float Z, float color[3]) +{ + x = X; + y = Y; + z = Z; + size = radiu; + R = color[0]; + G = color[1]; + B = color[2]; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + + +Sphere::Sphere(float radiu, float X, float Y, float Z, float Red, float Green, float Blue) +{ + x = X; + y = Y; + z = Z; + size = radiu; + R = Red; + G = Green; + B = Blue; + if(Sphere::fai <= 0 || Sphere::theta <= 0) Set(DEFAUT_NUMFAI,DEFAUT_NUMTHETA); + list = 0; +} + +inline void Sphere::Paint() +{ + int i,j; + + glPushMatrix(); + glTranslatef(x,y,z); + + if(list > 0) + { + glScalef(size,size,size); + glCallList(list); + glPopMatrix(); + return; + } + //direct paint + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glColor4f(R,G,B,A); + for(i=0; iList()); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glEnable(tex->Dim()); + + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glColor4f(R,G,B,A); + + texx = new float[fai]; + texdx = 1.0/(float) (fai-1); + texdy = 1.0/(float) (theta-1); + + for(i=0; iDim()); + delete texx; + glPopMatrix(); + + return; +} + +int Sphere::MakeList() +{ + int i, j; + + if(list>0) return list; + + glNewList(list = glGenLists(1), GL_COMPILE); + + for(i=0; i // Standard windows include +//#include // OpenGL library + + + +#ifndef _SPHERE +#define _SPHERE +#include "Point.h" +#include "Texture.h" +class Sphere: public Point +{ +private: + static int fai,theta; + int list; +public: + Sphere(); + Sphere(float); + Sphere(float*); + Sphere(float,float,float); + Sphere(float,float*); + Sphere(float,float,float,float); + Sphere(float,float*,float*); + Sphere(float,float,float,float,float*); + Sphere(float,float,float,float,float,float, float); + ~Sphere(); + static void Set(int, int); + virtual void Paint(); + virtual void Paint(Texture*); + virtual int MakeList(); + +}; + +#endif \ No newline at end of file diff --git a/GLLIBSRC/Style.cpp b/GLLIBSRC/Style.cpp new file mode 100644 index 0000000..84303d4 --- /dev/null +++ b/GLLIBSRC/Style.cpp @@ -0,0 +1,100 @@ +#include "Style.h" +GLint Style::curStyle=Style_default; + +Style::Style() +{ + oldStyle = curStyle; + SetStyle(curStyle); +} + +Style::~Style() +{ + RestoreOldStyle(); +} + +void Style::SetStyle(GLint i) +{ + switch (i) + { + case Style_default: + Solid(); + break; + case Style_SOLID : + Solid(); + break; + case Style_SOLID_FRONT_ONLY: + SolidFrontOnly(); + break; + case Style_SOLID_BACK_ONLY: + SolidBackOnly(); + break; + case Style_WIRE: + Wire(); + break; + case Style_TRANSP_SOLID: + TranspSolid(); + break; + } +} + + +void Style::SolidFrontOnly() +{ + + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glDisable(GL_BLEND); + glPolygonMode(GL_FRONT,GL_FILL); + //glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE_MINUS_SRC_ALPHA); + curStyle = Style_SOLID_FRONT_ONLY; + return; +} + +void Style::SolidBackOnly() +{ + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + glDisable(GL_BLEND); + glPolygonMode(GL_BACK,GL_FILL); + //glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE_MINUS_SRC_ALPHA); + curStyle = Style_SOLID_BACK_ONLY; + return; +} + +void Style::Solid() +{ + glDisable(GL_CULL_FACE); + glDisable(GL_BLEND); + glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); + //glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE_MINUS_SRC_ALPHA); + curStyle = Style_SOLID; + return; +} + +void Style::Wire() +{ + glDisable(GL_CULL_FACE); + glDisable(GL_BLEND); + glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + //glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE_MINUS_SRC_ALPHA); + curStyle = Style_WIRE; + return; +} + +void Style::TranspSolid() +{ + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); + glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); + //glBlendFunc(GL_ONE, GL_SRC_COLOR); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + curStyle = Style_TRANSP_SOLID; + return; +} + +void Style::RestoreOldStyle() +{ + SetStyle(oldStyle); + return; +} + diff --git a/GLLIBSRC/Style.h b/GLLIBSRC/Style.h new file mode 100644 index 0000000..ce3d953 --- /dev/null +++ b/GLLIBSRC/Style.h @@ -0,0 +1,31 @@ +#ifndef _STYLE +#define _STYLE +#include "GlcObj.h" + +#define Style_default 0 +#define Style_SOLID 1 +#define Style_SOLID_FRONT_ONLY 2 +#define Style_SOLID_BACK_ONLY 3 +#define Style_WIRE 4 +#define Style_TRANSP_SOLID 5 + +class Style +{ + private: + static GLint curStyle; + GLint oldStyle, thisStyle; + + protected: + public: + Style(); + ~Style(); + void Solid( ); + void SolidFrontOnly( ); + void SolidBackOnly( ); + void Wire( ); + void TranspSolid( ); + void SetStyle(GLint); + void RestoreOldStyle(); +}; + +#endif \ No newline at end of file diff --git a/GLLIBSRC/TEXTURE.H b/GLLIBSRC/TEXTURE.H new file mode 100644 index 0000000..c5869dc --- /dev/null +++ b/GLLIBSRC/TEXTURE.H @@ -0,0 +1,19 @@ +#ifndef _TEXTURE_ +#define _TEXTURE_ +#include "Bitmap.h" + +class Texture:public Bitmap +{ + private: + protected: + //int texture; + //int texDim; + public: + Texture(); + ~Texture(); + Texture(char*); + int List(){ return texture;} + int Dim(){ return texDim;} + +}; +#endif diff --git a/GLLIBSRC/XyPoint.cpp b/GLLIBSRC/XyPoint.cpp new file mode 100644 index 0000000..3f7a2f7 --- /dev/null +++ b/GLLIBSRC/XyPoint.cpp @@ -0,0 +1,110 @@ +#include "xyPoint.h" + +xyPoint::xyPoint() +{ + x=0.f; + y=0.f; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; +} + + +xyPoint::xyPoint(float x0, float y0) +{ + x=x0; + y=y0; + size = 1.f; + R = 1.f; + G = 1.f; + B = 1.f; + A = 1.f; + +} + + +xyPoint::xyPoint(float x0, float y0, float r, float g, float b) +{ + x=x0; + y=y0; + size = 1.f; + R = r; + G = g; + B = b; + A = 1.f; +} + +void xyPoint::Paint() +{ + glEnable(GL_POINT_SMOOTH); + glPointSize(size); + glColor4f(R,G,B,A); + glBegin(GL_POINTS); + glVertex2f(x, y); + glEnd(); +// glFlush(); + return; +} + +int xyPoint::MakeList() +{ + return 0; +} + +void xyPoint::Moveto(float Newx, float Newy) +{ + + x = Newx; + y = Newy; + return; +} + +void xyPoint::ChangeColor(float NewR, float NewG, float NewB) +{ + + R = NewR; + G = NewG; + B = NewB; + return; +} + +void xyPoint::GetColor(float*oldR, float*oldG, float*oldB) +{ + + *oldR = R; + *oldG = G; + *oldB = B; + return; +} + +void xyPoint::Copy(xyPoint*target) +{ + + if(target == NULL) return; + target->size = size; + target->R = R; + target->G = G; + target->B = B; + target->x = x; + target->y = y; + + return; +} + +void xyPoint::Paste(xyPoint*source) +{ + + if(source == NULL ) return; + size = source->size; + R = source->R; + G = source->G; + B = source->B; + x = source->x; + y = source->y; + + return; +} + + diff --git a/GLLIBSRC/XyPoint.h b/GLLIBSRC/XyPoint.h new file mode 100644 index 0000000..87eeb8a --- /dev/null +++ b/GLLIBSRC/XyPoint.h @@ -0,0 +1,47 @@ +#include // Standard windows include +#include // OpenGL library +#include "GlcObj.h" + +#ifndef _XYPOINT +#define _XYPOINT + +class xyPoint:public GlcObj +{ +protected: + GLfloat x,y; + GLfloat size; + GLfloat R,G,B,A; +public: + xyPoint(); + xyPoint(float,float); + xyPoint(float,float,float,float,float); + virtual ~xyPoint(){}; + + virtual void Copy(xyPoint*); + virtual void Paste(xyPoint*); + + virtual void Paint(); + virtual int MakeList(); + virtual int GetList(){return 0;}; + virtual void Moveto(float, float); + void ChangeColor(float, float, float); + void GetColor(float*, float*, float*); + void ChangeAlpha(float NewA){A = NewA;}; + float GetAlpha(){ return A;}; + virtual void ChangeSize(float NewSize){size = NewSize;}; + virtual float GetSize(){return size;}; + + virtual void SetBorderThick(float thick){}; + virtual void SetBarHight(float h){}; + virtual void SetBarWidth(float w){}; + virtual void SetBarCapW (float w){}; + virtual void SetBarCapH (float h){}; + virtual float GetBorderThick(){return 0.f;}; + virtual float GetBarHight(){return 0.f;}; + virtual float GetBarWidth(){return 0.f;}; + virtual float GetBarCapW (){return 0.f;}; + virtual float GetBarCapH (){return 0.f;}; + +}; + +#endif \ No newline at end of file diff --git a/VISATOMSRC/SampleDataSheet.cpp b/VISATOMSRC/SampleDataSheet.cpp new file mode 100644 index 0000000..1a3d404 --- /dev/null +++ b/VISATOMSRC/SampleDataSheet.cpp @@ -0,0 +1,60 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +//#include +#include +#include +#include "SampleDataSheet.h" + + +SampleDataSheet::SampleDataSheet() +{ + m_nCol = m_nRow = 0; + m_Data = NULL; + return; +} + +SampleDataSheet::SampleDataSheet(int ncol, int nrow) +{ + m_nCol = ncol; + m_nRow = nrow; + if(m_nCol*m_nRow > 0) + { + int i; + m_Data = new double*[m_nCol]; + for(i=0; i +#include +#include "Scene.h" +#include "Style.h" +#include "VisAtomCliper.h" + + +VisAtomCliper::~VisAtomCliper() +{ +} + +VisAtomCliper::VisAtomCliper() +{ + + this->m_Style = CLIPPING_STYLE_OR; + this->m_Scene = NULL; + this->m_Inv[0] = m_Inv[1] = m_Inv[2] =0; + this->m_Axsis[0] = m_Axsis[1] = m_Axsis[2] = 0; + this->m_Pos[0] = m_Pos[1] = m_Pos[2] = 0; + this->m_CStep[0] = m_CStep[1] = m_CStep[2] = 0.1; + this->m_ShowFrontface[0] = m_ShowFrontface[1] = m_ShowFrontface[2] = 1; + this->m_ShowBackface[0] = m_ShowBackface[1] = m_ShowBackface[2] = 1; + this->m_Opacity = 0.3; + this->EnableClip(false); + return; + } + +void VisAtomCliper::SetParameters(VisAtomCliper*sor) +{ + int i; + for(i=0; i<3; i++) + { + this->m_ClipStatu[i] = sor->m_ClipStatu[i]; + this->m_Inv[i] = sor->m_Inv[i]; + this->m_Axsis[i] = sor->m_Axsis[i]; + this->m_CStep[i] = sor->m_CStep[i]; + this->m_Pos[i] = sor->m_Pos[i]; + this->m_ShowFrontface[i] = sor->m_ShowFrontface[i]; + this->m_ShowBackface[i] = sor->m_ShowBackface[i]; + this->m_Opacity = sor->m_Opacity; + } + return; +} + +bool VisAtomCliper::IsParameterChanged(VisAtomCliper*sor) +{ + int i; + for(i=0; i<3; i++) + { + if(this->m_ClipStatu[i] != sor->m_ClipStatu[i]) return true; + if(this->m_Inv[i] != sor->m_Inv[i]) return true; + if(abs(this->m_Axsis[i] - sor->m_Axsis[i]) > 1.e-5) return true; + if(this->m_CStep[i] != sor->m_CStep[i]) return true; + } + return false; +} + +void VisAtomCliper::GetClipThickness(double thickness[]) +{ + int i; + if(!this->m_Scene) + { + this->GetClipStep(thickness); + return; + } + else + { + /*double dx = this->m_Scene->GetVolumeX1() - this->m_Scene->GetVolumeX0(); + double dy = this->m_Scene->GetVolumeY1() - this->m_Scene->GetVolumeY0(); + double dz = this->m_Scene->GetVolumeZ1() - this->m_Scene->GetVolumeZ0(); + thickness[0] = dx*this->m_CStep[0]; + thickness[1] = dy*this->m_CStep[1]; + thickness[2] = dz*this->m_CStep[2];*/ + this->GetClipStep(thickness); + return; + } +} + +void VisAtomCliper::GetClipAbsolutePos(double pos[]) +{ + if(!this->m_Scene) + { + this->GetClipPos(pos); + return; + } + else + { + /*double dx = this->m_Scene->GetVolumeX1() - this->m_Scene->GetVolumeX0(); + double dy = this->m_Scene->GetVolumeY1() - this->m_Scene->GetVolumeY0(); + double dz = this->m_Scene->GetVolumeZ1() - this->m_Scene->GetVolumeZ0(); + pos[0] = dx*this->m_Pos[0]; + pos[1] = dy*this->m_Pos[1]; + pos[2] = dz*this->m_Pos[2];*/ + this->GetClipPos(pos); + return; + } +} + +void VisAtomCliper::GetClipPlaneContour(double x0, double y0, double z0, double x1,double y1,double z1, + double vnx, double vny, double vnz, double rr, int&npt, double ppt[12][3]) +{ + + double x, y, z, dis, pt[12][3]; + int i, j, ii, flag[12]; + + + + //get the intersects + npt = 0; + if(abs(vnz) > 1.e-8) + { + z = (rr - vnx*x0 - vny*y0)/vnz; + if( z >=z0 && z<=z1) { pt[npt][0] = x0; pt[npt][1] = y0; pt[npt][2] = z; npt++;} + + z = (rr - vnx*x0 - vny*y1)/vnz; + if( z >=z0 && z<=z1) { pt[npt][0] = x0; pt[npt][1] = y1; pt[npt][2] = z; npt++;} + + z = (rr - vnx*x1 - vny*y0)/vnz; + if( z >=z0 && z<=z1) { pt[npt][0] = x1; pt[npt][1] = y0; pt[npt][2] = z; npt++;} + + z = (rr - vnx*x1 - vny*y1)/vnz; + if( z >=z0 && z<=z1) { pt[npt][0] = x1; pt[npt][1] = y1; pt[npt][2] = z; npt++;} + } + + if(abs(vnx) > 1.e-8) + { + x = (rr - vny*y0 - vnz*z0)/vnx; + if( x >=x0 && x<=x1) { pt[npt][0] = x; pt[npt][1] = y0; pt[npt][2] = z0; npt++;} + + x = (rr - vny*y0 - vnz*z1)/vnx; + if( x >=x0 && x<=x1) { pt[npt][0] = x; pt[npt][1] = y0; pt[npt][2] = z1; npt++;} + + x = (rr - vny*y1 - vnz*z0)/vnx; + if( x >=x0 && x<=x1) { pt[npt][0] = x; pt[npt][1] = y1; pt[npt][2] = z0; npt++;} + + x = (rr - vny*y1 - vnz*z1)/vnx; + if( x >=x0 && x<=x1) { pt[npt][0] = x; pt[npt][1] = y1; pt[npt][2] = z1; npt++;} + + } + + if(abs(vny) > 1.e-8) + { + y = (rr - vnz*z0 - vnx*x0)/vny; + if( y >=y0 && y<=y1) { pt[npt][0] = x0; pt[npt][1] = y; pt[npt][2] = z0; npt++;} + + y = (rr - vnz*z0 - vnx*x1)/vny; + if( y >=y0 && y<=y1) { pt[npt][0] = x1; pt[npt][1] = y; pt[npt][2] = z0; npt++;} + + y = (rr - vnz*z1 - vnx*x0)/vny; + if( y >=y0 && y<=y1) { pt[npt][0] = x0; pt[npt][1] = y; pt[npt][2] = z1; npt++;} + + y = (rr - vnz*z1 - vnx*x1)/vny; + if( y >=y0 && y<=y1) { pt[npt][0] = x1; pt[npt][1] = y; pt[npt][2] = z1; npt++;} + } + //sort the intersects + ppt[0][0] = pt[0][0]; + ppt[0][1] = pt[0][1]; + ppt[0][2] = pt[0][2]; + flag[0] = 1; + for(i=1; im_Scene->GetVolumeX0(); + x1 = this->m_Scene->GetVolumeX1(); + y0 = this->m_Scene->GetVolumeY0(); + y1 = this->m_Scene->GetVolumeY1(); + z0 = this->m_Scene->GetVolumeZ0(); + z1 = this->m_Scene->GetVolumeZ1(); + pos[0] = this->m_Pos[0]; //*(x1 - x0); + pos[1] = this->m_Pos[1]; //*(y1 - y0); + pos[2] = this->m_Pos[2]; //*(z1 - z0); + + if(this->m_Style == VisAtomCliper::CLIPPING_STYLE_ANYDIR) + { + double norm, rr, thick[3], vnx,vny, vnz, pt[12][3], ppt[12][3]; + int i, j, ii, npt, flag[12]; + //Without normal of the clip plane + if(abs(this->m_Axsis[0]) < 0.0001 && + abs(this->m_Axsis[1]) < 0.0001 && + abs(this->m_Axsis[2]) < 0.0001) return; + + //get normal of the clip plane + norm = this->m_Axsis[0]*this->m_Axsis[0] + + this->m_Axsis[1]*this->m_Axsis[1] + + this->m_Axsis[2]*this->m_Axsis[2]; + norm = pow(norm, 0.5); + vnx = this->m_Axsis[0]/norm; + vny = this->m_Axsis[1]/norm; + vnz = this->m_Axsis[2]/norm; + + + //get the distance to origion + this->GetClipThickness(thick); + rr = vnx*pos[0] + vny*pos[1] + vnz*pos[2]; + + if(this->m_ShowFrontface[0]) + { + //get the intersects1 + GetClipPlaneContour(x0, y0, z0, x1, y1, z1, vnx, vny, vnz, rr+0.5*thick[0], npt, ppt); + + //Begin the paint + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glLineWidth(1.f); + glDisable(GL_DEPTH_TEST); + + glColor4f(0.f, 0.f, 0.f, 0.6f); + glBegin(GL_LINE_LOOP); + for (i = 0; iIsEnabledDClipX()||this->IsEnabledDClipY()||this->IsEnabledDClipZ()) + { + if(this->m_ShowBackface[0]) + { + //get the intersects2 + GetClipPlaneContour(x0, y0, z0, x1, y1, z1, vnx, vny, vnz, rr-0.5*thick[0], npt, ppt); + + glColor4f(0.f, 0.f, 0.f, 0.6f); + glBegin(GL_LINE_LOOP); + for (i = 0; im_Scene->GetVolumeX0(); + x1 = this->m_Scene->GetVolumeX1(); + y0 = this->m_Scene->GetVolumeY0(); + y1 = this->m_Scene->GetVolumeY1(); + z0 = this->m_Scene->GetVolumeZ0(); + z1 = this->m_Scene->GetVolumeZ1(); + pos[0] = this->m_Pos[0]; //*(x1 - x0); + pos[1] = this->m_Pos[1]; //*(y1 - y0); + pos[2] = this->m_Pos[2]; //*(z1 - z0); + + if (this->m_Style == VisAtomCliper::CLIPPING_STYLE_ANYDIR) + { + double norm, rr, thick[3], vnx, vny, vnz, pt[12][3], ppt[12][3]; + int i, j, ii, npt, flag[12]; + //Without normal of the clip plane + if (abs(this->m_Axsis[0]) < 0.0001 && + abs(this->m_Axsis[1]) < 0.0001 && + abs(this->m_Axsis[2]) < 0.0001) return; + + //get normal of the clip plane + norm = this->m_Axsis[0] * this->m_Axsis[0] + + this->m_Axsis[1] * this->m_Axsis[1] + + this->m_Axsis[2] * this->m_Axsis[2]; + norm = pow(norm, 0.5); + vnx = this->m_Axsis[0] / norm; + vny = this->m_Axsis[1] / norm; + vnz = this->m_Axsis[2] / norm; + + + //get the distance to origion + this->GetClipThickness(thick); + rr = vnx * pos[0] + vny * pos[1] + vnz * pos[2]; + + //draw point vector + /*if( this->IsEnabledDClipX()||this->IsEnabledDClipY()||this->IsEnabledDClipZ()) + { + + glColor4f(1.f, 1.f, 1.f, 0.8f); + glBegin(GL_LINES); + glVertex3d(0., 0., 0.); + glVertex3d(pos[0], pos[1], pos[2]); + glEnd(); + }*/ + + if (this->m_ShowFrontface[0]) + { + //get the intersects1 + GetClipPlaneContour(x0, y0, z0, x1, y1, z1, vnx, vny, vnz, rr + 0.5*thick[0], npt, ppt); + + //Begin the paint + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glLineWidth(1.f); + + glEnable(GL_DEPTH_TEST); + glColor4f(1.f, 1.f, 1.f, (float)this->m_Opacity); + glBegin(GL_POLYGON); + glNormal3d(vnx, vny, vnz); + for (i = 0; iIsEnabledDClipX() || this->IsEnabledDClipY() || this->IsEnabledDClipZ()) + { + if (this->m_ShowBackface[0]) + { + //get the intersects2 + GetClipPlaneContour(x0, y0, z0, x1, y1, z1, vnx, vny, vnz, rr - 0.5*thick[0], npt, ppt); + + glColor4f(1.f, 1.f, 1.f, (float)this->m_Opacity); + glEnable(GL_DEPTH_TEST); + glBegin(GL_POLYGON); + glNormal3d(vnx, vny, vnz); + for (i = 0; i 0; + } + bool IsEnabledClipX() + { + return IsEnabledClip(0); + }; + bool IsEnabledClipY() + { + return IsEnabledClip(1); + }; + bool IsEnabledClipZ() + { + return IsEnabledClip(2); + }; + bool IsEnabledClip() + { + return IsEnabledClipX() || IsEnabledClipY() || IsEnabledClipZ(); + }; + + void EnableDClip(bool enabled, int i) + { + int old = m_ClipStatu[i] & VISCLIPERSTATU::CLIPPING_ENABLE1; + if (enabled) + { + m_ClipStatu[i] = VISCLIPERSTATU::CLIPPING_ENABLE2 + old; + } + else + { + m_ClipStatu[i] = VISCLIPERSTATU::CLIPPING_DISABLE + old; + } + } + void EnableDClip(bool enabled = true) + { + EnableDClip(enabled, 0); + EnableDClip(enabled, 1); + EnableDClip(enabled, 2); + }; + void EnableDClipX(bool enabled = true) + { + EnableDClip(enabled, 0); + //m_DClip[0] = enabled; + }; + void EnableDClipY(bool enabled = true) + { + EnableDClip(enabled, 1); + //m_DClip[1] = enabled; + }; + void EnableDClipZ(bool enabled = true) + { + EnableDClip(enabled, 2); + //m_DClip[2] = enabled; + }; + bool IsEnabledDClip(int i) + { + return (m_ClipStatu[i] & VisAtomCliper::CLIPPING_ENABLE2) > 0; + } + + bool IsEnabledDClipX() + { + return IsEnabledDClip(0); //return m_DClip[0]; + }; + bool IsEnabledDClipY() + { + return IsEnabledDClip(1); //return m_DClip[1]; + }; + bool IsEnabledDClipZ() + { + return IsEnabledDClip(2); //return m_DClip[2]; + }; + bool IsEnabledDClip() + { + return IsEnabledDClipX() || IsEnabledDClipY() || IsEnabledDClipZ(); + } + + void SetInverseClipX(bool enabled = true) + { + m_Inv[0] = enabled; + }; + void SetInverseClipY(bool enabled = true) + { + m_Inv[1] = enabled; + }; + void SetInverseClipZ(bool enabled = true) + { + m_Inv[2] = enabled; + }; + bool IsInverseClipX() + { + return m_Inv[0]; + }; + bool IsInverseClipY() + { + return m_Inv[1]; + }; + bool IsInverseClipZ() + { + return m_Inv[2]; + }; + + + void SetClipPos(double pos) + { + m_Pos[0] = m_Pos[1] = m_Pos[2] = pos; + }; + void SetClipPos(double pos[]) + { + m_Pos[0] = pos[0]; m_Pos[1] = pos[1]; m_Pos[2] = pos[2]; + }; + void GetClipPos(double pos[]) + { + pos[0] = m_Pos[0]; pos[1] = m_Pos[1]; pos[2] = m_Pos[2]; + }; + void GetClipPos(double&x, double&y, double&z) + { + x = m_Pos[0]; y = m_Pos[1]; z = m_Pos[2]; + }; + + //get the position multiplied by box side + void GetClipAbsolutePos(double pos[]); + + void SetClipStep(double step[]) + { + m_CStep[0] = step[0]; m_CStep[1] = step[1]; m_CStep[2] = step[2]; + }; + void GetClipStep(double step[]) + { + step[0] = m_CStep[0]; step[1] = m_CStep[1]; step[2] = m_CStep[2]; + }; + void GetClipThickness(double thickness[]); + double GetClipThickness() + { + return m_CStep[0]; + }; + + //used in style of anydirection clipping + void SetClipAxsis(double axsis[]) + { + m_Axsis[0] = axsis[0]; m_Axsis[1] = axsis[1]; m_Axsis[2] = axsis[2]; + }; + void GetClipAxsis(double axsis[]) + { + axsis[0] = m_Axsis[0]; axsis[1] = m_Axsis[1]; axsis[2] = m_Axsis[2]; + }; + void GetClipAxsis(double&x, double&y, double&z) + { + x = m_Axsis[0]; y = m_Axsis[1]; z = m_Axsis[2]; + }; + + void SetParameters(VisAtomCliper*sor); + bool IsParameterChanged(VisAtomCliper*sor); + + //used for set visualization parameters + void ShowFronFace(int show[]) + { + m_ShowFrontface[0] = show[0]; m_ShowFrontface[1] = show[1]; m_ShowFrontface[2] = show[2]; + }; + void ShowFronFace(int show) + { + m_ShowFrontface[0] = m_ShowFrontface[1] = m_ShowFrontface[2] = show; + }; + + int IsShowFronFace() + { + return m_ShowFrontface[0]; + }; + + void ShowBackFace(int show[]) + { + m_ShowBackface[0] = show[0]; m_ShowBackface[1] = show[1]; m_ShowBackface[2] = show[2]; + }; + void ShowBackFace(int show) + { + m_ShowBackface[0] = m_ShowBackface[1] = m_ShowBackface[2] = show; + }; + int IsShowBackFace() + { + return m_ShowBackface[0]; + }; + + void SetFaceOpacity(double opacity) + { + m_Opacity = opacity; + }; + double GetFaceOpacity() + { + return m_Opacity; + }; +}; + +//************************************************************ + + + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisAtomDataSheet.cpp b/VISATOMSRC/VisAtomDataSheet.cpp new file mode 100644 index 0000000..234ac5b --- /dev/null +++ b/VISATOMSRC/VisAtomDataSheet.cpp @@ -0,0 +1,113 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#include +#include +#include "VisAtomDataSheet.h" + + +VisAtomDataSheet::VisAtomDataSheet() +{ + m_nCol = m_nRow = 0; + m_ColProp = NULL; + m_pData = NULL; + m_Boxsize[0] = 1; + m_Boxsize[1] = -1; + m_Boxsize[2] = 1; + m_Boxsize[3] = -1; + m_Boxsize[4] = 1; + m_Boxsize[5] = -1; + return; +} + +VisAtomDataSheet::VisAtomDataSheet(int ncol, int nrow) +{ + this->SetColRow(ncol, nrow); + return; +} + + +VisAtomDataSheet::~VisAtomDataSheet() +{ + this->Clear(); + return; +} + + +void VisAtomDataSheet::Clear() +{ + + // delete the old data + if(m_pData) + { + int i; + for(i=0; iClear(); + + //update the new data + m_nCol = ncol; + m_nRow = nrow; + + int i; + if(m_nCol > 0) + { + + m_ColProp = new int[m_nCol]; + m_pData = new float*[m_nCol]; + for(i=0; i 0) + { + for(i=0; i 0) + { + int i; + m_ColProp = new int[m_nCol]; + m_pData = new float*[m_nCol]; + for(i=0; i= 0 ) m_ColProp[oldcol] = -1; + //if col <0, no colum selected for type + if(col >=0) m_ColProp[col] = COLPROP_TYPE; + } + void SetPosxCol(int col) + { + int oldcol = GetPosXCol(); + if(oldcol >= 0 ) m_ColProp[oldcol] = -1; + m_ColProp[col] = COLPROP_POSX; + } + void SetPosyCol(int col) + { + int oldcol = GetPosYCol(); + if(oldcol >= 0 ) m_ColProp[oldcol] = -1; + m_ColProp[col] = COLPROP_POSY; + } + void SetPoszCol(int col) + { + int oldcol = GetPosZCol(); + if(oldcol >= 0 ) m_ColProp[oldcol] = -1; + m_ColProp[col] = COLPROP_POSZ; + } + + void Clear(); + void SetColRow(int ncol, int nrow); + + void SetDataForCol_Row(int col, int row, char*str) {m_pData[col][row] = atof(str);} + void SetDataForRow(int row, char**str) {for(int i=0; i=m_nCol) return NULL; + if(col < 0) return NULL; + return m_pData[col]; + } + + void SetBoxSize(float b0, float b1, float b2, float b3, float b4,float b5) + { + m_Boxsize[0] = b0; + m_Boxsize[1] = b1; + m_Boxsize[2] = b2; + m_Boxsize[3] = b3; + m_Boxsize[4] = b4; + m_Boxsize[5] = b5; + return; + } + + void GetBoxSize(float&b0, float&b1, float&b2, float&b3, float&b4, float&b5) + { + b0 = m_Boxsize[0]; + b1 = m_Boxsize[1]; + b2 = m_Boxsize[2]; + b3 = m_Boxsize[3]; + b4 = m_Boxsize[4]; + b5 = m_Boxsize[5]; + return; + } + + int HasBoxSize() + { + if(m_Boxsize[0] >= m_Boxsize[1] || + m_Boxsize[2] >= m_Boxsize[3] || + m_Boxsize[4] >= m_Boxsize[5] ) return 0; + else return 1; + } + +}; + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisAtomExtendObject.h b/VISATOMSRC/VisAtomExtendObject.h new file mode 100644 index 0000000..50f5fb8 --- /dev/null +++ b/VISATOMSRC/VisAtomExtendObject.h @@ -0,0 +1,30 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2017 +*/ + +#ifndef _VISATOMEXTENDOBJECT_H +#define _VISATOMEXTENDOBJECT_H +#include "GlcObj.h" +#include "QString.h" +//***************************** +class VisAtomExtendObject:public GlcObj +{ + private: + + public: + VisAtomExtendObject(){}; + ~VisAtomExtendObject(){}; + + virtual QString RUNTIME_CLASSNAME(){ return QObject::tr("");}; + virtual void Paint(){}; + virtual int LoadData(QString fname) {return 0;}; + virtual int HasData(){ return 0;} + }; + + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisAtomSample.cpp b/VISATOMSRC/VisAtomSample.cpp new file mode 100644 index 0000000..5ae222b --- /dev/null +++ b/VISATOMSRC/VisAtomSample.cpp @@ -0,0 +1,3239 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ +#include // Standard windows include +#include // OpenGL library +#include // OpenGL library + +#include +#include + + +#include "Arrow.h" +#include "Arrowline.h" +#include "Circle.h" +#include "SolidCircle.h" +#include "Style.h" +#include "Sphere.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSubSample.h" +#include "VisAtomSample.h" +#include "VisAtomCliper.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomTrajectory.h" + + +void VisAtomSample::Clear(bool keepsubsample) +{ + if(!m_aType) delete m_aType;m_aType= NULL; + if(!m_aPx) delete m_aPx; m_aPx = NULL; + if(!m_aPy) delete m_aPy; m_aPy = NULL; + if(!m_aPz) delete m_aPz; m_aPz = NULL; + if(!m_aRadius) delete m_aRadius; m_aRadius = NULL; + if(!m_aRed) delete m_aRed; m_aRed = NULL; + if(!m_aGreen) delete m_aGreen; m_aGreen = NULL; + if(!m_aBlue) delete m_aBlue; m_aBlue = NULL; + if(!m_aRedex) delete m_aRedex; m_aRedex = NULL; + if(!m_aGreenex) delete m_aGreenex; m_aGreenex = NULL; + if(!m_aBlueex) delete m_aBlueex; m_aBlueex = NULL; + if(!m_aGeomStyle) delete m_aGeomStyle; m_aGeomStyle = NULL; + if(!m_aVisStat) delete m_aVisStat; m_aVisStat = NULL; + + if(m_vPx) delete m_vPx; m_vPx = NULL; + if(m_vPy) delete m_vPy; m_vPy = NULL; + if(m_vPz) delete m_vPz; m_vPz = NULL; + + if( !keepsubsample) + { + while(!this->m_subSamples.isEmpty()) + { + VisAtomSubSample*p = this->m_subSamples[0]; + delete p; + this->m_subSamples.removeAt(0); + this->m_selSubsamples.removeAt(0); + } + } + + //dettach from the data sheet + m_pData = NULL; + return; +} + +VisAtomSample::~VisAtomSample() +{ + + Clear(); + m_pickedAtomID = -1; + m_numAtom = 0; + m_pCliper.clear(); +} + +VisAtomSample::VisAtomSample() +{ + + m_pData = NULL; + m_aType = NULL; + m_aPx = NULL; + m_aPy = NULL; + m_aPz = NULL; + m_aXmi = m_aXmx = m_aYmi = m_aYmx = m_aZmi = m_aZmx = 0; + + m_aRadius = NULL; + m_aRed = NULL; + m_aGreen = NULL; + m_aBlue = NULL; + m_aRedex = NULL; + m_aGreenex = NULL; + m_aBlueex = NULL; + m_aGeomStyle = NULL; + m_aVisStat = NULL; + + m_vPx = NULL; + m_vPy = NULL; + m_vPz = NULL; + + m_numAtom = 0; + m_curSubsample = -1; + + m_pickedAtomID = -1; + m_pick_style = atom_pick_Option_Single; + m_pick_statu = atom_pick_Statu_nopicked; + + m_pTrajectory = NULL; + +} + +void VisAtomSample::Paint() +{ + + glMatrixMode(GL_MODELVIEW); + glEnable(GL_DEPTH_TEST); + Draw(); + if(this->m_pTrajectory) + { + this->m_pTrajectory->Paint(); + } + return; +} + +//******************************************** +void VisAtomSample::Draw() +{ + if(m_numAtom <= 0) return; + + DrawProjCirleAtoms(-1, 0, 0); + DrawProjCirleAtoms( 1, 0, 0); + DrawProjCirleAtoms( 0, 1, 0); + DrawProjCirleAtoms( 0,-1, 0); + DrawProjCirleAtoms( 0, 0, 1); + DrawProjCirleAtoms( 0, 0,-1); + + DrawProjSolidAtoms(-1, 0, 0); + DrawProjSolidAtoms( 1, 0, 0); + DrawProjSolidAtoms( 0, 1, 0); + DrawProjSolidAtoms( 0,-1, 0); + DrawProjSolidAtoms( 0, 0, 1); + DrawProjSolidAtoms( 0, 0,-1); + + DrawProjDotAtoms(-1, 0, 0); + DrawProjDotAtoms( 1, 0, 0); + DrawProjDotAtoms( 0, 1, 0); + DrawProjDotAtoms( 0,-1, 0); + DrawProjDotAtoms( 0, 0, 1); + DrawProjDotAtoms( 0, 0,-1); + + glEnable(GL_DEPTH_TEST); + DrawCircleAtoms(VisAtomVisualizingPolicy::D3_STYLE_INBOX); + DrawSolidAtoms(VisAtomVisualizingPolicy::D3_STYLE_INBOX); + DrawDotAtoms(VisAtomVisualizingPolicy::D3_STYLE_INBOX); + DrawLineVectors(VisAtomVisualizingPolicy::D3_STYLE_INBOX); + DrawSolidVectors(VisAtomVisualizingPolicy::D3_STYLE_INBOX); + + DrawCircleAtoms(VisAtomVisualizingPolicy::D3_STYLE_OUTBOX); + DrawSolidAtoms(VisAtomVisualizingPolicy::D3_STYLE_OUTBOX); + DrawDotAtoms(VisAtomVisualizingPolicy::D3_STYLE_OUTBOX); + DrawLineVectors(VisAtomVisualizingPolicy::D3_STYLE_OUTBOX); + DrawSolidVectors(VisAtomVisualizingPolicy::D3_STYLE_OUTBOX); + + return; +} +//********************************************* +//to high-light the slected atoms +void VisAtomSample::HighlightSelectedAtoms() +{ + int j, list; + Style Sty; + Sphere Balls = Sphere(); + bool checkin, in; + float x0, x1, y0, y1, z0, z1; + + glEnable(GL_LIGHTING); + Sty.SolidFrontOnly(); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + list = Balls.MakeList(); + for (j = 0; jm_aVisStat[j] & atom_Statu_Selected) + { + glColor4f(0.7f, 0.7f, 0.0f, 0.5f); + glPushMatrix(); + glTranslatef(m_aPx[j], m_aPy[j], m_aPz[j]); + glScalef(1.01f*m_aRadius[j], 1.01f*m_aRadius[j], 1.01f*m_aRadius[j]); + glCallList(list); + glPopMatrix(); + } + } + return; +} + +void VisAtomSample::HighlightFoundAtoms() +{ + int j, list; + Style Sty; + Sphere Balls = Sphere(); + bool checkin, in; + float x0, x1, y0, y1, z0, z1; + + glEnable(GL_LIGHTING); + Sty.SolidFrontOnly(); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + list = Balls.MakeList(); + for (j = 0; jm_aVisStat[j] & atom_Statu_MarkedFound) + { + glColor4f(0.7f, 0.7f, 0.7f, 0.5f); + glPushMatrix(); + glTranslatef(m_aPx[j], m_aPy[j], m_aPz[j]); + glScalef(1.01f*m_aRadius[j], 1.01f*m_aRadius[j], 1.01f*m_aRadius[j]); + glCallList(list); + glPopMatrix(); + } + } + return; +} + +//******************************************** +//To draw atom in style of solid sphere +void VisAtomSample::DrawSolidAtoms(int inbox) +{ + int j, list; + Style Sty; + Sphere Balls=Sphere(); + bool checkin, in; + float x0, x1, y0, y1, z0, z1; + + glEnable(GL_LIGHTING); + Sty.SolidFrontOnly(); + + VisAtomVisualizingPolicy::GetProjectionBox(x0, x1, y0, y1, z0, z1); + if (inbox == VisAtomVisualizingPolicy::D3_STYLE_INBOX) checkin = true; + else checkin = false; + + float shine[] = {0.5f, 0.5f, 0.5f, 1.0f}; + glMaterialfv(GL_FRONT, GL_SPECULAR,shine); + glMateriali(GL_FRONT,GL_SHININESS,100); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + list = Balls.MakeList(); + for(j=0; jm_aVisStat[j] & atom_Statu_Visiable || this->m_aVisStat[j] & atom_Statu_MarkedFound) && + (this->m_aGeomStyle[j] & inbox) && + (this->m_aGeomStyle[j] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) == VisAtomVisualizingPolicy::SHAPE_STYLE_SOLID) + + { + in = (x0 <= m_aPx[j] && m_aPx[j] <= x1) && (y0 <= m_aPy[j] && m_aPy[j] <= y1) && (z0 <= m_aPz[j] && m_aPz[j] <= z1); + if (in == checkin) + { + glPushName(j); + glColor4f(m_aRed[j], m_aGreen[j], m_aBlue[j], 1.f); + glPushMatrix(); + glTranslatef(m_aPx[j], m_aPy[j], m_aPz[j]); + glScalef(m_aRadius[j], m_aRadius[j], m_aRadius[j]); + glCallList(list); + glPopMatrix(); + glPopName(); + } + } + } + return; +} + +//******************************************** +//To draw atom of type I in style of solid sphere +void VisAtomSample::DrawWireAtoms(int inbox) +{ + int j; + Style Sty; + Sphere Balls=Sphere(); + int Balllist; + bool checkin, in; + float x0, x1, y0, y1, z0, z1; + + glEnable(GL_LIGHTING); + Sty.Wire(); + VisAtomVisualizingPolicy::GetProjectionBox(x0, x1, y0, y1, z0, z1); + if (inbox == VisAtomVisualizingPolicy::D3_STYLE_INBOX) checkin = true; + else checkin = false; + + Balllist = Balls.MakeList(); + for(j=0; jm_aVisStat[j] & atom_Statu_MarkedFound) && + (this->m_aGeomStyle[j] & inbox) && + (this->m_aGeomStyle[j] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE) + { + in = (x0 <= m_aPx[j] && m_aPx[j] <= x1) && (y0 <= m_aPy[j] && m_aPy[j] <= y1) && (z0 <= m_aPz[j] && m_aPz[j] <= z1); + if (in == checkin) + { + glPushName(j); + glColor4f(this->m_aRed[j], this->m_aGreen[j], this->m_aBlue[j], 1.f); + glPushMatrix(); + glTranslatef(this->m_aPx[j], this->m_aPy[j], this->m_aPz[j]); + glScalef(this->m_aRadius[j], this->m_aRadius[j], this->m_aRadius[j]); + glCallList(Balllist); + glPopMatrix(); + glPopName(); + } + } + } + + return; +} + + +//******************************************** +//To draw atom of type I in style of dot +void VisAtomSample::DrawDotAtoms(int inbox) +{ + + int j; + bool checkin, in; + float x0, x1, y0, y1, z0, z1; + + VisAtomVisualizingPolicy::GetProjectionBox(x0, x1, y0, y1, z0, z1); + if (inbox == VisAtomVisualizingPolicy::D3_STYLE_INBOX) checkin = true; + else checkin = false; + + glDisable(GL_LIGHTING); + glPointSize(2.f); + for(j=0; jm_aVisStat[j] & atom_Statu_MarkedFound) && + (this->m_aGeomStyle[j] & inbox) && + (this->m_aGeomStyle[j] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_DOT) + { + in = (x0 <= m_aPx[j] && m_aPx[j] <= x1) && (y0 <= m_aPy[j] && m_aPy[j] <= y1) && (z0 <= m_aPz[j] && m_aPz[j] <= z1); + if (in == checkin) + { + glColor4f(this->m_aRed[j], this->m_aGreen[j], this->m_aBlue[j], 1.f); + glPushName(j); + glBegin(GL_POINTS); + glVertex3f(m_aPx[j], m_aPy[j], m_aPz[j]); + glEnd(); + glPopName(); + } + + } + } + + return; +} + +//******************************************************************************* +// to draw atoms in circles +void VisAtomSample::DrawCircleAtoms(int inbox) +{ + + if(m_numAtom <= 0) return; + + double winx, winy, winz; + double winx1, winy1, winz1; + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + bool checkin, in; + float bx0, bx1, by0, by1, bz0, bz1; + + VisAtomVisualizingPolicy::GetProjectionBox(bx0, bx1, by0, by1, bz0, bz1); + if (inbox == VisAtomVisualizingPolicy::D3_STYLE_INBOX) checkin = true; + else checkin = false; + + int i, k, n, NA; + Circle BallsLine=Circle(); + SolidCircle BallsPie=SolidCircle(); + Style Sty=Style(); + + glDisable(GL_LIGHTING); + Sty.SolidFrontOnly(); + //to get current transform matrix + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + glGetIntegerv(GL_VIEWPORT, viewport); + + + //to determine the rotation + double x0, y0, z0, xx0, yy0, zz0, len; + double vx[3], vy[3], vz[3]; + double theta; + + vx[0] = modelMatrix[0]; + vx[1] = modelMatrix[1]; + vx[2] = modelMatrix[2]; + len = vx[0]*vx[0]+vx[1]*vx[1]+vx[2]*vx[2]; + len = sqrt((double)len); + vx[0] = vx[0]/len; + vx[1] = vx[1]/len; + vx[2] = vx[2]/len; + + vy[0] = modelMatrix[4]; + vy[1] = modelMatrix[5]; + vy[2] = modelMatrix[6]; + len = vy[0]*vy[0]+vy[1]*vy[1]+vy[2]*vy[2]; + len = sqrt((double)len); + vy[0] = vy[0]/len; + vy[1] = vy[1]/len; + vy[2] = vy[2]/len; + + vz[0] = modelMatrix[8]; + vz[1] = modelMatrix[9]; + vz[2] = modelMatrix[10]; + len = vz[0]*vz[0]+vz[1]*vz[1]+vz[2]*vz[2]; + len = sqrt((double)len); + vz[0] = vz[0]/len; + vz[1] = vz[1]/len; + vz[2] = vz[2]/len; + + x0 = vx[2]; + y0 = vy[2]; + z0 = vz[2]; + + theta = x0*vz[0]+y0*vz[1]+z0*vz[2]; + theta = acos(z0)*(180.0/3.14159265359); + //The normal of plane (Z,Z') in (X, Y, Z) coordinate system: + xx0 = -y0; + yy0 = x0; + zz0 = 0.0; + BallsLine.SetBorderThick(1.f); + int list1 = BallsPie.MakeList(); + int list2 = BallsLine.MakeList(); + float rad; + for(i=0; im_aVisStat[i] & atom_Statu_Visiable || this->m_aVisStat[i] & atom_Statu_MarkedFound) && + (this->m_aGeomStyle[i] & inbox) && + (((this->m_aGeomStyle[i] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_LINE)|| + ((this->m_aGeomStyle[i] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE)) ) + { + + in = (bx0 <= m_aPx[i] && m_aPx[i] <= bx1) && (by0 <= m_aPy[i] && m_aPy[i] <= by1) && (bz0 <= m_aPz[i] && m_aPz[i] <= bz1); + if (in == checkin) + { + int j = i; + glPushName(j); + glPushMatrix(); + glTranslatef(m_aPx[j], m_aPy[j], m_aPz[j]); + glRotated(theta, xx0, yy0, zz0); + //draw pie + rad = this->m_aRadius[j] * 0.98; + glPushMatrix(); + glScalef(rad, rad, rad); + if ((this->m_aGeomStyle[j] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) == VisAtomVisualizingPolicy::SHAPE_STYLE_LINE) + glColor3f(1.f, 1.f, 1.f); + else + glColor3f(m_aRed[j], m_aGreen[j], m_aBlue[j]); + glCallList(list1); + glPopMatrix(); + //draw edge + glPushMatrix(); + glScalef(rad, rad, rad); + if ((this->m_aGeomStyle[j] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) == VisAtomVisualizingPolicy::SHAPE_STYLE_LINE) + glColor3f(m_aRed[j], m_aGreen[j], m_aBlue[j]); + else + glColor3f(m_aRedex[j], m_aGreenex[j], m_aBlueex[j]); + glCallList(list2); + glPopMatrix(); + + glPopMatrix(); + glPopName(); + } + } + } + + //delete id; + glEnable(GL_LIGHTING); + + return; +} + +//******************************************************************************* +// to draw colormaping bar +void VisAtomSample::DrawColorMappinBar(int lablepos[]) +{ +#define BARW 16 +#define BARH 16*6 + + double winx, winy, winz; + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + double LB[3], RT[3]; + + glGetIntegerv(GL_VIEWPORT, viewport); + glDisable(GL_DEPTH_TEST); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + + //get the object coodination of left-bottom corner of viewport + winx = (double)viewport[0]; + winy = (double)viewport[1]; //(double)(h - viewport[1]); + winz = 0; + gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, + &LB[0], &LB[1], &LB[2]); + //get the object coodination of left-bottom corner of viewport + winx = winx + (double)viewport[2]; + winy = winy + (double)viewport[3]; + winz = 0; + gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, + &RT[0], &RT[1], &RT[2]); + + int nbar = VisAtomVisualizingPolicy::GetColorMappingNumBar(); + double hh = RT[1] - LB[1]; + double step = hh / (nbar - 1); + float R, G, B; + double x1, y1, z1, x2, y2, z2; + x1 = LB[0]; + y1 = LB[1]; + z1 = 0.5*(LB[2] + RT[2]); + x2 = RT[0]; + y2 = y1 + step; + z2 = z1; + glEnable(GL_COLOR_MATERIAL); + int i; + for (i = 0; iGetVolumeX1() - SCENE->GetVolumeX0()); + float vh = viewport[3] - viewport[0]; // (SCENE->GetVolumeY1() - SCENE->GetVolumeY0()); + + float w0 = (SCENE->GetVolumeX1() - SCENE->GetVolumeX0()); + float h0 = (SCENE->GetVolumeY1() - SCENE->GetVolumeY0()); + + double x1, y1, z1, x2, y2, z2; + + int nbar = VisAtomVisualizingPolicy::GetColorMappingNumBar(); + double step, hh; + if(h0>w0) hh = h0; + else hh = w0; + step = hh / (nbar - 1); + float R, G, B; + x1 = -w0*0.5; + y1 = -0.5*hh; // SCENE->GetVolumeY0(); + z1 = SCENE->GetVolumeZ1(); + x2 = w0*0.5; + y2 = y1 + step; + z2 = z1; + glEnable(GL_COLOR_MATERIAL); + + for(int i=0; im_aGeomStyle[j] & inbox) && + (this->m_aGeomStyle[j]&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK)==VisAtomVisualizingPolicy::VECTOR_STYLE_LINE) + { + in = (bx0 <= m_aPx[j] && m_aPx[j] <= bx1) && (by0 <= m_aPy[j] && m_aPy[j] <= by1) && (bz0 <= m_aPz[j] && m_aPz[j] <= bz1); + if (in == checkin) + { + V.ResetStartPoint(m_aPx[j], m_aPy[j], m_aPz[j]); + V.ResetEndPoint(m_aPx[j] + m_vPx[j], m_aPy[j] + m_vPy[j], m_aPz[j] + m_vPz[j]); + glColor3f(m_aRed[j], m_aGreen[j], m_aBlue[j]); + glPushName(j); + V.PaintVertex(); + glPopName(); + } + } + } + glEnable(GL_LIGHTING); + return; +} + +//******************************************************************************* +// to draw solid vectors of atoms +void VisAtomSample::DrawSolidVectors(int inbox) +{ + if(!VisAtomVisualizingPolicy::HasVectorData()) return; + + Style Sty; + Arrow V=Arrow(); + bool checkin, in; + float bx0, bx1, by0, by1, bz0, bz1; + + VisAtomVisualizingPolicy::GetProjectionBox(bx0, bx1, by0, by1, bz0, bz1); + if (inbox == VisAtomVisualizingPolicy::D3_STYLE_INBOX) checkin = true; + else checkin = false; + + glEnable(GL_LIGHTING); + Sty.SolidFrontOnly(); + + float shine[] = {0.5f, 0.5f, 0.5f, 0.6f}; + glMaterialfv(GL_FRONT, GL_SPECULAR,shine); + glMateriali(GL_FRONT,GL_SHININESS,80); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + + int j; + float vrad, vlenscal,arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vrad, vlenscal,arrowl, arrowr); + V.ChangeSize(arrowr); + + for(j=0; jm_aGeomStyle[j] & inbox) && + (this->m_aGeomStyle[j]&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK)==VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID) + { + in = (bx0 <= m_aPx[j] && m_aPx[j] <= bx1) && (by0 <= m_aPy[j] && m_aPy[j] <= by1) && (bz0 <= m_aPz[j] && m_aPz[j] <= bz1); + if (in == checkin) + { + V.ChangeColor(m_aRed[j], m_aGreen[j], m_aBlue[j]); + V.ResetStartPoint(m_aPx[j], m_aPy[j], m_aPz[j]); + V.ResetEndPoint(m_aPx[j] + m_vPx[j], m_aPy[j] + m_vPy[j], m_aPz[j] + m_vPz[j]); + glPushName(j); + V.Paint(); + glPopName(); + } + } + } + return; +} + +//******************************************************************************* +// to draw atomsprojected on box side face +void VisAtomSample::DrawProjSolidAtoms(int nx, int ny, int nz) +{ + + if(m_numAtom <= 0) return; + + + glDisable(GL_DEPTH_TEST); + Style Sty=Style(); + glDisable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + + Sty.Solid(); + + Circle BallsLine=Circle(); + SolidCircle BallsPie=SolidCircle(); + + int list1 = BallsPie.MakeList(); + + //the face postion and rotation axsis + int i, k, tv[3], flag; + float x0, x1, y0, y1, z0, z1, fx, fy, fz, rx, ry, rz, rad, theta; + bool in; + VisAtomVisualizingPolicy::GetProjectionBox(x0, x1, y0, y1, z0, z1); + + + tv[0] = 1 - abs(nx); + tv[1] = 1 - abs(ny); + tv[2] = 1 - abs(nz); + + fx = 0.f; + if(nx > 0) { fx = x1; rx= 0; ry = 1.f; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_X1; } + else if(nx < 0) { fx = x0; rx= 0; ry =-1.f; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_X0;} + + fy = 0.f; + if(ny > 0) { fy = y1; rx= 1.f; ry = 0; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Y1;} + else if(ny < 0) { fy = y0; rx=-1.f; ry = 0; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Y0;} + + fz = 0.f; + if(nz > 0) { fz = z1; rx= 0; ry = 0; rz = 1.f;theta =0.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Z1;} + else if(nz < 0) { fz = z0; rx= 0; ry = 0; rz = 1.f;theta =0.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Z0;} + + + for(i=0; im_aVisStat[i]&atom_Statu_Visiable) && ((this->m_aGeomStyle[i]&flag)== flag) && + ((this->m_aGeomStyle[i]&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_SOLID )) + { + in = (x0 <= m_aPx[i] && m_aPx[i] <= x1) && (y0 <= m_aPy[i] && m_aPy[i] <= y1) && (z0 <= m_aPz[i] && m_aPz[i] <= z1); + if (in) + { + glPushName(i); + glPushMatrix(); + glTranslatef(m_aPx[i] * tv[0] + fx * 0.99, m_aPy[i] * tv[1] + fy * 0.99, m_aPz[i] * tv[2] + fz * 0.99); + glRotatef(theta, rx, ry, rz); + //draw pie + glColor4f(m_aRed[i], m_aGreen[i], m_aBlue[i], 1.f); + glPushMatrix(); + glScalef(m_aRadius[i], m_aRadius[i], m_aRadius[i]); + glCallList(list1); + glPopMatrix(); + + glPopMatrix(); + glPopName(); + } + } + } + //delete id; + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + + return; +} + + +//******************************************************************************* +// to draw atomsprojected on box side face +void VisAtomSample::DrawProjCirleAtoms(int nx, int ny, int nz) +{ + + if(m_numAtom <= 0) return; + + + glDisable(GL_DEPTH_TEST); + Style Sty=Style(); + glDisable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + + Sty.Solid(); + + Circle BallsLine=Circle(); + SolidCircle BallsPie=SolidCircle(); + + BallsLine.SetBorderThick(1.f); + int list1 = BallsPie.MakeList(); + int list2 = BallsLine.MakeList(); + + //the face postion and rotation axsis + int i, k, n, NA, tv[3], flag; + float x0, x1, y0, y1, z0, z1, fx, fy, fz, rx, ry, rz, rad, theta; + bool in; + VisAtomVisualizingPolicy::GetProjectionBox(x0, x1, y0, y1, z0, z1); + + tv[0] = 1 - abs(nx); + tv[1] = 1 - abs(ny); + tv[2] = 1 - abs(nz); + + fx = 0.f; + if(nx > 0) { fx = x1; rx= 0; ry = 1.f; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_X1; } + else if(nx < 0) { fx = x0; rx= 0; ry =-1.f; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_X0;} + + fy = 0.f; + if(ny > 0) { fy = y1; rx= 1.f; ry = 0; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Y1;} + else if(ny < 0) { fy = y0; rx=-1.f; ry = 0; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Y0;} + + fz = 0.f; + if(nz > 0) { fz = z1; rx= 0; ry = 0; rz = 1.f;theta =0.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Z1;} + else if(nz < 0) { fz = z0; rx= 0; ry = 0; rz = 1.f;theta =0.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Z0;} + + + for(i=0; im_aVisStat[i]&atom_Statu_Visiable) && ((this->m_aGeomStyle[i]&flag)== flag) && + (((this->m_aGeomStyle[i]&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_LINE)|| + ((this->m_aGeomStyle[i]&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE)) ) + { + in = (x0 <= m_aPx[i] && m_aPx[i] <= x1) && (y0 <= m_aPy[i] && m_aPy[i] <= y1) && (z0 <= m_aPz[i] && m_aPz[i] <= z1); + if (in) + { + glPushName(i); + //draw cricles + glPushMatrix(); + glTranslatef(m_aPx[i] * tv[0] + fx * 0.99, m_aPy[i] * tv[1] + fy * 0.99, m_aPz[i] * tv[2] + fz * 0.99); + glRotatef(theta, rx, ry, rz); + //draw pie + rad = this->m_aRadius[i] * 0.98; + glPushMatrix(); + glScalef(rad, rad, rad); + if ((this->m_aGeomStyle[i] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) == VisAtomVisualizingPolicy::SHAPE_STYLE_LINE) + glColor3f(1.f, 1.f, 1.f); + else + glColor3f(m_aRed[i], m_aGreen[i], m_aBlue[i]); + glCallList(list1); + glPopMatrix(); + //draw edge + glPushMatrix(); + glScalef(rad, rad, rad); + if ((this->m_aGeomStyle[i] & VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) == VisAtomVisualizingPolicy::SHAPE_STYLE_LINE) + glColor3f(m_aRed[i], m_aGreen[i], m_aBlue[i]); + else + glColor3f(m_aRedex[i], m_aGreenex[i], m_aBlueex[i]); + glCallList(list2); + glPopMatrix(); + + glPopMatrix(); + glPopName(); + + } + } + } + + //delete id; + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + + return; +} + + +//******************************************************************************* +// to draw atomsprojected on box side face +void VisAtomSample::DrawProjDotAtoms(int nx, int ny, int nz) +{ + + if(m_numAtom <= 0) return; + + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + + //the face postion and rotation axsis + int i, k, tv[3], flag; + float x0, x1, y0, y1, z0, z1, fx, fy, fz, rx, ry, rz, theta; + bool in; + VisAtomVisualizingPolicy::GetProjectionBox(x0, x1, y0, y1, z0, z1); + + tv[0] = 1 - abs(nx); + tv[1] = 1 - abs(ny); + tv[2] = 1 - abs(nz); + + fx = 0.f; + if(nx > 0) { fx = x1; rx= 0; ry = 1.f; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_X1; } + else if(nx < 0) { fx = x0; rx= 0; ry =-1.f; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_X0;} + + fy = 0.f; + if(ny > 0) { fy = y1; rx= 1.f; ry = 0; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Y1;} + else if(ny < 0) { fy = y0; rx=-1.f; ry = 0; rz = 0;theta =90.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Y0;} + + fz = 0.f; + if(nz > 0) { fz = z1; rx= 0; ry = 0; rz = 1.f;theta =0.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Z1;} + else if(nz < 0) { fz = z0; rx= 0; ry = 0; rz = 1.f;theta =0.f; flag = VisAtomVisualizingPolicy::PROJECTION_STYLE_Z0;} + + + for(i=0; im_aVisStat[i]&atom_Statu_Visiable) && ((this->m_aGeomStyle[i]&flag)== flag) && + (this->m_aGeomStyle[i]&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK)==VisAtomVisualizingPolicy::SHAPE_STYLE_DOT) + { + in = (x0 <= m_aPx[i] && m_aPx[i] <= x1) && (y0 <= m_aPy[i] && m_aPy[i] <= y1) && (z0 <= m_aPz[i] && m_aPz[i] <= z1); + if (in) + { + glColor4f(this->m_aRed[i], this->m_aGreen[i], this->m_aBlue[i], 1.f); + glPushName(i); + glBegin(GL_POINTS); + glVertex3f(m_aPx[i] * tv[0] + fx * 0.99, m_aPy[i] * tv[1] + fy * 0.99, m_aPz[i] * tv[2] + fz * 0.99); + glEnd(); + glPopName(); + } + } + } + + //delete id; + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + + return; +} + + + +//To get the ID of current picked atom (in current sample) +int VisAtomSample::GetCurAtom() +{ + return m_pickedAtomID; +} + +//To set the atom id as current picked atom (in current sample) +void VisAtomSample::SetCurAtom(int id) +{ + if(id > m_numAtom) return; + m_pickedAtomID = id; +} + +//To get the type of current picked atom (in current sample) +int VisAtomSample::GetTypeofCurAtom() +{ + if(m_pickedAtomID <= 0) return -1; + return m_aType[m_pickedAtomID-1]; +} + +//To get the X coordinate of current picked atom (in current sample) +float VisAtomSample::GetXofCurAtom() +{ + if(m_pickedAtomID <=0) return -(float)1.E38; + return m_aPx[m_pickedAtomID-1]; +} + + +//To get the Y coordinate of current picked atom (in current sample) +float VisAtomSample::GetYofCurAtom() +{ + if(m_pickedAtomID <=0) return -(float)1.E38; + return m_aPy[m_pickedAtomID-1]; +} + + +//To get the Z coordinate of current picked atom (in current sample) +float VisAtomSample::GetZofCurAtom() +{ + if(m_pickedAtomID <=0) return -(float)1.E38; + return m_aPz[m_pickedAtomID-1]; +} + + + +//To set atom id as selected +void VisAtomSample::Select_aAtom(int id) +{ + if(id > m_numAtom) return; + if(id <= 0) return; + int i = id-1; + this->m_aVisStat[i] = this->m_aVisStat[i]|atom_Statu_Selected; + return; +} + +//To set the current atom as selected +void VisAtomSample::Select_aAtom() +{ + int id = GetCurAtom(); + if(id <=0) return; + Select_aAtom(id); +} + +void VisAtomSample::MarkAtomsFound(int from, int to, int step) +{ + for (int i = from; i <= to; i+=step) + { + if (1 <= i && i <= m_numAtom) + { + this->m_aVisStat[i - 1] = this->m_aVisStat[i - 1] | atom_Statu_MarkedFound; + } + } + return; +} + +void VisAtomSample::MarkGroupAtomsFound(int group, int from, int to) +{ + int ip = 0; + for (int i = 0; i < this->m_numAtom; i++) + { + if (this->m_aType[i] == group) + { + ip++; + if (ip >= from && ip <= to) + { + this->m_aVisStat[i] = this->m_aVisStat[i] | atom_Statu_MarkedFound; + } + } + } + return; +} + +void VisAtomSample::GeNextAtomMarkedFound(int ith, int&gid, int&ingr, float&posx, float&posy, float&posz) +{ + int ip, i0, i; + + i0 = ith; + if (ith <= 0) i0 = 0; + + gid = 0; + ingr = 0; + ip = 0; + for (int i = 0; i < this->m_numAtom; i++) + { + if( this->m_aVisStat[i] & atom_Statu_MarkedFound ) + { + if (ip == i0) + { + gid = i + 1; + ingr = this->m_aType[i]; + posx = this->m_aPx[i]; + posy = this->m_aPy[i]; + posz = this->m_aPz[i]; + break; + } + ip++; + } + } +} + + + +//To set an atom as unselected +void VisAtomSample::unSelect_aAtom(int id) +{ + if(id > m_numAtom) return; + if(id <= 0) return; + int i = id-1; + int j,k; + k = this->m_aVisStat[i]&atom_Statu_Visiable; + j = (this->m_aVisStat[i]>>2); + this->m_aVisStat[i] = (j<<2); + this->m_aVisStat[i] = this->m_aVisStat[i]|k; + //astatu[i] = astatu[i]|atom_Statu_Selected; + return; +} + +//To set the current picked atom as unselected +void VisAtomSample::unSelect_aAtom() +{ + int id = GetCurAtom(); + if(id <=0) return; + unSelect_aAtom(id); +} + +void VisAtomSample::unSelect_Atoms(int from, int to) +{ + for (int i = from; i <= to; i++) + { + this->unSelect_aAtom(i); + } + return; +} + + +//To set an atom as unselected +void VisAtomSample::unSelect_AllAtoms() +{ + int i,j, k; + for(i=0; im_aVisStat[i]&atom_Statu_Visiable; + j = (this->m_aVisStat[i]>>2); + this->m_aVisStat[i] = (j<<2); + this->m_aVisStat[i] = this->m_aVisStat[i]|k; + } + m_pickedAtomID = -1; + return; +} + +//To remove the found mark of atoms +void VisAtomSample::RemoveAtomsFoundMark() +{ + int i, j, k; + for (i = 0; im_aVisStat[i] & atom_Statu_MarkedFound) + { + k = this->m_aVisStat[i] & atom_Statu_Visiable; + j = (this->m_aVisStat[i] >> 3); + this->m_aVisStat[i] = (j << 3); + this->m_aVisStat[i] = this->m_aVisStat[i] | k; + } + } + return; +} + + + +//To get the number of atoms that are visiable +int VisAtomSample::NumberofVisiableAtom() +{ + int i, count; + + count = 0; + for(i=0; im_aVisStat[i]&atom_Statu_Visiable) count ++; + + return count; +} + + +//To get if the samples changed +int VisAtomSample::IfChanged() +{ + return statu; +} + +//To set all the samples in unchanged statu +void VisAtomSample::FinishChange() +{ + statu = sample_Statu_noChange; + return; +} + + +//To move a atom picked +int VisAtomSample::Move_aAtom(float dx, float dy, float dz) +{ + if(m_pickedAtomID <= 0) return 0; + int i = m_pickedAtomID-1; + m_aPx[i] = m_aPx[i]+dx; + m_aPy[i] = m_aPy[i]+dy; + m_aPz[i] = m_aPz[i]+dz; + statu = sample_Statu_Changed; + return m_pickedAtomID; +} + +//To move atoms that are selected +void VisAtomSample::Move_SelectedAtoms(float dx, float dy, float dz) +{ + if(m_pickedAtomID <= 0) return; + int i; + for(i=0; im_aVisStat[i]&atom_Statu_Selected) + { + m_aPx[i] = m_aPx[i]+dx; + m_aPy[i] = m_aPy[i]+dy; + m_aPz[i] = m_aPz[i]+dz; + } + } + statu = sample_Statu_Changed; + return; +} + + +//To translate the atoms(subsample) of type I +void VisAtomSample::Move_aAtomGroup(int I, float dx, float dy, float dz) +{ + int i; + for(i=0; iGetVolumeX0(); + yy0 = SCENE->GetVolumeY0(); + zz0 = SCENE->GetVolumeZ0(); + xx1 = SCENE->GetVolumeX1(); + yy1 = SCENE->GetVolumeY1(); + zz1 = SCENE->GetVolumeZ1(); + dist = SCENE->GetDistance(); + scenestyle = SCENE->GetStyle(); + //be careful to adpted this part according to SCEN->create + float w =(float)viewport[2]; + float h =(float)viewport[3]; + if(w == 0.f ) w = 1.f; + if(h == 0.f) h = 1.f; + if((scenestyle&scene_Style_Perspective) != scene_Style_Perspective) + { + double width, height; + width = (xx1-xx0); + if(width < 0.0) width = -width; + height = (yy1-yy0); + if(height < 0.0) height = -height; + width = std::max(width, height); + if (w <= h) + glOrtho (xx0, xx0+width, yy0*h/w, (yy0+width)*h/w, zz0, zz1); + else + glOrtho (xx0*w/h, (xx0+width)*w/h, yy0, (yy0+width), zz0, zz1); + } + else + { + double nearz = zz0; + if(nearz < 0.0) nearz = -nearz; + if(nearz == 0.0 ) nearz = 1.0; + nearz = nearz+dist; + double farz = 10.*(zz1-zz0)+nearz; + double ang = atan((yy1-yy0)/nearz/2.0)*180.0/3.1415926; + gluPerspective(ang, w/h, nearz, farz); + glTranslatef(0.f, 0.f, (float)(-2.5*nearz + zz0)); + } + //Initialize names + glInitNames(); + // Draw the scene + this->Paint(); + glFlush(); + // Collect the hits + hits = glRenderMode(GL_RENDER); + if(hits>0) + { + // To determine which one on the top + flag = selectBuff[1]; + id = selectBuff[3]; + for(i=1; i 0) + { + flag = m_pickedAtomID-1; + i = this->m_aVisStat[flag]&atom_Statu_Visiable; + j = (this->m_aVisStat[flag]>>2); + this->m_aVisStat[flag] = (j<<2); + this->m_aVisStat[flag] = this->m_aVisStat[flag]|i; + } + //To set the picked atom as current and make it as selected + m_pickedAtomID = id+1; + this->m_aVisStat[id] = this->m_aVisStat[id]|atom_Statu_Selected; + m_pick_statu = atom_pick_Statu_picked; + } + else // the current atom has been picked twice + { + //To set the picked atom as current and make it as selected + id = m_pickedAtomID - 1; + this->m_aVisStat[id] = this->m_aVisStat[id] | atom_Statu_Selected; + m_pick_statu = atom_pick_Statu_doublepicked; + } + // To get the position of current atom + (*curX) = GetXofCurAtom(); + (*curY) = GetYofCurAtom(); + (*curZ) = GetZofCurAtom(); + } + else + { + //To un select the old picked atom + if(m_pickedAtomID > 0) + { + flag = m_pickedAtomID-1; + i = this->m_aVisStat[flag]&atom_Statu_Visiable; + j = (this->m_aVisStat[flag]>>2); + this->m_aVisStat[flag] = (j<<2); + this->m_aVisStat[flag] = this->m_aVisStat[flag]|i; + } + m_pickedAtomID = -1; + m_pick_statu = atom_pick_Statu_nopicked; + } + + // Restore the projection matrix + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + delete selectBuff; + + // Go back to modelview for normal rendering + glMatrixMode(GL_MODELVIEW); + return m_pick_statu; +} + + +//To process pick mutiple atoms in current sample +int VisAtomSample::PickMultiple(int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + // Space for selection buffer + GLuint*selectBuff; + int i,j,id,n; + GLuint flag; + // Hit counter and viewport storeage + GLint hits, viewport[4]; + double xx0, yy0, zz0, xx1, yy1, zz1; + int scenestyle; + + if(m_numAtom <= 0) return atom_pick_Statu_nopicked; + // store the current position + m_pick_posx = xPos; + m_pick_posy = yPos; + // Setup selection buffer + n = 4*m_numAtom; + selectBuff = NULL; + selectBuff = new GLuint[n]; + glSelectBuffer(n, selectBuff); + // Change render mode + glRenderMode(GL_SELECT); + // Get the viewport + glGetIntegerv(GL_VIEWPORT, viewport); + // Switch to projection and save the matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + + glLoadIdentity(); + gluPickMatrix(xPos, viewport[3]-yPos, 3, 3, viewport); + + // Apply perspective matrix + xx0 = SCENE->GetVolumeX0(); + yy0 = SCENE->GetVolumeY0(); + zz0 = SCENE->GetVolumeZ0(); + xx1 = SCENE->GetVolumeX1(); + yy1 = SCENE->GetVolumeY1(); + zz1 = SCENE->GetVolumeZ1(); + scenestyle = SCENE->GetStyle(); + float w =(float)viewport[2]; + float h =(float)viewport[3]; + if(w == 0.f ) w = 1.f; + if(h == 0.f) h = 1.f; + if((scenestyle&scene_Style_Perspective) != scene_Style_Perspective) + { + double width, height; + width = (xx1-xx0); + if(width < 0.0) width = -width; + height = (yy1-yy0); + if(height < 0.0) height = -height; + width = std::max(width, height); + if (w <= h) + glOrtho (xx0, xx0+width, yy0*h/w, (yy0+width)*h/w, zz0, zz1); + else + glOrtho (xx0*w/h, (xx0+width)*w/h, yy0, (yy0+width), zz0, zz1); + } + else + { + double nearz = zz0; + if(nearz < 0.0) nearz = -nearz; + if(nearz == 0.0 ) nearz = 1.0; + double farz = 10.*(zz1-zz0)+nearz; + double ang = atan((yy1-yy0)/nearz/2.0)*180.0/3.1415926; + gluPerspective(ang, w/h, nearz, farz); + } + //Initialize names + glInitNames(); + // Draw the scene + this->Paint(); + glFlush(); + // Collect the hits + hits = glRenderMode(GL_RENDER); + if(hits>0) + { + // To determine which one on the top + flag = selectBuff[1]; + id = selectBuff[3]; + for(i=1; im_aVisStat[id]&atom_Statu_Selected) + { + m_pick_statu = atom_pick_Statu_doublepicked; + } + else + { + this->m_aVisStat[id] = this->m_aVisStat[id]|atom_Statu_Selected; + m_pick_statu = atom_pick_Statu_picked; + } + } + else // the current atom has been picked twice + { + id = m_pickedAtomID - 1; + this->m_aVisStat[id] = this->m_aVisStat[id] | atom_Statu_Selected; + m_pick_statu = atom_pick_Statu_doublepicked; + } + // To get the position of current atom + (*curX) = GetXofCurAtom(); + (*curY) = GetYofCurAtom(); + (*curZ) = GetZofCurAtom(); + } + else + { + //To un select the old picked atoms + for(id=0; idm_aVisStat[id]&atom_Statu_Selected) + { + i = this->m_aVisStat[id]&atom_Statu_Visiable; + j = (this->m_aVisStat[id]>>2); + this->m_aVisStat[id] = (j<<2); + this->m_aVisStat[id] = this->m_aVisStat[id]|i; + } + } + m_pickedAtomID = -1; + m_pick_statu = atom_pick_Statu_nopicked; + } + + // Restore the projection matrix + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + delete selectBuff; + + // Go back to modelview for normal rendering + glMatrixMode(GL_MODELVIEW); + return m_pick_statu; +} + + +//To pick atoms define by a square +int VisAtomSample::PickSquare(int flag, int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + static float left, right, top, bottom; + + double winx, winy, winz; + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + + glGetIntegerv(GL_VIEWPORT, viewport); + + winx = (double)xPos; + winy = (double)(viewport[3]-yPos); + winz = 100.0; + + switch (flag) + { + case 0: //start pick + unSelect_AllAtoms(); + left = (float)winx; + top = (float)winy; + m_pick_statu = atom_pick_Statu_nopicked; + return m_pick_statu; + case 1: //Move + right = (float)winx; + bottom = (float)winy; + m_pick_statu = atom_pick_Statu_nopicked; + return m_pick_statu; + case 2: + { + float xmi, xma, ymi, yma; + xmi = std::min(left, right); + xma = std::max(left, right); + ymi = std::min(top, bottom); + yma = std::max(top, bottom); + + int i; + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + + for(i=0; im_aVisStat[i]&atom_Statu_Visiable) + { + gluProject(m_aPx[i], m_aPy[i], m_aPz[i], modelMatrix, projMatrix, viewport, + &winx, &winy, &winz); + if((winx >= xmi) && (winx <= xma)&&(winy >= ymi) && (winy <= yma)) + this->m_aVisStat[i] = this->m_aVisStat[i]|atom_Statu_Selected; + } + } + m_pick_statu = atom_pick_Statu_picked; + return m_pick_statu; + } + case 3: + { + // store the current position + float xmi, xma, ymi, yma; + xmi = std::min(left, right); + xma = std::max(left, right); + ymi = std::min(top, bottom); + yma = std::max(top, bottom); + + if((winx >= xmi) && (winx <= xma)&&(winy >= ymi) && (winy <= yma)) + { + m_pick_posx = xPos; + m_pick_posy = yPos; + m_pick_statu = atom_pick_Statu_doublepicked; + } + return m_pick_statu; + } + + } + return atom_pick_Statu_nopicked; +} + +//To process pick tri-atoms +int VisAtomSample::PickTriPoints(int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + // Space for selection buffer + GLuint*selectBuff; + int i,j,id,n; + GLuint flag; + // Hit counter and viewport storeage + GLint hits, viewport[4]; + double xx0, yy0, zz0, xx1, yy1, zz1; + int scenestyle; + static int tristatu = 0; + static float v1[3], v2[3], v3[3]; + + if(m_numAtom <= 0) return atom_pick_Statu_nopicked; + if(m_pick_statu == atom_pick_Statu_nopicked) tristatu = 0; + if(tristatu == 0) unSelect_AllAtoms(); + + // store the current position + m_pick_posx = xPos; + m_pick_posy = yPos; + // Setup selection buffer + n = 4*m_numAtom; + selectBuff = NULL; + selectBuff = new GLuint[n]; + glSelectBuffer(n, selectBuff); + // Change render mode + glRenderMode(GL_SELECT); + // Get the viewport + glGetIntegerv(GL_VIEWPORT, viewport); + // Switch to projection and save the matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + + glLoadIdentity(); + gluPickMatrix(xPos, viewport[3]-yPos, 3, 3, viewport); + + // Apply perspective matrix + xx0 = SCENE->GetVolumeX0(); + yy0 = SCENE->GetVolumeY0(); + zz0 = SCENE->GetVolumeZ0(); + xx1 = SCENE->GetVolumeX1(); + yy1 = SCENE->GetVolumeY1(); + zz1 = SCENE->GetVolumeZ1(); + scenestyle = SCENE->GetStyle(); + float w =(float)viewport[2]; + float h =(float)viewport[3]; + if(w == 0.f ) w = 1.f; + if(h == 0.f) h = 1.f; + if((scenestyle&scene_Style_Perspective) != scene_Style_Perspective) + { + double width, height; + width = (xx1-xx0); + if(width < 0.0) width = -width; + height = (yy1-yy0); + if(height < 0.0) height = -height; + width = std::max(width, height); + if (w <= h) + glOrtho (xx0, xx0+width, yy0*h/w, (yy0+width)*h/w, zz0, zz1); + else + glOrtho (xx0*w/h, (xx0+width)*w/h, yy0, (yy0+width), zz0, zz1); + } + else + { + double nearz = zz0; + if(nearz < 0.0) nearz = -nearz; + if(nearz == 0.0 ) nearz = 1.0; + double farz = 10.*(zz1-zz0)+nearz; + double ang = atan((yy1-yy0)/nearz/2.0)*180.0/3.1415926; + gluPerspective(ang, w/h, nearz, farz); + } + //Initialize names + glInitNames(); + // Draw the scene + this->Paint(); + glFlush(); + // Collect the hits + hits = glRenderMode(GL_RENDER); + if(hits>0) + { + // To determine which one on the top + flag = selectBuff[1]; + id = selectBuff[3]; + for(i=1; im_aVisStat[id]&atom_Statu_Selected) ) + { + this->m_aVisStat[id] = this->m_aVisStat[id]|atom_Statu_Selected; + tristatu ++; + m_pick_statu = atom_pick_Statu_picked; + } + } + + // To get the position of current atom + (*curX) = GetXofCurAtom(); + (*curY) = GetYofCurAtom(); + (*curZ) = GetZofCurAtom(); + + switch (tristatu) + { + case 1: + { + v1[0] = m_aPx[id]; + v1[1] = m_aPy[id]; + v1[2] = m_aPz[id]; + break; + } + case 2: + { + v2[0] = m_aPx[id]; + v2[1] = m_aPy[id]; + v2[2] = m_aPz[id]; + break; + } + case 3: + { + v3[0] = m_aPx[id]; + v3[1] = m_aPy[id]; + v3[2] = m_aPz[id]; + + float vv1[3], vv2[3]; + vv1[0] = v1[0]-v3[0]; + vv1[1] = v1[1]-v3[1]; + vv1[2] = v1[2]-v3[2]; + vv2[0] = v2[0]-v3[0]; + vv2[1] = v2[1]-v3[1]; + vv2[2] = v2[2]-v3[2]; + + float a1, a2, a3, d, d1; + + a1 = vv1[1]*vv2[2]-vv1[2]*vv2[1]; + a2 = vv1[2]*vv2[0]-vv1[0]*vv2[2]; + a3 = vv1[0]*vv2[1]-vv1[1]*vv2[0]; + + d = a1*v3[0]+a2*v3[1]+a3*v3[2]; + for(i=0; i= 0) + { + if(d1 >= d) this->m_aVisStat[i] = this->m_aVisStat[i]|atom_Statu_Selected; + } + else + { + if(d1 <= d) this->m_aVisStat[i] = this->m_aVisStat[i]|atom_Statu_Selected; + } + } + + m_pick_statu = atom_pick_Statu_doublepicked; + tristatu = 0; + break; + } + } + } + + // Restore the projection matrix + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + delete selectBuff; + + // Go back to modelview for normal rendering + glMatrixMode(GL_MODELVIEW); + return m_pick_statu; +} + + +//To process move single picked +int VisAtomSample::MovePickedAtom(int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + + if(m_pick_statu == atom_pick_Statu_doublepicked) + { + switch(m_pick_style) + { + case atom_pick_Option_Single: + return MoveSinglePicked(xPos, yPos, SCENE, curX, curY, curZ); + case atom_pick_Option_Multiple: + return MoveMultiplePicked(xPos, yPos, SCENE, curX, curY, curZ); + case atom_pick_Option_Subsample: + return MoveSubsamplePicked(xPos, yPos, SCENE, curX, curY, curZ); + //case atom_pick_Option_Square: + // return MoveSquarePicked(xPos, yPos, SCENE); + } + } + else + { + switch(m_pick_style) + { + case atom_pick_Option_Square: + return PickSquare(1, xPos, yPos, SCENE,curX, curY, curZ); + } + } + return 0; +} + + +//To process move single picked +int VisAtomSample::MoveSinglePicked(int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + + float x0,y0,z0; + float x1,y1,z1; + double winx, winy, winz, objx, objy, objz; + int ID, Type; + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + + glGetIntegerv(GL_VIEWPORT, viewport); + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + + InformPickedAtom(&ID, &Type, &x0, &y0, &z0); + + objx = x0; + objy = y0; + objz = z0; + gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, + &winx, &winy, &winz); + + winx = (double)xPos; + winy = (double)(viewport[3]-yPos); + + gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, + &objx, &objy, &objz); + + x1 = objx - x0; + y1 = objy - y0; + z1 = objz - z0; + + (*curX) = objx; + (*curY) = objy; + (*curZ) = objz; + if(xPos == m_pick_posx|yPos == m_pick_posy) return sample_Statu_noChange; + + return Move_aAtom(x1, y1, z1); +} + + +//To process move single picked +int VisAtomSample::MoveMultiplePicked(int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + + float x0,y0,z0; + float x1,y1,z1; + double winx, winy, winz, objx, objy, objz; + int ID, Type; + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + + glGetIntegerv(GL_VIEWPORT, viewport); + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + + InformPickedAtom(&ID, &Type, &x0, &y0, &z0); + + objx = x0; + objy = y0; + objz = z0; + gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, + &winx, &winy, &winz); + + winx = (double)xPos; + winy = (double)(viewport[3]-yPos); + + gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, + &objx, &objy, &objz); + + x1 = (float)(objx - x0); + y1 = (float)(objy - y0); + z1 = (float)(objz - z0); + + (*curX) = objx; + (*curY) = objy; + (*curZ) = objz; + + if(xPos == m_pick_posx|yPos == m_pick_posy) return sample_Statu_noChange; + + Move_SelectedAtoms(x1, y1, z1); + return 1; +} + +//To process move subsample picked +int VisAtomSample::MoveSubsamplePicked(int xPos, int yPos, Scene*SCENE, float*curX, float*curY, float*curZ) + { + + float x0,y0,z0; + float x1,y1,z1; + double winx, winy, winz, objx, objy, objz; + int ID, Type; + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + + glGetIntegerv(GL_VIEWPORT, viewport); + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + + InformPickedAtom(&ID, &Type, &x0, &y0, &z0); + + objx = x0; + objy = y0; + objz = z0; + gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, + &winx, &winy, &winz); + + winx = (double)xPos; + winy = (double)(viewport[3]-yPos); + + gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, + &objx, &objy, &objz); + + x1 = (float)(objx - x0); + y1 = (float)(objy - y0); + z1 = (float)(objz - z0); + + + (*curX) = objx; + (*curY) = objy; + (*curZ) = objz; + + if(xPos == m_pick_posx|yPos == m_pick_posy) return sample_Statu_noChange; + + Move_aAtomGroup(x1, y1, z1); + return 1; +} + + + +//To process move and drop +int VisAtomSample::DropPickedAtom(int xPos, int yPos, Scene*SCENE,float*curX, float*curY, float*curZ) + { + + if(m_pick_statu == atom_pick_Statu_doublepicked) + { + switch(m_pick_style) + { + case atom_pick_Option_Single: + case atom_pick_Option_Multiple: + case atom_pick_Option_Subsample: + case atom_pick_Option_Square: + return DropSinglePicked(xPos, yPos, SCENE); + case atom_pick_Option_Tripoints: + return DropSinglePicked(xPos, yPos, SCENE); + } + } + else + { + if(m_pick_statu == atom_pick_Statu_nopicked) + { + switch(m_pick_style) + { + case atom_pick_Option_Square: + PickSquare(2, xPos, yPos, SCENE, curX, curY, curZ); + m_pick_statu = atom_pick_Statu_nopicked; + statu = sample_Statu_noChange; + return statu; + } + } + /// + } + return 0; +} + + +//To drop the picked atom to position +int VisAtomSample::DropSinglePicked(int xPos, int yPos, Scene*SCENE) +{ + //int i = MoveSinglePicked(xPos, yPos, SCENE); + if(m_pick_statu == atom_pick_Statu_nopicked) return sample_Statu_noChange; + if(xPos == m_pick_posx|yPos == m_pick_posy) return sample_Statu_noChange; + m_pick_statu = atom_pick_Statu_nopicked; + statu = sample_Statu_noChange; + return sample_Statu_Changed; +} + + +//To get information about the picked atom +int VisAtomSample::InformPickedAtom(int*ID, int*Type, float*xPos, float*yPos, float*zPos) +{ + + if( (m_pick_statu == atom_pick_Statu_picked) ||(m_pick_statu == atom_pick_Statu_doublepicked)) + { + switch(m_pick_style) + { + case atom_pick_Option_Single: + case atom_pick_Option_Multiple: + case atom_pick_Option_Subsample: + return Inf_of_SinglePicked(ID, Type, xPos, yPos, zPos); + } + } + return 0; +} + +//To get information about the picked atom +int VisAtomSample::Inf_of_SinglePicked(int*ID, int*Type, float*xPos, float*yPos, float*zPos) +{ + if(m_pick_statu == atom_pick_Statu_nopicked) return atom_pick_Statu_nopicked; + if(m_pickedAtomID <= 0) return atom_pick_Statu_nopicked; + int i= m_pickedAtomID-1; + (*ID) = m_pickedAtomID; + (*Type) = m_aType[i]; + (*xPos) = m_aPx[i]; + (*yPos) = m_aPy[i]; + (*zPos) = m_aPz[i]; + return m_pick_statu; +} + + +//To get the type of atoms in sample +int VisAtomSample::GetSampleType(int*TYPE) +{ + // i: the index of subsample + int i; + for(i=0; im_aVisStat[i]&atom_Statu_Deleted) return; + this->m_aVisStat[i] = this->m_aVisStat[i]|atom_Statu_Visiable; + return; +} +//To show a atom of current picked +inline void VisAtomSample::Show_aAtom() +{ + if(m_pickedAtomID <=0) return; + Show_aAtom(m_pickedAtomID); +} + +//To hide a atom with id +inline void VisAtomSample::Hide_aAtom(int id) +{ + int i = id-1; + int j; + j = (this->m_aVisStat[i]>>1); + this->m_aVisStat[i] = (j<<1); + return; +} +//To hide current picked atom +inline void VisAtomSample::Hide_aAtom() +{ + if(m_pickedAtomID <=0) return; + Hide_aAtom(m_pickedAtomID); +} + + +//To show the selected atoms +void VisAtomSample::Show_SelectedAtoms( ) +{ + int i; + for(i=0; im_aVisStat[i]&atom_Statu_Selected)Show_aAtom(i+1); + return; + +} + +//To hide the selected atoms +void VisAtomSample::Hide_SelectedAtoms( ) +{ + int i,j; + for(i=0; im_aVisStat[i]&atom_Statu_Selected) + { + j = (this->m_aVisStat[i]>>2); + this->m_aVisStat[i] = (j<<2); + } + } + return; +} + + +//To show the unselected atoms +void VisAtomSample::Show_unSelectedAtoms( ) +{ + int i; + for(i=0; im_aVisStat[i]&atom_Statu_Selected)) Show_aAtom(i+1); + return; +} + +//To show the unselected atoms +void VisAtomSample::Hide_unSelectedAtoms( ) +{ + int i; + for(i=0; im_aVisStat[i]&atom_Statu_Selected)) Hide_aAtom(i+1); + return; +} + +//To show all atoms in active sample +void VisAtomSample::Show_AllAtoms( ) +{ + int i; + for(i=0; iClear(true); + this->m_pData = pData; + + this->m_numAtom = pData->GetNumRow(); + this->m_aType = new char[m_numAtom]; + this->m_aPx = new float[m_numAtom]; + this->m_aPy = new float[m_numAtom]; + this->m_aPz = new float[m_numAtom]; + this->m_aVisStat = new char [m_numAtom]; + this->m_aRadius = new float[m_numAtom]; + this->m_aRed = new float[m_numAtom]; + this->m_aGreen = new float[m_numAtom]; + this->m_aBlue = new float[m_numAtom]; + this->m_aRedex = new float[m_numAtom]; + this->m_aGreenex = new float[m_numAtom]; + this->m_aBlueex = new float[m_numAtom]; + this->m_aGeomStyle = new int[m_numAtom]; + this->m_vPx = new float[m_numAtom]; memset(this->m_vPx, 0, sizeof(float)*this->m_numAtom); + this->m_vPy = new float[m_numAtom]; memset(this->m_vPy, 0, sizeof(float)*this->m_numAtom); + this->m_vPz = new float[m_numAtom]; memset(this->m_vPz, 0, sizeof(float)*this->m_numAtom); + + //We also set the data sheet for mapping-color + VisAtomVisualizingPolicy::SetDataSheet(pData); + + int i,j, col; + float*dcol; + + //set type + col = m_pData->GetTypeCol(); + if(col >= 0) + { + dcol = m_pData->GetData(col); + for(i=0; iGetPosXCol(); + dcol = m_pData->GetData(col); + for(i=0; iGetPosYCol(); + dcol = m_pData->GetData(col); + for(i=0; iGetPosZCol(); + dcol = m_pData->GetData(col); + for(i=0; iHasBoxSize()) + { + pData->GetBoxSize(this->m_aXmi, this->m_aXmx, + this->m_aYmi, this->m_aYmx, + this->m_aZmi, this->m_aZmx); + } + else + this->AutoSampleBoxRange(); + + //set all visible + for(i=0; im_aVisStat[i] = VisAtomSubSample::SUBSAMPLE_VISIABLE; + //determine how many kind of atom we have + int nmin,nmax; + nmax = 0; nmin = 10000000; + for(i=0; i nmax) nmax = m_aType[i]; + else if(m_aType[i] < nmin) nmin = m_aType[i]; + } + //if there is already subsample list, use old subsample information + //otherwise, create defaut subsamples,a subsample is constructed by atoms of the same type + int ns = this->m_subSamples.count()+1; + float rad, scal; + this->GetDefaultAtomRadiu(rad, scal); + for(i=ns; i<=nmax; i++) + { + VisAtomSubSample*p = new VisAtomSubSample(i); + this->m_subSamples.append(p); + this->m_selSubsamples.append(0); + // create default properties for this subsample + p->SetCurAtomSize(rad); + } + //restore the display policy of subsamples + for(i=0; im_subSamples.count(); i++) + { + this->m_subSamples[i]->SetDataSheet(pData); + if(VisAtomVisualizingPolicy::GetScalarCol() < 0) + { + this->m_subSamples[i]->SetCurVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + } + //this->m_subSamples[i]->SetCurVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + this->LoadSubsampleProp(i); + } + this->SetCurrentSubsample(0); + + + //to update the projection box size + if(VisAtomVisualizingPolicy::IsAutoProjectionBox()) + { + VisAtomVisualizingPolicy::SetProjectionBox(this->m_aXmi, this->m_aXmx, this->m_aYmi, this->m_aYmx, this->m_aZmi, this->m_aZmx); + } + return; +} + +void VisAtomSample::LoadSubsampleProp(int is) +{ + float r, g, b, a, rad; + int i, geomstyle; + VisAtomSubSample*p = this->m_subSamples[is]; + geomstyle = p->GetCurGeometryStyle(); + + int col[3], hasvect; + float*vpx, *vpy, *vpz, vrad, vlenscal; + VisAtomVisualizingPolicy::GetVectorCol(col); + hasvect = VisAtomVisualizingPolicy::HasVectorData(); + if(hasvect) + { + vpx = this->m_pData->GetData(col[0]); + vpy = this->m_pData->GetData(col[1]); + vpz = this->m_pData->GetData(col[2]); + VisAtomVisualizingPolicy::GetVectorSize(vrad, vlenscal); + } + + for(i=0; im_numAtom; i++) + { + if(p->CheckMembership(this->m_aType[i], this->m_aPx[i], this->m_aPy[i], this->m_aPz[i])) + { + //load basic atom properties + p->GetCurAtomSize(i, this->m_aRadius[i]); + //this->m_aRadius[i] = rad; + this->m_aGeomStyle[i] = geomstyle; + if((geomstyle&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) == VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE) + { + if(p->GetCurVisualPolicy()->GetColorStyle() == VisAtomVisualizingPolicy::COLOR_STYLE_MAP) + { + p->GetCurColor(r, g, b, a, i); + this->m_aRed[i] = r; + this->m_aGreen[i] = g; + this->m_aBlue[i] = b; + + p->GetColor(r, g, b, a, i, 0); + this->m_aRedex[i] = r; + this->m_aGreenex[i] = g; + this->m_aBlueex[i] = b; + } + else if(p->GetCurVisualPolicy()->GetColorStyle() == VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE) + { + p->GetCurColor(r, g, b, a, i); + this->m_aRed[i] = r ; + this->m_aGreen[i] = g; + this->m_aBlue[i] = b; + + this->m_aRedex[i] = 1.f - r; + this->m_aGreenex[i] = 1.f - g; + this->m_aBlueex[i] = 1.f - b; + } + } + else + { + p->GetCurColor(r, g, b, a, i); + this->m_aRed[i] = r; + this->m_aGreen[i] = g; + this->m_aBlue[i] = b; + } + } + //load vector properties if we have vector data + if(hasvect) + { + this->m_vPx[i] = vpx[i]*vlenscal; + this->m_vPy[i] = vpy[i]*vlenscal; + this->m_vPz[i] = vpz[i]*vlenscal; + } + + } + return; +} + +void VisAtomSample::SetCliper(QListcliper) +{ + + int i; + + this->m_pCliper.clear(); + for(i=0; iAddCliper(cliper[i]); + } + this->ResetVisibility(); +} + + +void VisAtomSample::AddCliper(VisAtomCliper*cliper) +{ + switch (cliper->GetStyle()) + { + case VisAtomCliper::CLIPPING_STYLE_OR: + { + this->m_pCliper.clear(); + break; + } + case VisAtomCliper::CLIPPING_STYLE_AND: + { + this->m_pCliper.clear(); + break; + } + case VisAtomCliper::CLIPPING_STYLE_ANYDIR: + { + break; + } + + } + this->m_pCliper.append(cliper); +} + + +void VisAtomSample::ResetVisibility() +{ + //first we should make all atoms visible + int i,j; + for(i = 0; i < this->m_numAtom; i++) + { + this->m_aVisStat[i] = atom_Statu_Visiable|this->m_aVisStat[i]; + } + + //check if hide by subsample property + for(j=0; jm_subSamples.count(); j++) + { + VisAtomSubSample*p = this->m_subSamples[j]; + if(!p->IsVisible()) + { + for(i=0; im_numAtom; i++) + { + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(p->CheckMembership(this->m_aType[i], this->m_aPx[i], this->m_aPy[i], this->m_aPz[i])) + this->SetStatAsHide(this->m_aVisStat[i]); + } + } + } + + //check if atoms are clipped + if(!this->m_pCliper.isEmpty()) this->ResetVisibilityByCliper(); + + //check if the atom are in invisible region + return; +} + + +void VisAtomSample::ResetVisibilityByCliper() +{ + + VisAtomCliper*cliper; + cliper = this->m_pCliper[0]; + int style = cliper->GetStyle(); + + switch(style) + { + case VisAtomCliper::CLIPPING_STYLE_OR: + { + //this->ResetVisibilityByCliper_OR(cliper); + this->ResetVisibilityByCliper_OR_ALSO(cliper); + break; + } + case VisAtomCliper::CLIPPING_STYLE_AND: + { + this->ResetVisibilityByCliper_AND(cliper); + break; + } + case VisAtomCliper::CLIPPING_STYLE_ANYDIR: + { + ResetVisibilityByCliper_ANYDIR(); + break; + } + } + return; +} + +void VisAtomSample::ResetVisibilityByCliper_OR(VisAtomCliper*cliper) +{ + + if(!cliper->IsEnabledClipX() && + !cliper->IsEnabledClipY() && + !cliper->IsEnabledClipZ()) return; + + int i; + double pos0[3], pos1[3], dp[3]; + cliper->GetClipThickness(dp); + cliper->GetClipPos(pos0); + for(i=0; i<3; i++) + { + pos0[i] = pos0[i] + dp[i]*0.5; + pos1[i] = pos0[i] - dp[i]; + } + + //NOTE: the atom has been made visible in root ResetVisibility + //************************** Check in X axsis + if(cliper->IsEnabledClipX()) + { + //for double clipping + if(cliper->IsEnabledDClipX()) + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos0[0], 1.0, this->m_aPx[i]) || + IsCliped(pos1[0], -1.0, this->m_aPx[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + else if(cliper->IsInverseClipX()) + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos1[0], -1.0, this->m_aPx[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + else + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos0[0], 1.0, this->m_aPx[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + }//****************** End of Checking in X axsis + + //********************** Check in Y axsis + if(cliper->IsEnabledClipY()) + { + //for double clipping + if(cliper->IsEnabledDClipY()) + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos0[1], 1.0, this->m_aPy[i]) || + IsCliped(pos1[1], -1.0, this->m_aPy[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + else if(cliper->IsInverseClipY()) + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos1[1], -1.0, this->m_aPy[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + else + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos0[1], 1.0, this->m_aPy[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + } //********************************** End of Checking in Y axsis + + //********************** Check in Z axsis + if(cliper->IsEnabledClipZ()) + { + //for double clipping + if(cliper->IsEnabledDClipZ()) + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos0[2], 1.0, this->m_aPz[i]) || + IsCliped(pos1[2], -1.0, this->m_aPz[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + else if(cliper->IsInverseClipZ()) + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos1[2], -1.0, this->m_aPz[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } + else + { + for(i=0; im_numAtom; i++) + { + //if the atom is alread invisible, no clipping check is needed + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + if(IsCliped(pos0[2], 1.0, this->m_aPz[i])) this->SetStatAsHide(this->m_aVisStat[i]); + } + } //********************************** End of Checking in Z axsis + } +} + +//**** An alternative algorithm for OR-clipping +void VisAtomSample::ResetVisibilityByCliper_OR_ALSO(VisAtomCliper*cliper) + { + + if(!cliper->IsEnabledClipX() && + !cliper->IsEnabledClipY() && + !cliper->IsEnabledClipZ()) return; + + + int i, stat, n0[3], n1[3]; + double pos0[3], pos1[3], dp[3]; + + + cliper->GetClipThickness(dp); + cliper->GetClipPos(pos0); + for(i=0; i<3; i++) + { + pos0[i] = pos0[i] + dp[i]*0.5; + pos1[i] = pos0[i] - dp[i]; + n0[i] = 0; + n1[i] =0; + } + + if(cliper->IsEnabledClipX()) + { + if(cliper->IsEnabledDClipX()) { n0[0] = n1[0] =1;} + else if(cliper->IsInverseClipX()) { n0[0] = 0; n1[0] = 1;} + else { n0[0] = 1; n1[0] = 0; } + } + + if(cliper->IsEnabledClipY()) + { + if(cliper->IsEnabledDClipY()) { n0[1] = n1[1] =1;} + else if(cliper->IsInverseClipY()) { n0[1] = 0; n1[1] = 1;} + else { n0[1] = 1; n1[1] = 0; } + }; + + if(cliper->IsEnabledClipZ()) + { + if(cliper->IsEnabledDClipZ()) { n0[2] = n1[2] =1;} + else if(cliper->IsInverseClipZ()) { n0[2] = 0; n1[2] = 1;} + else { n0[2] = 1; n1[2] = 0; } + }; + + for(i=0; im_numAtom; i++) + { + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + + //Check if the atom has been clipped + stat = + (n0[0]&&IsCliped(pos0[0], 1.0, this->m_aPx[i]) ) | + (n0[1]&&IsCliped(pos0[1], 1.0, this->m_aPy[i]) ) | + (n0[2]&&IsCliped(pos0[2], 1.0, this->m_aPz[i]) ) | + (n1[0]&&IsCliped(pos1[0], -1.0, this->m_aPx[i]) ) | + (n1[1]&&IsCliped(pos1[1], -1.0, this->m_aPy[i]) ) | + (n1[2]&&IsCliped(pos1[2], -1.0, this->m_aPz[i]) ); + //if stat is true, hade the atom + if(stat) this->SetStatAsHide(this->m_aVisStat[i]); + } + + } + + +//********************************************** + void VisAtomSample::ResetVisibilityByCliper_AND(VisAtomCliper*cliper) + { + int i, stat, deb; + double pos0[3], pos1[3], dp[3],vol[8][3]; + + if(!cliper->IsEnabledClipX() && + !cliper->IsEnabledClipY() && + !cliper->IsEnabledClipZ()) return; + + cliper->GetClipThickness(dp); + cliper->GetClipPos(pos0); + for(i=0; i<3; i++) + { + pos0[i] = pos0[i] + dp[i]*0.5; + pos1[i] = pos0[i] - dp[i]; + } + + //************** + if(cliper->IsEnabledClipX()) + { + if(!cliper->IsEnabledDClipX()) + { + if(cliper->IsInverseClipX()) + { + vol[0][0] = vol[2][0] = vol[4][0] = vol[6][0] = 1.e18; + vol[1][0] = vol[3][0] = vol[5][0] = vol[7][0] = pos1[0]; + } + else + { + vol[0][0] = vol[2][0] = vol[4][0] = vol[6][0] = pos0[0]; + vol[1][0] = vol[3][0] = vol[5][0] = vol[7][0] = -1.e18; + } + } + else + { + vol[0][0] = vol[2][0] = vol[4][0] = vol[6][0] = pos0[0]; + vol[1][0] = vol[3][0] = vol[5][0] = vol[7][0] = pos1[0]; + } + } + else + { + vol[0][0] = vol[2][0] = vol[4][0] = vol[6][0] = -1.e18; + vol[1][0] = vol[3][0] = vol[5][0] = vol[7][0] = 1.e18; + } + + //************** + if(cliper->IsEnabledClipY()) + { + if(!cliper->IsEnabledDClipY()) + { + if(cliper->IsInverseClipY()) + { + vol[0][1] = vol[1][1] = vol[4][1] = vol[5][1] = 1.e18; + vol[2][1] = vol[3][1] = vol[6][1] = vol[7][1] = pos1[1]; + } + else + { + vol[0][1] = vol[1][1] = vol[4][1] = vol[5][1] = pos0[1]; + vol[2][1] = vol[3][1] = vol[6][1] = vol[7][1] = -1.e18; + } + } + else + { + vol[0][1] = vol[1][1] = vol[4][1] = vol[5][1] = pos0[1]; + vol[2][1] = vol[3][1] = vol[6][1] = vol[7][1] = pos1[1]; + } + } + else + { + vol[0][1] = vol[1][1] = vol[4][1] = vol[5][1] = -1.e18; + vol[2][1] = vol[3][1] = vol[6][1] = vol[7][1] = 1.e18; + } + +//************** +if (cliper->IsEnabledClipZ()) +{ + if (!cliper->IsEnabledDClipZ()) + { + if (cliper->IsInverseClipZ()) + { + vol[0][2] = vol[1][2] = vol[2][2] = vol[3][2] = 1.e18; + vol[4][2] = vol[5][2] = vol[6][2] = vol[7][2] = pos1[2]; + } + else + { + vol[0][2] = vol[1][2] = vol[2][2] = vol[3][2] = pos0[2]; + vol[4][2] = vol[5][2] = vol[6][2] = vol[7][2] = -1.e18; + } + } + else + { + vol[0][2] = vol[1][2] = vol[2][2] = vol[3][2] = pos0[2]; + vol[4][2] = vol[5][2] = vol[6][2] = vol[7][2] = pos1[2]; + } +} +else +{ + vol[0][2] = vol[1][2] = vol[2][2] = vol[3][2] = -1.e18; + vol[4][2] = vol[5][2] = vol[6][2] = vol[7][2] = 1.e18; +} + + +//1st region +for (i = 0; i < this->m_numAtom; i++) +{ + if (!(this->m_aVisStat[i] & atom_Statu_Visiable)) continue; + + //Check if the atom has been clipped + deb = 0; + stat = (IsCliped(vol[0][0], 1.0, this->m_aPx[i])& + IsCliped(vol[0][1], 1.0, this->m_aPy[i])& + IsCliped(vol[0][2], 1.0, this->m_aPz[i])); + deb = deb | stat; + + stat = (IsCliped(vol[1][0], -1.0, this->m_aPx[i])& + IsCliped(vol[1][1], 1.0, this->m_aPy[i])& + IsCliped(vol[1][2], 1.0, this->m_aPz[i])); + deb = deb | stat; + + stat = (IsCliped(vol[2][0], 1.0, this->m_aPx[i])& + IsCliped(vol[2][1], -1.0, this->m_aPy[i])& + IsCliped(vol[2][2], 1.0, this->m_aPz[i])); + deb = deb | stat; + + stat = (IsCliped(vol[3][0], -1.0, this->m_aPx[i])& + IsCliped(vol[3][1], -1.0, this->m_aPy[i])& + IsCliped(vol[3][2], 1.0, this->m_aPz[i])); + deb = deb | stat; + + stat = (IsCliped(vol[4][0], 1.0, this->m_aPx[i])& + IsCliped(vol[4][1], 1.0, this->m_aPy[i])& + IsCliped(vol[4][2], -1.0, this->m_aPz[i])); + deb = deb | stat; + + stat = (IsCliped(vol[5][0], -1.0, this->m_aPx[i])& + IsCliped(vol[5][1], 1.0, this->m_aPy[i])& + IsCliped(vol[5][2], -1.0, this->m_aPz[i])); + deb = deb | stat; + + stat = (IsCliped(vol[6][0], 1.0, this->m_aPx[i])& + IsCliped(vol[6][1], -1.0, this->m_aPy[i])& + IsCliped(vol[6][2], -1.0, this->m_aPz[i])); + deb = deb | stat; + + + stat = (IsCliped(vol[7][0], -1.0, this->m_aPx[i])& + IsCliped(vol[7][1], -1.0, this->m_aPy[i])& + IsCliped(vol[7][2], -1.0, this->m_aPz[i])); + deb = deb | stat; + + if (deb) this->SetStatAsHide(this->m_aVisStat[i]); +} + + } + + //******************************************************************************** + void VisAtomSample::ResetVisibilityByCliper_ANYDIR() + { + VisAtomCliper*cliper; + int nc, i, j, stat, deb, inplane; + double dist, norm; + double *posx, *posy, *posz, *dirx, *diry, *dirz, *htu, *htl; + + + nc = this->m_pCliper.size(); + posx = new double[nc]; + posy = new double[nc]; + posz = new double[nc]; + dirx = new double[nc]; + diry = new double[nc]; + dirz = new double[nc]; + htl = new double[nc]; + htu = new double[nc]; + for(j = 0; j < nc; j++) + { + cliper = this->m_pCliper[j]; + cliper->GetClipAxsis(dirx[j], diry[j], dirz[j]); + + //normalize the norm vector + norm = dirx[j] * dirx[j] + diry[j] * diry[j] + dirz[j] * dirz[j]; + if (norm < 0.0001) norm = 1; + norm = pow(norm, 0.5); + dirx[j] = dirx[j] / norm; + diry[j] = diry[j] / norm; + dirz[j] = dirz[j] / norm; + //NOTE: for this case, only one clipping plane, thus only dp[0] is the thickness; + if (cliper->IsEnabledClip()) + { + if (cliper->IsEnabledDClip()) + { + htl[j] = -cliper->GetClipThickness()*0.5; + htu[j] = cliper->GetClipThickness()*0.5; + } + else if (cliper->IsInverseClipX() || cliper->IsInverseClipY() || cliper->IsInverseClipZ()) + { + htl[j] = -cliper->GetClipThickness()*0.5; + htu[j] = 1.e64; + } + else + { + htl[j] = -1.e64; + htu[j] = cliper->GetClipThickness()*0.5; + } + } + else + { + htl[j] = 1.e64; + htu[j] = -1.e64; + } + //Get the center of clipping plane + //cliper->GetClipAbsolutePos(pos0); + cliper->GetClipPos(posx[j], posy[j], posz[j]); + //if (abs(dir[0]) < 0.001 && abs(dir[1]) < 0.001 && abs(dir[2]) < 0.001) return; + } + + + for(i=0; im_numAtom; i++) + { + if(!(this->m_aVisStat[i]&atom_Statu_Visiable)) continue; + + inplane = 0; + for(j=0; jm_aPx[i] - posx[j])*dirx[j] + + (this->m_aPy[i] - posy[j])*diry[j] + + (this->m_aPz[i] - posz[j])*dirz[j]; + if (htl[j] <= dist && dist <= htu[j]) + { + inplane = j + 1; + } + } + if(!inplane) this->SetStatAsHide(this->m_aVisStat[i]); + /*dist = (this->m_aPx[i]-pos0[0])*dir[0] + + (this->m_aPy[i]-pos0[1])*dir[1] + + (this->m_aPz[i]-pos0[2])*dir[2]; + + if(cliper->IsEnabledDClipX()||cliper->IsEnabledDClipY()||cliper->IsEnabledDClipZ()) + { + if( dist>ht || dist<-ht) this->SetStatAsHide(this->m_aVisStat[i]); + } + else if(cliper->IsInverseClipX()||cliper->IsInverseClipY()||cliper->IsInverseClipZ()) + { + if( dist< -ht) this->SetStatAsHide(this->m_aVisStat[i]); + } + else + { + if( dist> ht) this->SetStatAsHide(this->m_aVisStat[i]); + }*/ + + } + delete posx; + delete posy; + delete posz; + delete dirx; + delete diry; + delete dirz; + delete htl; + delete htu; + } + +//******************************************************************************** +//To get the range of the whole box along x +void VisAtomSample::AutoSampleBoxRange() +{ + // i: the index of subsample + int i; + this->m_aXmi = 9.E20; + this->m_aXmx =-9.E20; + this->m_aYmi = 9.E20; + this->m_aYmx =-9.E20; + this->m_aZmi = 9.E20; + this->m_aZmx =-9.E20; + for(i=0; im_numAtom; i++) + { + if(this->m_aXmi > this->m_aPx[i]) this->m_aXmi = this->m_aPx[i]; + if(this->m_aXmx < this->m_aPx[i]) this->m_aXmx = this->m_aPx[i]; + + if(this->m_aYmi > this->m_aPy[i]) this->m_aYmi = this->m_aPy[i]; + if(this->m_aYmx < this->m_aPy[i]) this->m_aYmx = this->m_aPy[i]; + + if(this->m_aZmi > this->m_aPz[i]) this->m_aZmi = this->m_aPz[i]; + if(this->m_aZmx < this->m_aPz[i]) this->m_aZmx = this->m_aPz[i]; + } + this->m_aXmx = std::max(abs(this->m_aXmx), abs(this->m_aXmi)); + this->m_aXmi = -this->m_aXmx; + this->m_aYmx = std::max(abs(this->m_aYmx), abs(this->m_aYmi)); + this->m_aYmi = -this->m_aYmx; + this->m_aZmx = std::max(abs(this->m_aZmx), abs(this->m_aZmi)); + this->m_aZmi = -this->m_aZmx; + return; +} + +//******************************************************************************** +void VisAtomSample::GetDefaultAtomRadiu(float&radiu, float&scal) +{ + //automatically set the radius of atoms + float rn = pow((double)this->m_numAtom, 0.3333333); + float ds = this->m_aXmx - this->m_aXmi; + + if(ds > this->m_aYmx - this->m_aYmi) ds = this->m_aYmx - this->m_aYmi; + if(ds > this->m_aZmx - this->m_aZmi) ds = this->m_aZmx - this->m_aZmi; + + radiu = 0.5*ds/rn; + scal = radiu/(ds/4.0); + return; +} + + +//******************************************************************************** +VisAtomVisualizingPolicy*VisAtomSample::GetSubsampleVisualPolicy(QString name, int policy) +{ + //to find out he subsample of name + int i; + VisAtomSubSample*p; + for(i=0; im_subSamples.count(); i++) + { + p = this->m_subSamples[i]; + if(name == p->GetName()) break; + } + if(policy < 0) return p->GetCurVisualPolicy(); + else return p->GetVisualPolicy(policy); +} + +//******************************************************************************** +void VisAtomSample::GetDefaultVectorSize(float&lenscal, float&rad, float&arrowl, float&arrowr) +{ + //automatically set the radius of atoms + float rn = pow((double)this->m_numAtom, 0.3333333); + float ds = this->m_aXmx - this->m_aXmi; + + if(ds > this->m_aYmx - this->m_aYmi) ds = this->m_aYmx - this->m_aYmi; + if(ds > this->m_aZmx - this->m_aZmi) ds = this->m_aZmx - this->m_aZmi; + rad = 0.025*ds/rn; + arrowr = rad*2.0; + arrowl = 1.7321*arrowr; + + int col[3]; + VisAtomVisualizingPolicy::GetVectorCol(col); + float*vx = this->m_pData->GetData(col[0]); + float*vy = this->m_pData->GetData(col[1]); + float*vz = this->m_pData->GetData(col[2]); + int i; + float len, lmx; + + lmx = -1.e20; + for(i=0; im_pData->GetNumRow(); i++) + { + len = vx[i]*vx[i] + vy[i]*vy[i] + vz[i]*vz[i]; + if(len > lmx) lmx = len; + } + len = pow((double)lmx, 0.5); + lenscal = ds/rn/len; + return; +} +//******************************************************************************** + +#define MAXCOL 64 +#define MAXSTRL 32 +void VisAtomSample::DrawWignerSeizVolume(QString fname) +{ + + + QFile file(fname); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + Arrowline V=Arrowline(); + Style Sty; + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + Sty.Solid(); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glLineWidth(4.f); + //to determine how many col for each line + char buf[MAXCOL*MAXSTRL]; + float pos0[3], norm1[3], norm0[3],verts[120][3]; + int id, nfaces, i, j, ip, nverts, i1, i2, index, ityp; + + ip = 0; + while (!file.atEnd()) + { + file.readLine(buf, MAXCOL*MAXSTRL); + file.readLine(buf, MAXCOL*MAXSTRL); + sscanf(buf, "%i %i %i %e %e %e", &id, &index, &ityp, &pos0[0], &pos0[1], &pos0[2]); + file.readLine(buf, MAXCOL*MAXSTRL); + sscanf(buf, "%i ", &nfaces); + glPushMatrix(); + //glTranslatef(pos0[0], pos0[1], pos0[2]); + for(i=0; i 0) continue; + //determine the normal + norm1[0] = (verts[1][1]-verts[0][1])*(verts[2][2]-verts[1][2])-(verts[1][2]-verts[0][2])*(verts[2][1]-verts[1][1]); + norm1[1] = (verts[1][2]-verts[0][2])*(verts[2][0]-verts[1][0])-(verts[1][0]-verts[0][0])*(verts[2][2]-verts[1][2]); + norm1[2] = (verts[1][0]-verts[0][0])*(verts[2][1]-verts[1][1])-(verts[1][1]-verts[0][1])*(verts[2][0]-verts[1][0]); + + glBegin(GL_POLYGON); + glColor3f((float)i/5.f+0.1, 0.f, 0.f); + + if(norm1[0]*norm0[0]+norm1[1]*norm0[1]+norm1[2]*norm0[2]>0) + { + glNormal3f(norm0[0], norm0[1], norm0[2]); + for(j=0; j=0; j--) glVertex3d(verts[j][0], verts[j][1], verts[j][2]); + } + glEnd(); + + //to begine draw the face + /*glBegin(GL_LINE_LOOP); + glColor3f(0.0f, 0.f, 0.f); + glNormal3f(norm0[0], norm0[1], norm0[2]); + + for(j=0; j=100) break; + } + file.close(); +} + + + +void VisAtomSample::AttachTrajectory(VisAtomTrajectory*pTraject) +{ + this->m_pTrajectory = pTraject; +} + +void VisAtomSample::SetShowOnlyAtomsFound(int showonly) +{ + if (!showonly) + { + this->ResetVisibility(); + } + else + { + int i; + for (i = 0; i < this->m_numAtom; i++) + { + if (!(this->m_aVisStat[i] & atom_Statu_MarkedFound)) + { + this->Hide_aAtom(i + 1); + } + } + } + +} + +/*void VisAtomSample::DrawWignerSeizVolume(QString fname) +{ + Sphere Balls=Sphere(); + + QFile file(fname); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + Style Sty; + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + Sty.Solid(); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + glLineWidth(1.f); + //to determine how many col for each line + char buf[MAXCOL*MAXSTRL]; + float pos0[3], norm1[3], norm0[3], verts[50][3]; + float x, y, z; + int id, nfaces, i, j, ityp, ip, nverts, gid, i1, i2, index; + + ip = 0; + while (!file.atEnd()) + { + file.readLine(buf, MAXCOL*MAXSTRL); + file.readLine(buf, MAXCOL*MAXSTRL); + sscanf(buf, "%i %i %i %e %e %e", &id, &index,&ityp, &pos0[0], &pos0[1], &pos0[2]); + file.readLine(buf, MAXCOL*MAXSTRL); + sscanf(buf, "%i ", &nfaces); + glPushMatrix(); + for(i=0; i<2; i++) //nfaces; i++) + { + file.readLine(buf, MAXCOL*MAXSTRL); + sscanf(buf, "%i ", &nverts); + for(j=0; j=100) break; + } + file.close(); +}*/ + diff --git a/VISATOMSRC/VisAtomSample.h b/VISATOMSRC/VisAtomSample.h new file mode 100644 index 0000000..955e95f --- /dev/null +++ b/VISATOMSRC/VisAtomSample.h @@ -0,0 +1,278 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#ifndef _VISATOMSAMPLE_H +#define _VISATOMSAMPLE_H +#include "GlcObj.h" +#include "Scene.h" +#include "VisAtomSubSample.h" + + +#define atom_Statu_Invisiable 0 +#define atom_Statu_Visiable 1 +#define atom_Statu_Selected 2 +#define atom_Statu_MarkedFound 4 +#define atom_Statu_Deleted 8 + + +#define file_format_Simple 0 + +#define atom_pick_Option_Single 0 +#define atom_pick_Option_Subsample 1 +#define atom_pick_Option_Multiple 2 +#define atom_pick_Option_Square 3 +#define atom_pick_Option_Tripoints 4 + +#define atom_pick_Statu_nopicked 0 +#define atom_pick_Statu_picked 1 +#define atom_pick_Statu_doublepicked 2 +#define atom_pick_Statu_droped 4 + +#define sample_Statu_noChange 0 +#define sample_Statu_Changed 1 + +class VisAtomDataSheet; +class VisAtomCliper; +class VisAtomTrajectory; + +class VisAtomSample:public GlcObj +{ + private: + //************ New or modified 2013-09 ************************ + // + void ResetVisibilityByCliper(); + void ResetVisibilityByCliper_OR(VisAtomCliper*cliper); + void ResetVisibilityByCliper_OR_ALSO(VisAtomCliper*cliper); + void ResetVisibilityByCliper_AND(VisAtomCliper*cliper); + void ResetVisibilityByCliper_ANYDIR(); + + bool IsCliped(double c, double n, float p) {if((p-c)*n > 0) return true; else return false;} + void SetStatAsHide(char&visstat){ char j; j = (visstat>>1); visstat = (j<<1);} + + protected: + VisAtomDataSheet*m_pData; + QListm_pCliper; + + + int m_numAtom; + char *m_aType; + float *m_aPx, *m_aPy, *m_aPz; + //display parameter for atoms + char *m_aVisStat; + float *m_aRadius; + float *m_aRed, *m_aGreen, *m_aBlue; + float *m_aRedex, *m_aGreenex, *m_aBlueex; + int *m_aGeomStyle; + //display parameter for vectors + float *m_vPx, *m_vPy, *m_vPz; + + // the box range automatically determined by position of atoms + float m_aXmi, m_aXmx, m_aYmi, m_aYmx, m_aZmi, m_aZmx; + + + QList m_subSamples; + QList m_selSubsamples; + int m_curSubsample; + + int m_pick_style, m_pick_statu; + int m_pick_posx, m_pick_posy; + int m_pickedAtomID; + int statu; + + VisAtomTrajectory*m_pTrajectory; + friend class VisAtomTrajectory; + + public: + VisAtomSample(); + ~VisAtomSample(); + + void Clear(bool keepsubsample=false); + void SetDataSheet(VisAtomDataSheet*pData); + VisAtomDataSheet*GetDataSheet(){ return m_pData;} + + int NumberofAtom(){return m_numAtom;}; + int GetSampleType(int*); + int GetSampleX(float*); + int GetSampleY(float*); + int GetSampleZ(float*); + char* GetSampleTypeP(){if(m_aType != NULL) return m_aType; else return NULL;}; + float*GetSampleXP(){if(m_aPx != NULL) return m_aPx; else return NULL;}; + float*GetSampleYP(){if(m_aPy != NULL) return m_aPy; else return NULL;}; + float*GetSampleZP(){if(m_aPz != NULL) return m_aPz; else return NULL;}; + + void AutoSampleBoxRange(); + void GetSampleBoxRangeX(float&xmi, float&xmx){xmi = m_aXmi; xmx = m_aXmx;}; + void GetSampleBoxRangeY(float&ymi, float&ymx){ymi = m_aYmi; ymx = m_aYmx;}; + void GetSampleBoxRangeZ(float&zmi, float&zmx){zmi = m_aZmi; zmx = m_aZmx;}; + void GetDefaultAtomRadiu(float&radiu, float&scal); + void GetDefaultVectorSize(float&lenscal, float&rad, float&arrowl, float&arrowr); + + + int NumberofSubsample(){ return m_subSamples.count();}; + VisAtomSubSample*GetSubsample(int i){return m_subSamples[i];}; + VisAtomSubSample*GetSubsample(QString name) + { for(int i=0; iGetName() == name) return m_subSamples[i]; + return NULL; + }; + + void SetCurrentSubsample(int subsample){m_curSubsample = subsample; }; + int SetCurrentSubsample(QString name) + { for(int i=0; iGetName() == name) { m_curSubsample = i; return m_curSubsample;} + return -1; }; + int GetCurrentSubsampleID() { return m_curSubsample; }; + VisAtomSubSample*GetCurrentSubsample(){ return m_subSamples[m_curSubsample]; }; + bool IsCurrentSample(QString name) + { + if(name == m_subSamples[m_curSubsample]->GetName() ) return true; + else return false; + } + + int SetSelSubsample(QString name) + { for(int i=0; iGetName() == name) { m_selSubsamples[i] = 1; return i;} + return -1; }; + + int SetUnselSubsample(QString name) + { for(int i=0; iGetName() == name) { m_selSubsamples[i] = 0; return i;} + return -1; }; + + int IsSelectedSubsample(int i) + { return m_selSubsamples[i];} + + + //This part concerning display property + virtual void Paint(); + void Draw(); + void DrawSolidAtoms(int inbox); + void DrawWireAtoms(int inbox); + void DrawDotAtoms(int inbox); + void DrawCircleAtoms(int inbox); + + void DrawLineVectors(int inbox); + void DrawSolidVectors(int inbox); + void DrawColorMappinBar(int*lablepos); + void DrawWignerSeizVolume(QString fname); + + + void DrawProjCirleAtoms(int nx, int ny, int nz); + void DrawProjSolidAtoms(int nx, int ny, int nz); + void DrawProjDotAtoms(int nx, int ny, int nz); + + void HighlightSelectedAtoms(); + void HighlightFoundAtoms(); + + void Save_Summary(FILE*); + void Save_Config_Selected(FILE*); + void Save_Config_PickedSubsample(FILE*); + void Save_Config_VisiableAtoms(FILE*); + void Save_Config(FILE*); + int NumberofVisiableAtom(); + + + //Part concerning statu + int IfChanged(); + void FinishChange(); + + int GetPickStatu(); + int GetPickOption(); + void ClearPickStatu(); + void SetPickOption(int); + int PickAtom(int, int, Scene*, float*, float*, float*); + int PickSingle(int, int, Scene*, float*, float*, float*); + int PickMultiple(int, int, Scene*, float*, float*, float*); + int PickSquare(int, int, int, Scene*, float*, float*, float*); + int PickTriPoints(int, int, Scene*, float*, float*, float*); + int MovePickedAtom(int, int, Scene*, float*, float*, float*); + int MoveSinglePicked(int, int, Scene*, float*, float*, float*); + int MoveMultiplePicked(int, int, Scene*, float*, float*, float*); + int MoveSubsamplePicked(int, int, Scene*, float*, float*, float*); + int DropPickedAtom(int, int, Scene*,float*, float*, float*); + int DropSinglePicked(int, int, Scene*); + int InformPickedAtom(int*, int*, float*, float*, float*); + int Inf_of_SinglePicked(int*, int*, float*, float*, float*); + int Move_aAtom(float, float, float); + void Move_SelectedAtoms(float, float, float); + void Move_aAtomGroup(int, float, float, float); + void Move_aAtomGroup(float, float, float); + + + //*** this part concering the operation on atoms + int GetCurAtom(); + void SetCurAtom(int id); + int GetTypeofCurAtom(); + float GetXofCurAtom(); + float GetYofCurAtom(); + float GetZofCurAtom(); + + void Show_aAtom(int); + void Show_aAtom(); + void Hide_aAtom(int); + void Hide_aAtom(); + void Hide_SelectedAtoms(); + void Hide_unSelectedAtoms(); + void Show_SelectedAtoms(); + void Show_unSelectedAtoms(); + void Show_AllAtoms(); + void Hide_AllAtoms(); + void Select_aAtom(int); + void Select_aAtom(); + void unSelect_aAtom(int); + void unSelect_aAtom(); + void unSelect_Atoms(int from, int to); + void unSelect_aAtomGroup(int); + void unSelect_aAtomGroup(); + void unSelect_AllAtoms(); + + //************ New or modified 2013-09 ************************ + // + //*** this part concerning the clipping of scene + void SetCliper(QListclip); + void AddCliper(VisAtomCliper*clip); + void ResetVisibility(); + + + //*** this part concering the operation on atoms + void LoadSubsampleProp(int is); + void LoadCurSubsampleProp(){if(m_curSubsample>=0) LoadSubsampleProp(m_curSubsample);} + + void SetAtomRadiusForSubsample(int is, float radius){ m_subSamples[is]->SetCurAtomSize(radius);}; + void SetAtomShapeStyleForSubsample(int is, int style){ m_subSamples[is]->SetCurAtomShapeStyle(style);}; + void SetColorForSubsample(int is, float R, float G, float B, float A=1.f){ m_subSamples[is]->SetCurColor(R, G, B, A);}; + + + void SetAtomRadiusForCurrentSubsample(float radius) + {if(m_curSubsample>=0) SetAtomRadiusForSubsample(m_curSubsample, radius);}; + + void SetAtomShapeStyleForCurrentSubsample(int style) + {if(m_curSubsample>=0) SetAtomShapeStyleForSubsample(m_curSubsample, style);}; + + void SetColorForCurrentSubsample(float R, float G, float B, float A=1.f) + {if(m_curSubsample>=0) SetColorForSubsample(m_curSubsample, R, G, B);}; + + + VisAtomVisualizingPolicy*GetSubsampleVisualPolicy(QString name, int policy); + //**** + void AttachTrajectory(VisAtomTrajectory*pTraject); + VisAtomTrajectory*GetTrajectoryData(){return m_pTrajectory;}; + + //*** + void MarkAtomsFound(int from, int to, int step); + void MarkGroupAtomsFound(int group, int from, int to); + void RemoveAtomsFoundMark(); + void SetShowOnlyAtomsFound(int showonly); + void GeNextAtomMarkedFound(int here, int&gid, int&ingr, float&posx, float&posy, float&posz); + + }; + + + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisAtomSubSample.cpp b/VISATOMSRC/VisAtomSubSample.cpp new file mode 100644 index 0000000..b9a707e --- /dev/null +++ b/VISATOMSRC/VisAtomSubSample.cpp @@ -0,0 +1,195 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#include +#include +#include "VisAtomDataSheet.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomSubSample.h" + + + +void VisAtomSubSample::Clear() +{ + this->m_group.clear(); + + while(!this->m_region.isEmpty()) + { + VisAtomRegionData*p = this->m_region[0]; + delete p; + this->m_region.removeAt(0); + } + + this->m_dataregion.clear(); + this->m_datacol.clear(); + this->m_datacol.clear(); + + while(!this->m_vispolicy.isEmpty()) + { + VisAtomVisualizingPolicy*p = this->m_vispolicy[0]; + delete p; + this->m_vispolicy.removeAt(0); + } + + return; +} + +VisAtomSubSample::~VisAtomSubSample() +{ + Clear(); +} + +VisAtomSubSample::VisAtomSubSample() +{ + this->m_statu = VisAtomSubSample::SUBSAMPLE_VISIABLE; + VisAtomVisualizingPolicy*p; + //create the first default visualization policy + p = new VisAtomVisualizingPolicy(); + p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + p->SetColorByDefaultTable(0); + this->m_vispolicy.append(p); + + //create the secod visualization policy + p = new VisAtomVisualizingPolicy(); + p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_vispolicy.append(p); + + this->m_curvispolicy = 0; + this->m_pData = NULL; + return; +} + +VisAtomSubSample::VisAtomSubSample(int atype) +{ + this->m_statu = VisAtomSubSample::SUBSAMPLE_VISIABLE; + //create the first default visualization policy + VisAtomVisualizingPolicy*p; + p = new VisAtomVisualizingPolicy(); + p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + p->SetColorByDefaultTable(atype-1); + this->m_vispolicy.append(p); + + //create the secod visualization policy + p = new VisAtomVisualizingPolicy(); + p->SetColorStyle(VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_vispolicy.append(p); + + this->m_group.append(atype); + this->m_curvispolicy = 0; + this->m_pData = NULL; + return; +} + +bool VisAtomSubSample::CheckMembership(int atype, float x, float y, float z, float scalar) +{ + int i, count; + int ingroup, inregion, inscalar; + + //check if belong to one of the groups + ingroup = 1; + if(!this->m_group.isEmpty()) + { + ingroup = 0; + for(i=0; im_group.count(); i++) + { + if(atype == this->m_group[i]) + { + ingroup = 1; + break; + } + } + } + + //check if belong to one of the regions + inregion = 1; + if(!this->m_region.isEmpty()) + { + inregion = 0; + for(i=0; im_region.count(); i++) + { + //checking + } + } + + //check if belong to one of the scarlar regions + inscalar = 1; + if(!this->m_dataregion.isEmpty()) + { + inscalar = 0; + for(i=0; im_dataregion.count(); i++) + { + //checking + } + } + //*** + return ingroup&&inregion&&inscalar; +} + + +int VisAtomSubSample::GetNumberofAtoms() +{ + int i,j, num, col, row; + float*type, *x, *y, *z; + float*scalar; + + if(!m_pData) return 0; + + row = m_pData->GetNumRow(); + //get type + col = m_pData->GetTypeCol(); + if(col >=0) type = m_pData->GetData(col); + else type = NULL; + + //get position + col = m_pData->GetPosXCol(); + x = m_pData->GetData(col); + + col = m_pData->GetPosYCol(); + y = m_pData->GetData(col); + + col = m_pData->GetPosZCol(); + z = m_pData->GetData(col); + + + num = 0; + if(VisAtomVisualizingPolicy::GetScalarCol() >=0) + { + scalar = m_pData->GetData(VisAtomVisualizingPolicy::GetScalarCol()); + if(type) + { for(i=0; iCheckMembership((int)(type[i]+0.000001), x[i], y[i], z[i], scalar[i])) num++; + } + else + { + for(i=0; iCheckMembership(1, x[i], y[i], z[i], scalar[i])) num++; + } + + } + else + if(type) + { + for(i=0; iCheckMembership((int)(type[i]+0.000001), x[i], y[i], z[i])) num++; + } + else + { + for(i=0; iCheckMembership(1, x[i], y[i], z[i])) num++; + } + return num; +} + +void VisAtomSubSample::AddVisualPolicy(VisAtomVisualizingPolicy*policy) +{ + VisAtomVisualizingPolicy*p = new VisAtomVisualizingPolicy(policy); + this->m_vispolicy.append(p); +} + + \ No newline at end of file diff --git a/VISATOMSRC/VisAtomSubSample.h b/VISATOMSRC/VisAtomSubSample.h new file mode 100644 index 0000000..c8ca5d4 --- /dev/null +++ b/VISATOMSRC/VisAtomSubSample.h @@ -0,0 +1,252 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#ifndef _VISATOMSUBSAMPLE_H +#define _VISATOMSUBSAMPLE_H +#include "GlcObj.h" +#include "QList.h" +#include "VisAtomVisualizingPolicy.h" + +class VisAtomDataSheet; +//********************************************************************* +class VisAtomRegionData +{ + public: + enum VISATOMREGION + { + UNDEF_REGION = 0, + SPHERE_REGION = 1, + CUBIC_REGION = 2, + DPLANE_REGION = 3, + EQUATION_REGION = 4 + }; + protected: + int m_type; + QList m_param; + + public: + VisAtomRegionData(){ m_type = UNDEF_REGION;} + ~VisAtomRegionData(){m_param.clear();} + + void SetSphereRegion(double px, double py, double pz, double r) + { + m_type = SPHERE_REGION; + m_param.clear(); + m_param< m_group; + QList m_region; //space region defining the subsample + QList m_dataregion; //data range defining the subsample + QList m_datacol; //colume of data datasheet giving the data region + QList m_vispolicy; //visual policies for the subsample + + + public: + enum VISATOMSUBSTATU + { + SUBSAMPLE_INVISIABLE = 0, + SUBSAMPLE_VISIABLE = 1 + }; + VisAtomSubSample(int atype); + VisAtomSubSample(); + ~VisAtomSubSample(); + void Clear(); + + QString GetName(){return m_name;} + void SetName(QString name) { m_name = name;}; + + void SetDataSheet(VisAtomDataSheet*pdata) {m_pData = pdata;} + void AddGroupID(int type){m_group.append(type);} + int GetNumberofGroup() { return m_group.count();} + int GetGroupID(int i) { return m_group[i];} + + VisAtomRegionData*GetRegion(int i){ return m_region[i];} + int GetNumberofRegions(){ return m_region.size();} + + int GetNumberofScalarRegions(){ return m_dataregion.count()/2;} + + //to check if an atom is in the subgroup + bool CheckMembership(int atype, float x, float y, float z, float scalar=0); + int GetNumberofAtoms(); + + //properties of the subsample + int IsVisible() {return m_statu;}; + void SetVisible(int visible=true) { m_statu = visible;}; + + void AddVisualPolicy(VisAtomVisualizingPolicy*policy); + int GetNumberofVisualPolicy() { return this->m_vispolicy.count();} + VisAtomVisualizingPolicy*GetVisualPolicy(int i) { return this->m_vispolicy[i];} + VisAtomVisualizingPolicy*GetCurVisualPolicy() { return this->m_vispolicy[m_curvispolicy];} + int GetCurVisualPolicyID() { return m_curvispolicy; } + void SetCurVisualPolicy(int policy) {m_curvispolicy = policy;} + void SetLastVisualPolicyAsCurrent() {SetCurVisualPolicy(m_vispolicy.count()-1);} + + //coloring functions.. + void SetColor(float R, float G, float B, float A, int policy) + { + VisAtomVisualizingPolicy*p = this->m_vispolicy[policy]; + p->SetColor(R, G, B, A); + }; + void GetColor(float&R, float&G, float&B, float&A, int policy) + { + VisAtomVisualizingPolicy*p = this->m_vispolicy[policy]; + p->GetColor(R, G, B, A); + }; + void GetColor(float&R, float&G, float&B, float&A, int index, int policy) + { + VisAtomVisualizingPolicy*p = this->m_vispolicy[policy]; + p->GetColor(R, G, B, A, index); + }; + void SetCurColor(float R, float G, float B, float A) {SetColor(R, G, B, A, m_curvispolicy);} + void GetCurColor(float&R, float&G, float&B, float&A) {GetColor(R, G, B, A, m_curvispolicy);} + void GetCurColor(float&R, float&G, float&B, float&A, int index) {GetColor(R, G, B, A, index, m_curvispolicy);} + void SetColorStyle(int style,int policy) + { + VisAtomVisualizingPolicy*p = m_vispolicy[policy]; + return p->SetColorStyle(style); + } + int GetColorStyle(int policy) + { + VisAtomVisualizingPolicy*p = m_vispolicy[policy]; + return p->GetColorStyle(); + } + void SetCurColorStyle(int style) { SetColorStyle(style, m_curvispolicy);} + int GetCurColorStyle() { return GetColorStyle(m_curvispolicy);} + + //Geometry + void SetAtomShapeStyle(int style, int policy) + { + VisAtomVisualizingPolicy*p = m_vispolicy[policy]; + p->SetAtomShapeStyle(style); + return; + }; + void SetVectorStyle(int style, int policy) + { + VisAtomVisualizingPolicy*p = m_vispolicy[policy]; + p->SetVectorStyle(style); + return; + }; + int GetGeometryStyle(int policy) + { + VisAtomVisualizingPolicy*p = m_vispolicy[policy]; + return p->GetGeomStyle(); + }; + void SetCurAtomShapeStyle(int style) { SetAtomShapeStyle(style, m_curvispolicy); } + void SetCurVectorStyle(int style) { SetVectorStyle(style, m_curvispolicy); } + int GetCurGeometryStyle() { return GetGeometryStyle(m_curvispolicy); } + //size functions + void SetAtomSize(float rad, int policy) + { + this->m_vispolicy[policy]->SetAtomSize(rad); + } + void GetAtomSize(float&rad, int policy) + { + rad = this->m_vispolicy[policy]->GetAtomSize(); + } + void GetAtomSize(int i, float&rad, int policy) + { + rad = this->m_vispolicy[policy]->GetAtomSize(i); + } + void SetCurAtomSize(float rad){ SetAtomSize(rad, m_curvispolicy);} + void GetCurAtomSize(float&rad){ GetAtomSize(rad, m_curvispolicy);} + void GetCurAtomSize(int i, float&rad){ GetAtomSize(i, rad, m_curvispolicy);} + bool IsAtomHaveUnifiedSize(int policy){ return this->m_vispolicy[policy]->IsAtomHaveUnifiedSize();} + bool IsCurAtomHaveUnifiedSize(){ return IsAtomHaveUnifiedSize(m_curvispolicy);} + void SetAtomHaveUnifiedSize(bool yes, int policy) + { + VisAtomVisualizingPolicy*p = this->m_vispolicy[policy]; + p->SetAtomHaveUnifiedSize(yes); + } + void SetCurAtomHaveUnifiedSize(bool yes){this->SetAtomHaveUnifiedSize(yes, m_curvispolicy);}; + + + //trajectory propperty + void SetTrajectoryLinethick(float thick, int policy) + { + this->m_vispolicy[policy]->SetTrajectoryLinethick(thick); + } + void SetTrajectoryLinethick(float thick) + { + for(int i=0; im_vispolicy.count(); i++) + this->m_vispolicy[i]->SetTrajectoryLinethick(thick); + } + void SetCurTrajectoryLinethick(float thick) + { + SetTrajectoryLinethick(thick, m_curvispolicy); + } + float GetTrajectoryLinethick(int policy) + { + return this->m_vispolicy[policy]->GetTrajectoryLinethick(); + } + float GetCurTrajectoryLinethick() + { + return this->m_vispolicy[m_curvispolicy]->GetTrajectoryLinethick(); + } + }; + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisAtomTrajectory.cpp b/VISATOMSRC/VisAtomTrajectory.cpp new file mode 100644 index 0000000..bf0f5d0 --- /dev/null +++ b/VISATOMSRC/VisAtomTrajectory.cpp @@ -0,0 +1,312 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#include +#include +#include "VisAtomTrajectory.h" +#include "VisAtomSample.h" + + +VisAtomTrajectory::VisAtomTrajectory() +{ + m_curSample = NULL; + m_aDx0 = NULL; + m_aDy0 = NULL; + m_aDz0 = NULL; + return; +} + + +//************************************************************************** +VisAtomTrajectory::~VisAtomTrajectory() +{ + Clear(); + return; +} + + +//************************************************************************** +void VisAtomTrajectory::Clear() +{ + + int i; + for(i=0; im_SampleDataSheets.size(); i++) + { + if(this->m_SampleDataSheets[i]) delete this->m_SampleDataSheets[i]; + } + this->m_SampleDataSheets.clear(); + + if(this->m_aDx0) delete this->m_aDx0; this->m_aDx0=NULL; + if(this->m_aDy0) delete this->m_aDy0; this->m_aDy0=NULL; + if(this->m_aDz0) delete this->m_aDz0; this->m_aDz0=NULL; + return; +} + +//************************************************************************** +void VisAtomTrajectory::AddData(VisAtomDataSheet*pData) +{ + if(this->m_SampleDataSheets.isEmpty()) + { + //save the postion data of the the point + this->m_aDx0 = new float[this->m_curSample->m_numAtom]; + this->m_aDy0 = new float[this->m_curSample->m_numAtom]; + this->m_aDz0 = new float[this->m_curSample->m_numAtom]; + memcpy(this->m_aDx0, pData->GetData(pData->GetPosXCol()), sizeof(float)*this->m_curSample->m_numAtom); + memcpy(this->m_aDy0, pData->GetData(pData->GetPosYCol()), sizeof(float)*this->m_curSample->m_numAtom); + memcpy(this->m_aDz0, pData->GetData(pData->GetPosZCol()), sizeof(float)*this->m_curSample->m_numAtom); + } + this->m_SampleDataSheets.append(pData); + + float*x0 = this->m_SampleDataSheets[0]->GetData(this->m_curSample->m_pData->GetPosXCol()); + float*y0 = this->m_SampleDataSheets[0]->GetData(this->m_curSample->m_pData->GetPosYCol()); + float*z0 = this->m_SampleDataSheets[0]->GetData(this->m_curSample->m_pData->GetPosZCol()); + + float*dx = pData->GetData(pData->GetPosXCol()); + float*dy = pData->GetData(pData->GetPosYCol()); + float*dz = pData->GetData(pData->GetPosZCol()); + + for(int i=0; im_curSample->m_numAtom; i++) + { + dx[i] = x0[i] + (dx[i] - this->m_aDx0[i]); + dy[i] = y0[i] + (dy[i] - this->m_aDy0[i]); + dz[i] = z0[i] + (dz[i] - this->m_aDz0[i]); + } + + return; +} + +//************************************************************************** +void VisAtomTrajectory::AttachSample(VisAtomSample*pSample) +{ + this->m_curSample = pSample; + return; +} + +//************************************************************************** +VisAtomDataSheet*VisAtomTrajectory::GetDataSheet(int i) +{ + if(i>= this->m_SampleDataSheets.size()) return NULL; + else return this->m_SampleDataSheets[i]; +} + +//************************************************************************** +void VisAtomTrajectory::SetDataCol(int colx, int coly, int colz) +{ + if(this->m_SampleDataSheets.isEmpty()) return; + + + int i,j; + float*x0 = this->m_SampleDataSheets[0]->GetData(this->m_curSample->m_pData->GetPosXCol()); + float*y0 = this->m_SampleDataSheets[0]->GetData(this->m_curSample->m_pData->GetPosYCol()); + float*z0 = this->m_SampleDataSheets[0]->GetData(this->m_curSample->m_pData->GetPosZCol()); + + //restore the old data stte + for(j=0; jm_SampleDataSheets.size(); j++) + { + float*dx = this->m_SampleDataSheets[j]->GetData(this->m_SampleDataSheets[j]->GetPosXCol()); + float*dy = this->m_SampleDataSheets[j]->GetData(this->m_SampleDataSheets[j]->GetPosYCol()); + float*dz = this->m_SampleDataSheets[j]->GetData(this->m_SampleDataSheets[j]->GetPosZCol()); + for(i=0; im_curSample->m_numAtom; i++) + { + dx[i] = dx[i] - x0[i] + this->m_aDx0[i]; + dy[i] = dy[i] - y0[i] + this->m_aDy0[i]; + dz[i] = dz[i] - z0[i] + this->m_aDz0[i]; + } + } + + //reset the new data + this->m_SampleDataSheets[0]->SetPosxCol(colx); + this->m_SampleDataSheets[0]->SetPosyCol(coly); + this->m_SampleDataSheets[0]->SetPoszCol(colz); + memcpy(this->m_aDx0, this->m_SampleDataSheets[0]->GetData(colx), sizeof(float)*this->m_curSample->m_numAtom); + memcpy(this->m_aDy0, this->m_SampleDataSheets[0]->GetData(coly), sizeof(float)*this->m_curSample->m_numAtom); + memcpy(this->m_aDz0, this->m_SampleDataSheets[0]->GetData(colz), sizeof(float)*this->m_curSample->m_numAtom); + + for(j=0; jm_SampleDataSheets.size(); j++) + { + //resuore the old data stte + this->m_SampleDataSheets[j]->SetPosxCol(colx); + this->m_SampleDataSheets[j]->SetPosyCol(coly); + this->m_SampleDataSheets[j]->SetPoszCol(colz); + float*dx = this->m_SampleDataSheets[j]->GetData(colx); + float*dy = this->m_SampleDataSheets[j]->GetData(coly); + float*dz = this->m_SampleDataSheets[j]->GetData(colz); + for(i=0; im_curSample->m_numAtom; i++) + { + dx[i] = x0[i] + (dx[i] - this->m_aDx0[i]); + dy[i] = y0[i] + (dy[i] - this->m_aDy0[i]); + dz[i] = z0[i] + (dz[i] - this->m_aDz0[i]); + } + } + + return; +} + +//************************************************************************** +int VisAtomTrajectory::GetDisplacement(int iatom, float&DX, float&DY, float&DZ) +{ + if(this->m_SampleDataSheets.size() == 0) return 0; + + float*x0 = this->m_SampleDataSheets[0]->GetData(this->m_SampleDataSheets[0]->GetPosXCol()); + float*y0 = this->m_SampleDataSheets[0]->GetData(this->m_SampleDataSheets[0]->GetPosYCol()); + float*z0 = this->m_SampleDataSheets[0]->GetData(this->m_SampleDataSheets[0]->GetPosZCol()); + + int n = this->m_SampleDataSheets.size()-1; + float*x1 = this->m_SampleDataSheets[n]->GetData(this->m_SampleDataSheets[n]->GetPosXCol()); + float*y1 = this->m_SampleDataSheets[n]->GetData(this->m_SampleDataSheets[n]->GetPosYCol()); + float*z1 = this->m_SampleDataSheets[n]->GetData(this->m_SampleDataSheets[n]->GetPosZCol()); + + + DX = x1[iatom] - x0[iatom]; + DY = y1[iatom] - y0[iatom]; + DZ = z1[iatom] - z0[iatom]; + return 1; + +} +//************************************************************************** +int VisAtomTrajectory::GetPathlength(int iatom, float&pathlen) +{ + if(this->m_SampleDataSheets.size() == 0) return 0; + + float*x0 = this->m_SampleDataSheets[0]->GetData(this->m_SampleDataSheets[0]->GetPosXCol()); + float*y0 = this->m_SampleDataSheets[0]->GetData(this->m_SampleDataSheets[0]->GetPosYCol()); + float*z0 = this->m_SampleDataSheets[0]->GetData(this->m_SampleDataSheets[0]->GetPosZCol()); + + float*x1, *y1, *z1; + double dd=0; + for(int j=1; jm_SampleDataSheets.size(); j++) + { + x1 = this->m_SampleDataSheets[j]->GetData(this->m_SampleDataSheets[j]->GetPosXCol()); + y1 = this->m_SampleDataSheets[j]->GetData(this->m_SampleDataSheets[j]->GetPosYCol()); + z1 = this->m_SampleDataSheets[j]->GetData(this->m_SampleDataSheets[j]->GetPosZCol()); + dd = pow(x1[iatom] - x0[iatom],2) + pow(y1[iatom] - y0[iatom],2) + pow(z1[iatom] - z0[iatom],2); + pathlen = pathlen + pow(dd,0.5); + + x0 = x1; + y0 = y1; + z0 = z1; + } + return 1; +} + + + +//************************************************************************** +void VisAtomTrajectory::Paint() +{ + if(this->m_SampleDataSheets.isEmpty()) return; + if(!this->m_curSample) return; + glMatrixMode(GL_MODELVIEW); + glEnable(GL_DEPTH_TEST); + this->DrawTrjectoryLine(); +} + +//************************************************************************** +void VisAtomTrajectory::DrawTrjectoryLine() +{ + + glEnable(GL_COLOR_MATERIAL); + + int j, i; + glDisable(GL_LIGHTING); + + + VisAtomDataSheet*p0 = this->m_SampleDataSheets[0]; + VisAtomDataSheet*p1 = NULL; + float*px0, *py0, *pz0; + float*px1, *py1, *pz1; + float*s0 = NULL; + float*s1 = NULL; + int scalcol = VisAtomVisualizingPolicy::GetScalarCol(); + if(scalcol >= 0) s0 = p0->GetData(scalcol); + + px0 = p0->GetData(p0->GetPosXCol()); + py0 = p0->GetData(p0->GetPosYCol()); + pz0 = p0->GetData(p0->GetPosZCol()); + + int*aGeomStyle = this->m_curSample->m_aGeomStyle; + char*aVisStat = this->m_curSample->m_aVisStat; + float*Red = this->m_curSample->m_aRed; + float*Green = this->m_curSample->m_aGreen; + float*Blue = this->m_curSample->m_aBlue; + char*aType = this->m_curSample->m_aType; + + int numsub = this->m_curSample->m_subSamples.size(); + float*thick = new float[numsub]; + int *colorstyle = new int[numsub]; + for(i=0; im_curSample->m_subSamples[i]->GetCurTrajectoryLinethick(); + colorstyle[i] = this->m_curSample->m_subSamples[i]->GetCurColorStyle(); + } + + int numatoms = this->m_curSample->m_numAtom; + + //draw in single color + for(j=1; jm_SampleDataSheets.size(); j++) + { + p1 = this->m_SampleDataSheets[j]; + px1 = p1->GetData(p1->GetPosXCol()); + py1 = p1->GetData(p1->GetPosYCol()); + pz1 = p1->GetData(p1->GetPosZCol()); + if(scalcol >= 0) s1 = p1->GetData(scalcol); + + for(i=0; i m_SampleDataSheets; + VisAtomSample*m_curSample; + float*m_aDx0; + float*m_aDy0; + float*m_aDz0; + friend class VisAtomSample; + + void DrawTrjectoryLine(); + + public: + VisAtomTrajectory(); + ~VisAtomTrajectory(); + + void AttachSample(VisAtomSample*pSample); + + void Clear(); + void AddData(VisAtomDataSheet*pData); + int NumberOfDatasheet(){return m_SampleDataSheets.size();} ; + void SetDataCol(int colx, int coly, int colz); + VisAtomDataSheet*GetDataSheet(int i); + + int GetDisplacement(int iatom, float&DX, float&DY, float&DZ); + int GetPathlength(int iatom, float&pathlen); + + void Paint(); + +}; + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisAtomVisualizingPolicy.cpp b/VISATOMSRC/VisAtomVisualizingPolicy.cpp new file mode 100644 index 0000000..ea8facf --- /dev/null +++ b/VISATOMSRC/VisAtomVisualizingPolicy.cpp @@ -0,0 +1,230 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#include +#include + +#include "VisAtomVisualizingPolicy.h" + +//default color table +static const int CORLOR_NUM = 10; +static const float CORLOR_TABLE[CORLOR_NUM][4] = +{ + 0.5f, 0.0f, 0.0f, 1.f, + 0.0f, 0.3f, 0.0f, 1.f, + 0.0f, 0.0f, 0.3f, 1.f, + 0.5f, 0.3f, 0.0f, 1.f, + 0.5f, 0.0f, 0.3f, 1.f, + 0.0f, 0.3f, 0.3f, 1.f, + 0.5f, 0.3f, 0.3f, 1.f, + 0.1f, 0.0f, 0.0f, 1.f, + 0.0f, 0.1f, 0.0f, 1.f, + 0.0f, 0.0f, 0.1f, 1.f, +}; + +static const int CORLOR_MAP_SIZE = VisAtomVisualizingPolicy::CORLOR_MAP_SIZE; +static const int CORLOR_MAP_SIZEM = CORLOR_MAP_SIZE-1; +static const float MAP_TABLE[CORLOR_MAP_SIZE][3] = +{ + { 0.0, 0.0, 1.0, }, + { 0.0, 1.0, 1.0, }, + { 0.0, 1.0, 0.0, }, + { 1.0, 1.0, 0.0, }, + { 1.0, 0.5, 0.0, }, + { 1.0, 0.0, 0.0, }, +}; +//size mapping parameters +int VisAtomVisualizingPolicy::m_radcol = -1; +float VisAtomVisualizingPolicy::m_radscal = 1; +float*VisAtomVisualizingPolicy::m_raddata = NULL; + +//color mapping parameters +int VisAtomVisualizingPolicy::m_scalarcol = -1; +int VisAtomVisualizingPolicy::m_colormap = 0; +float VisAtomVisualizingPolicy::m_scalarmin = 0.f; +float VisAtomVisualizingPolicy::m_scalarmax = 1.f; +float VisAtomVisualizingPolicy::m_scalarrange = VisAtomVisualizingPolicy::m_scalarmax - VisAtomVisualizingPolicy::m_scalarmin; +//float VisAtomVisualizingPolicy::m_wscalarmin = m_scalarmin; +//float VisAtomVisualizingPolicy::m_wscalarmax = m_scalarmax; +//float VisAtomVisualizingPolicy::m_wscalarrange = VisAtomVisualizingPolicy::m_wscalarmax - VisAtomVisualizingPolicy::m_wscalarmin; +float*VisAtomVisualizingPolicy::m_mappingdata = NULL; + +float VisAtomVisualizingPolicy::m_wscalartab[CORLOR_MAP_SIZE] = {0.f, 0.f, 0.f, 0.f, 0.f, 1.f}; + + +//vector visualization parameteters +float VisAtomVisualizingPolicy::m_vlenscal = -1.0f; +float VisAtomVisualizingPolicy::m_vrad = 0.1f; +float VisAtomVisualizingPolicy::m_arrowl = 0.2f; +float VisAtomVisualizingPolicy::m_arrowr = 0.2f; +int VisAtomVisualizingPolicy::m_vcol[3]={-1,-1,-1}; + +//trajectory visualization parameters +VisAtomDataSheet* VisAtomVisualizingPolicy::m_datasheet = NULL; + + +//projection visualization parameters +int VisAtomVisualizingPolicy::m_autoBox = 1; +float VisAtomVisualizingPolicy::m_projectionBox[6]={0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + + + +VisAtomVisualizingPolicy::~VisAtomVisualizingPolicy() +{ +} + +VisAtomVisualizingPolicy::VisAtomVisualizingPolicy() +{ + + m_geomStyle = GEOM_STYLE_ATOM | GEOM_STYLE_3D; //|GEOM_STYLE_PROJECT; + //display property of atoms in the subsample + m_shapeStyle= SHAPE_STYLE_DOT; + m_radius = 0.5f; + m_unifyradiu = 1; + + m_vectorStyle = VECTOR_STYLE_LINE; + m_trajectoryStyle = TRAJECTORY_STYLE_STARTSITE|TRAJECTORY_STYLE_ENDSITE|TRAJECTORY_STYLE_HASLINE; + + m_colorStyle = COLOR_STYLE_SINGLE; + m_red = CORLOR_TABLE[0][0]; + m_green = CORLOR_TABLE[0][1]; + m_blue = CORLOR_TABLE[0][2]; + m_alpha = CORLOR_TABLE[0][3]; + + m_tLinethick = 1.f; + m_tRadiusscal= 0.25f; + + m_projectionStyle = VisAtomVisualizingPolicy::PROJECTION_STYLE_X0 + + VisAtomVisualizingPolicy::PROJECTION_STYLE_Y0 + + VisAtomVisualizingPolicy::PROJECTION_STYLE_Z0; + m_3dStyle = VisAtomVisualizingPolicy::D3_STYLE_INBOX; + + return; +} + +VisAtomVisualizingPolicy::VisAtomVisualizingPolicy(VisAtomVisualizingPolicy*sor) +{ + Paste(sor); +} + +void VisAtomVisualizingPolicy::SetColorByDefaultTable(int index) +{ + int it = index; + if(it >= CORLOR_NUM) it = 0; + + m_red = CORLOR_TABLE[it][0]; + m_green = CORLOR_TABLE[it][1]; + m_blue = CORLOR_TABLE[it][2]; + m_alpha = CORLOR_TABLE[it][3]; + return; +} + +//*********************************************************************************** +// return the color of atom index +void VisAtomVisualizingPolicy::GetColor(float&R, float&G, float&B, float&A, int index, float*exscalar) +{ + + double scalar = exscalar[index]; + if(scalar <= m_wscalartab[0]) + { + R = MAP_TABLE[0][0]; + G = MAP_TABLE[0][1]; + B = MAP_TABLE[0][2]; + return; + } + else if(scalar >= m_wscalartab[CORLOR_MAP_SIZEM]) + { + R = MAP_TABLE[CORLOR_MAP_SIZEM][0]; + G = MAP_TABLE[CORLOR_MAP_SIZEM][1]; + B = MAP_TABLE[CORLOR_MAP_SIZEM][2]; + return; + } + + int i, it, it1; + for(i=1; im_colorStyle == VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE) + { + this->GetColor(R, G, B, A); + return; + } + + VisAtomVisualizingPolicy::GetColor(R, G, B, A, index, this->m_mappingdata); + return; +} + +//*********************************************************************************** +void VisAtomVisualizingPolicy::Paste(VisAtomVisualizingPolicy*sor) +{ + + //display property of atoms in the subsample + m_shapeStyle = sor->m_shapeStyle; + m_radius = sor->m_radius; + m_vlenscal = sor->m_vlenscal; + m_vrad = sor->m_vrad; + m_arrowl = sor->m_arrowl; + m_arrowr = sor->m_arrowr; + m_vcol[1] = sor->m_vcol[1]; + m_vcol[2] = sor->m_vcol[2]; + m_vcol[3] = sor->m_vcol[3]; + + m_colorStyle = sor->m_colorStyle; + m_red = sor->m_red; + m_green = sor->m_green; + m_blue = sor->m_blue; + m_alpha = sor->m_alpha; + + m_trajectoryStyle = sor->m_trajectoryStyle; + m_tLinethick = sor->m_tLinethick; + m_tRadiusscal = sor->m_tRadiusscal; + + m_projectionStyle = sor->m_projectionStyle; + m_3dStyle = sor->m_3dStyle; +} + +int VisAtomVisualizingPolicy::GetColorMappingNumBar() +{ + return CORLOR_MAP_SIZE; +} + +void VisAtomVisualizingPolicy::GetColorMappingBar(int index, float&R, float&G, float&B) +{ + R = MAP_TABLE[index][0]; + G = MAP_TABLE[index][1]; + B = MAP_TABLE[index][2]; +} + +void VisAtomVisualizingPolicy::SetScalarMappingTab(float smin, float smax) +{ + float dv = (smax - smin)/(float)CORLOR_MAP_SIZEM; + for(int i=0; iGetData(col);} + static int GetAtomSizeCol() { return m_radcol;} + + //*** functions concerning geometry style + int GetGeomStyle() + { int style = 0; + if(m_geomStyle&GEOM_STYLE_ATOM) style = style|m_shapeStyle; + if(m_geomStyle&GEOM_STYLE_VECTOR) style = style|m_vectorStyle; + if(m_geomStyle&GEOM_STYLE_TRAJECT) style = style|m_trajectoryStyle; + if (m_geomStyle&GEOM_STYLE_PROJECT) style = style|m_projectionStyle; + if (m_geomStyle&GEOM_STYLE_3D) style = style|m_3dStyle; + return style; + }; + + void SetGeomStyleAtomVisible(bool visible) + { int style = 0; + //if(m_geomStyle&GEOM_STYLE_VECTOR) style = style| GEOM_STYLE_VECTOR; + //if(visible) style = style | GEOM_STYLE_ATOM; + style = style|(m_geomStyle&GEOM_STYLE_VECTOR); + style = style|(m_geomStyle&GEOM_STYLE_TRAJECT); + style = style|(m_geomStyle&GEOM_STYLE_PROJECT); + style = style|(m_geomStyle&GEOM_STYLE_3D); + if(visible) style = style | GEOM_STYLE_ATOM; + m_geomStyle = style; + } + bool IsGeomStyleAtomVisible(){ return m_geomStyle&GEOM_STYLE_ATOM;} + + + //vector functions + void SetVectorStyle(int style) { m_vectorStyle = style;} + int GetVectorStyle() { return m_vectorStyle;} + void SetGeomStyleVectorVisible(bool visible) + { int style = 0; + //if(m_geomStyle&GEOM_STYLE_ATOM) style = style| GEOM_STYLE_ATOM; + //if(visible) style = style | GEOM_STYLE_VECTOR; + style = style|(m_geomStyle&GEOM_STYLE_TRAJECT); + style = style|(m_geomStyle&GEOM_STYLE_ATOM); + style = style|(m_geomStyle&GEOM_STYLE_PROJECT); + style = style|(m_geomStyle&GEOM_STYLE_3D); + if(visible) style = style | GEOM_STYLE_VECTOR; + + m_geomStyle = style; + } + bool IsGeomStyleVectorVisible(){return m_geomStyle&GEOM_STYLE_VECTOR;} + + + //trjectory functions + void SetTrajectoryStyle(int style) { m_trajectoryStyle = style;} + int GetTrajectoryStyle() { return m_trajectoryStyle;} + void SetGeomStyleTrajectoryVisible(bool visible) + { int style = 0; + style = style|(m_geomStyle&GEOM_STYLE_ATOM); + style = style|(m_geomStyle&GEOM_STYLE_VECTOR); + style = style|(m_geomStyle&GEOM_STYLE_PROJECT); + style = style|(m_geomStyle&GEOM_STYLE_3D); + if(visible) style = style | GEOM_STYLE_TRAJECT; + + m_geomStyle = style; + } + bool IsGeomStyleTrajectoryVisible(){return m_geomStyle&GEOM_STYLE_TRAJECT;} + void SetTrajectoryLinethick(float thick){ m_tLinethick = thick;} + float GetTrajectoryLinethick(){ return m_tLinethick;} + void SetTrajectorySitescal(float scal){ m_tRadiusscal = scal;} + float GetTrajectorySitescal(){ return m_tRadiusscal;} + float GetTrajectorySitesize(){ return m_tRadiusscal*m_radius;} + + //projecction functions + void SetProjectionStyle(int style) { m_projectionStyle = style;} + int GetProjectionStyle() { return m_projectionStyle;} + void SetGeomStyleProjectionVisible(bool visible) + { int style = 0; + style = style|(m_geomStyle&GEOM_STYLE_ATOM); + style = style|(m_geomStyle&GEOM_STYLE_VECTOR); + style = style|(m_geomStyle&GEOM_STYLE_TRAJECT); + style = style|(m_geomStyle&GEOM_STYLE_3D); + if(visible) style = style | GEOM_STYLE_PROJECT; + + m_geomStyle = style; + } + bool IsGeomStyleProjectionVisible(){return m_geomStyle&GEOM_STYLE_PROJECT;} + + //3d functions + void Set3DStyle(int style) { m_3dStyle = style; } + int Get3DStyle() { return m_3dStyle; } + void SetGeomStyle3DVisible(bool visible) + { + int style = 0; + style = style | (m_geomStyle&GEOM_STYLE_ATOM); + style = style | (m_geomStyle&GEOM_STYLE_VECTOR); + style = style | (m_geomStyle&GEOM_STYLE_TRAJECT); + style = style | (m_geomStyle&GEOM_STYLE_PROJECT); + if (visible) style = style | GEOM_STYLE_3D; + m_geomStyle = style; + } + bool IsGeomStyle3DVisible() { return m_geomStyle & GEOM_STYLE_3D; } + + + //static functions: + static void SetDataSheet(VisAtomDataSheet*datasheet) + { + m_datasheet = datasheet; + if(m_scalarcol >=0 && m_scalarcol < datasheet->GetNumCol()) m_mappingdata = m_datasheet->GetData(m_scalarcol); + else {m_scalarcol = -1; m_mappingdata = NULL;} + + if(m_radcol>=0 && m_radcol < datasheet->GetNumCol()) m_raddata = m_datasheet->GetData(m_radcol); + else {m_radcol = -1; m_raddata = NULL;} + + } + //static functions concerning color mapping + static void SetScalarCol(int col) {m_scalarcol = col; m_mappingdata = m_datasheet->GetData(m_scalarcol); } + static int GetScalarCol() { return m_scalarcol;} + static void SetScalarRange(float min, float max) { m_scalarmin = min; m_scalarmax = max; m_scalarrange = m_scalarmax - m_scalarmin;} + static void GetScalarRange(float&min, float&max) { min = m_scalarmin; max = m_scalarmax;} + static int GetColorMappingNumBar(); + static void GetColorMappingBar(int index, float&R, float&G, float&B); + static void VisAtomVisualizingPolicy::SetScalarMappingTab(int index, float value) + { + VisAtomVisualizingPolicy::m_wscalartab[index] = value; + } + static float VisAtomVisualizingPolicy::GetScalarMappingTabValue(int index) + { + return VisAtomVisualizingPolicy::m_wscalartab[index]; + } + static float VisAtomVisualizingPolicy::GetScalarMappingTabMinValue() + { + return VisAtomVisualizingPolicy::m_wscalartab[0]; + } + static float VisAtomVisualizingPolicy::GetScalarMappingTabMaxValue() + { + return VisAtomVisualizingPolicy::m_wscalartab[sizeof(m_wscalartab)/sizeof(float)-1]; + } + static void SetScalarMappingTab(float smin, float smax); + + //static functions concerning vector visualization + static bool HasVectorData() + { + bool yes = false; + + if(m_datasheet && + (m_vcol[0] >= 0 && m_vcol[0] < m_datasheet->GetNumCol()) && + (m_vcol[1] >= 0 && m_vcol[1] < m_datasheet->GetNumCol()) && + (m_vcol[2] >= 0 && m_vcol[2] < m_datasheet->GetNumCol()) ) + yes = true; + + return yes; + } + + static void SetVectorCol(int vcol[3]) + { + m_vcol[0] = vcol[0]; + m_vcol[1] = vcol[1]; + m_vcol[2] = vcol[2]; + } + + static void GetVectorCol(int vcol[3]) + { + vcol[0] = m_vcol[0]; + vcol[1] = m_vcol[1]; + vcol[2] = m_vcol[2]; + } + + + static void SetVectorSize(float vlenscal, float vrad, float arrowl, float arrowr) + { + m_vlenscal = vlenscal; + m_vrad = vrad; + m_arrowl = arrowl; + m_arrowr = arrowr; + } + static void SetVectorSize(float vrad, float vlenscal){ m_vrad = vrad; m_vlenscal = vlenscal;} + + static void GetVectorSize(float&vlenscal, float&vrad, float&arrowl, float&arrowr) + { + vlenscal = m_vlenscal; + vrad = m_vrad; + arrowl = m_arrowl; + arrowr = m_arrowr; + } + static void GetVectorSize(float&vrad, float&vlenscal){ vrad = m_vrad; vlenscal = m_vlenscal;} + + //static function concerning projection + static int IsAutoProjectionBox() + { + return m_autoBox; + } + + static void SetAutoProjectionBox(bool autobox) + { + m_autoBox = autobox; + } + + static void SetProjectionBox(float x0, float x1, float y0, float y1, float z0, float z1) + { + m_projectionBox[0] = x0; + m_projectionBox[1] = x1; + m_projectionBox[2] = y0; + m_projectionBox[3] = y1; + m_projectionBox[4] = z0; + m_projectionBox[5] = z1; + } + static void GetProjectionBox(float& x0, float& x1, float& y0, float& y1, float& z0, float& z1) + { + x0 = m_projectionBox[0]; + x1 = m_projectionBox[1]; + y0 = m_projectionBox[2]; + y1 = m_projectionBox[3]; + z0 = m_projectionBox[4]; + z1 = m_projectionBox[5]; + } + + }; + +#endif \ No newline at end of file diff --git a/VISATOMSRC/VisClusterEnvelope.cpp b/VISATOMSRC/VisClusterEnvelope.cpp new file mode 100644 index 0000000..87924a8 --- /dev/null +++ b/VISATOMSRC/VisClusterEnvelope.cpp @@ -0,0 +1,609 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ +#include // Standard windows include +#include // OpenGL library +#include // OpenGL library + +#include +#include + +#include "Arrow.h" +#include "Arrowline.h" +#include "Circle.h" +#include "SolidCircle.h" +#include "Style.h" +#include "VisClusterEnvelope.h" + +static QString CLASSNAME = "VisClusterEnvelope"; +QString VisClusterEnvelope::RUNTIME_CLASSNAME(){ return CLASSNAME;}; + +static int CURRENT_EXTNUM = -1; +static QString CURRENT_FNAME = ""; + + +//*********************************************************** +ClusterEnvelopeFace::ClusterEnvelopeFace(int nv) +{ + m_ITY0=0; m_IA0=0; m_GIA0=0; + m_ITY1=0; m_IA1=0; m_GIA1=0; + m_NV = nv; + if(m_NV > 0) m_Vert = new float[m_NV*3]; +} + +ClusterEnvelopeFace::~ClusterEnvelopeFace() + { + if(m_Vert) delete m_Vert; + m_NV= 0; + } + + +void ClusterEnvelopeFace::Set(int nv) + { + if(m_Vert) delete m_Vert; + m_Vert = NULL; + m_NV = nv; + if(m_NV > 0) m_Vert = new float[m_NV*3]; + + return; + } + + void ClusterEnvelopeFace::Set(int nv, float dvt0[], float dvt1[], float*vert) + { + this->Set(nv); + + int i; + for (i=0; i<3; i++) + { + m_DVT0[i] = dvt0[i]; + m_DVT1[i] = dvt1[i]; + } + for (i=0; im_DVT0[0], this->m_DVT0[1], this->m_DVT0[2]); + /*glNormal3f(this->m_DVT1[0] - this->m_DVT0[0], + this->m_DVT1[1] - this->m_DVT0[1], + this->m_DVT1[2] - this->m_DVT0[2]);*/ + + glBegin(GL_POLYGON); + for(iv=0; ivm_NV; iv++) + { + glNormal3f(this->m_Vert[iv*3] - this->m_DVT0[0], + this->m_Vert[iv*3+1] - this->m_DVT0[1], + this->m_Vert[iv*3+2] - this->m_DVT0[2]); + glVertex3f(this->m_Vert[iv*3], this->m_Vert[iv*3+1], this->m_Vert[iv*3+2]); + } + glEnd(); + glPopMatrix(); + + } + + //*********************************************************** + ClusterEnvelope:: ClusterEnvelope() + { + m_NF=0; + m_Face= NULL; + this->m_red = 0.5f; + this->m_green = 0.5f; + this->m_blue = 0.f; + this->m_alpha = 1.0f; + }; + +ClusterEnvelope::ClusterEnvelope(int nf) +{ + this->m_NF = nf; + if(this->m_NF > 0) this->m_Face = new ClusterEnvelopeFace*[m_NF]; + for(int i=0; im_NF; i++) this->m_Face[i] = new ClusterEnvelopeFace(); + this->m_red = 0.5f; + this->m_green = 0.5f; + this->m_blue = 0.f; + this->m_alpha = 1.0f; +} + +ClusterEnvelope::~ClusterEnvelope() + { + if(this->m_Face) + { + for(int i=0; im_NF; i++) + if(this->m_Face[i]) delete this->m_Face[i]; + delete this->m_Face; + this->m_Face = NULL; + } + this->m_NF= 0; + } + + + void ClusterEnvelope::PaintSolidface() + { + glColor4f(this->m_red, this->m_green, this->m_blue, this->m_alpha); + for(int i=0; im_NF; i++) + { + if(this->m_Face[i]) this->m_Face[i]->Paint(); + } + } + + void ClusterEnvelope::PaintWireface() + { + glColor3f(1.f-this->m_red, 1.f-this->m_green, 1.f-this->m_blue); + for(int i=0; im_NF; i++) + { + if(this->m_Face[i]) this->m_Face[i]->Paint(); + } + } + + + +//************************************************************ +int static iscomment( char*str) +{ +/* +! Purpose: to determinte if the string is a commnet line +! Input: STRING a string +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + + for(int i=0; i 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + index1 = 0; + } + flag = 0; + } + else + { + if((str[i] >= '0' && str[i] <= '9') || str[i] == '-' || str[i] == '+' || str[i] == '.' ) + { + if(flag == 0 ) + { + flag = 1; + count ++; + if(count > mxCount) break; + } + } + else + { + if(flag != 1) flag = 2; + } + } + + if(flag == 1) index1 ++; + + i++; + if(i >= strlen(str) ) + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + } + break; + } + } while(1); + return count; +} + +//*********************************************************** +void VisClusterEnvelope::Clear(bool keepsubsample) +{ + if(this->m_Clus) + { + for(int i=0; im_NC; i++) + if(this->m_Clus[i]) delete this->m_Clus[i]; + delete this->m_Clus; + } + this->m_NC = 0; + this->m_Clus = NULL; + return; +} + +//*********************************************************** +VisClusterEnvelope::~VisClusterEnvelope() +{ + Clear(); +} +//*********************************************************** +VisClusterEnvelope::VisClusterEnvelope() +{ + this->m_NC = 0; + this->m_Clus = NULL; + +} + +//*********************************************************** +void VisClusterEnvelope::Paint() +{ + + if(this->m_NC == 0) return; + + Style Sty; + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + Sty.Solid(); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_NORMALIZE); + + for(int i=0; im_NC; i++) + { + if(this->m_Clus[i]) this->m_Clus[i]->PaintSolidface(); + } + glDisable(GL_LIGHTING); + Sty.Wire(); + for(int i=0; im_NC; i++) + { + if(this->m_Clus[i]) this->m_Clus[i]->PaintWireface(); + } + return; +} + +int VisClusterEnvelope::CURRENT_FILEINDEX() +{ + return CURRENT_EXTNUM; +} + +QString VisClusterEnvelope::CURRENT_FILENAME() +{ + return CURRENT_FNAME; +} +//*********************************************************** +#define MAXSTRL 256 +#define MAXCOL 10 +#define NUMSTRL 32 +int VisClusterEnvelope::LoadData(QString fname) +{ + + QFile file(fname); + if(!file.open(QIODevice::ReadOnly|QIODevice::Text)) return 0; + + + //to determine the format of the file + char buf[MAXSTRL]; + char*strnumb[MAXCOL]; + int i, nc; + for(i=0; iClear(); + + this->m_NC = nc; + if(this->m_NC > 0) + { + this->m_Clus = new ClusterEnvelope*[this->m_NC]; + for(i=0; im_NC; i++) this->m_Clus[i] = NULL; + + nc =0; + //to get load the cluster facess + int len, ind, ic = -1, nf; + for(i=0; im_NC; i++) + { + // get the cluster id + while (!file.atEnd()) + { + len = file.readLine(buf, sizeof(buf))-1; + hlines++; + if(len <= 0) continue; + if(iscomment(buf)) continue; + + //the cluster id + if(iskeyword(buf, "&CLUS") ) + { + if(extract_numb( buf, 1, strnumb)) { ic = atoi(strnumb[0])-1; break;} + } + else + continue; + } + + //the number of faces + while (!file.atEnd()) + { + len = file.readLine(buf, sizeof(buf))-1; + hlines++; + if(len <= 0) continue; + if(iscomment(buf)) continue; + + if( iskeyword(buf, "&NFACE") ) + { + if(extract_numb( buf, 1, strnumb)) {nf = atoi(strnumb[0]); break;} + else {nf = 0; break;}; + } + else + continue; + } + //create the envelope of nf facet + this->m_Clus[ic] = new ClusterEnvelope(nf); + + //get the vertices of faces + int j, iface, nv, iv; + for(j=0; jm_Clus[ic]->m_Face[iface]->m_IA0 = atoi(strnumb[1]); + this->m_Clus[ic]->m_Face[iface]->m_GIA0 = atoi(strnumb[2]); + this->m_Clus[ic]->m_Face[iface]->m_ITY0 = atoi(strnumb[3]); + this->m_Clus[ic]->m_Face[iface]->m_DVT0[0] = atof(strnumb[4]); + this->m_Clus[ic]->m_Face[iface]->m_DVT0[1] = atof(strnumb[5]); + this->m_Clus[ic]->m_Face[iface]->m_DVT0[2] = atof(strnumb[6]); + + len = file.readLine(buf, sizeof(buf))-1; + ncol = extract_numb( buf, MAXCOL, strnumb); + this->m_Clus[ic]->m_Face[iface]->m_IA1 = atoi(strnumb[0]); + this->m_Clus[ic]->m_Face[iface]->m_GIA1 = atoi(strnumb[1]); + this->m_Clus[ic]->m_Face[iface]->m_ITY1 = atoi(strnumb[2]); + this->m_Clus[ic]->m_Face[iface]->m_DVT1[0] = atof(strnumb[3]); + this->m_Clus[ic]->m_Face[iface]->m_DVT1[1] = atof(strnumb[4]); + this->m_Clus[ic]->m_Face[iface]->m_DVT1[2] = atof(strnumb[5]); + + //gett number of vetices + len = file.readLine(buf, sizeof(buf))-1; + if( iskeyword(buf, "&NVERT") ) + { + ncol = extract_numb( buf, 1, strnumb); + nv = atoi(strnumb[0]); + this->m_Clus[ic]->m_Face[iface]->Set(nv); + for(iv=0; ivm_Clus[ic]->m_Face[iface]->m_Vert[iv*3 ] = atof(strnumb[0]); + this->m_Clus[ic]->m_Face[iface]->m_Vert[iv*3+1] = atof(strnumb[1]); + this->m_Clus[ic]->m_Face[iface]->m_Vert[iv*3+2] = atof(strnumb[2]); + } + } //end for &NVERT + break; + } //end for iface if(haskeyword(buf) && iskeyword(buf, "&IFACE") ) + break; + } //end for while (!file.atEnd()) + }//end for (j=0; jm_NC; + //this->unsetCursor(); + + +} + +int VisClusterEnvelope::LoadDataNext() +{ + + if(CURRENT_EXTNUM < 0) return 0; + if(CURRENT_FNAME.isEmpty()) return 0; + + int ind = CURRENT_EXTNUM + 1; + + QString ext, snum, currentfname=CURRENT_FNAME; + snum.setNum(ind); + + ext='.'; + if(ind < 10) + ext.append("000"); + else if(ind < 100) + ext.append("00"); + else if(ind < 1000) + ext.append("0"); + ext.append(snum); + currentfname.append(ext); + return LoadData(currentfname); +} + +int VisClusterEnvelope::LoadDataPrev() +{ + + if(CURRENT_EXTNUM < 0) return 0; + if(CURRENT_FNAME.isEmpty()) return 0; + + int ind = CURRENT_EXTNUM - 1; + + QString ext, snum, currentfname=CURRENT_FNAME; + snum.setNum(ind); + + ext='.'; + if(ind < 10) + ext.append("000"); + else if(ind < 100) + ext.append("00"); + else if(ind < 1000) + ext.append('0'); + ext.append(snum); + currentfname.append(ext); + return LoadData(currentfname); +} + + + + diff --git a/VISATOMSRC/VisClusterEnvelope.h b/VISATOMSRC/VisClusterEnvelope.h new file mode 100644 index 0000000..a84f4b7 --- /dev/null +++ b/VISATOMSRC/VisClusterEnvelope.h @@ -0,0 +1,83 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#ifndef _VISCLUSTEREVELOPE_H +#define _VISCLUSTEREVELOPE_H +#include "VisAtomExtendObject.h" +//***************************** +class ClusterEnvelopeFace +{ + protected: + friend class ClusterEnvelope; + friend class VisClusterEnvelope; + + int m_NV; + int m_ITY0, m_IA0, m_GIA0; + int m_ITY1, m_IA1, m_GIA1; + float m_DVT0[3]; + float m_DVT1[3]; + float*m_Vert; + public: + ClusterEnvelopeFace() + { m_ITY0=0; m_IA0=0; m_GIA0=0; + m_ITY1=0; m_IA1=0; m_GIA1=0; + m_NV = 0; m_Vert = NULL;}; + ClusterEnvelopeFace(int nv); + ~ClusterEnvelopeFace(); + void Set(int nv); + void Set(int nv, float dvt0[], float dvt1[], float*vert); + void Paint(); +}; + +//***************************** +class ClusterEnvelope +{ + protected: + friend class ClusterEnvelopeFace; + friend class VisClusterEnvelope; + int m_NF; + ClusterEnvelopeFace**m_Face; + //display property + float m_red, m_green, m_blue, m_alpha; + + public: + ClusterEnvelope(); + ClusterEnvelope(int nf); + ~ClusterEnvelope(); + void PaintSolidface(); + void PaintWireface(); +}; + +//***************************** +class VisClusterEnvelope:public VisAtomExtendObject +{ + private: + + protected: + friend class ClusterEnvelope; + int m_NC; + ClusterEnvelope**m_Clus; + public: + QString RUNTIME_CLASSNAME(); + + VisClusterEnvelope(); + ~VisClusterEnvelope(); + void Clear(bool keepsubsample=false); + virtual void Paint(); + int LoadData(QString fname); + int LoadDataNext(); + int LoadDataPrev(); + static int CURRENT_FILEINDEX(); + static QString CURRENT_FILENAME(); + int HasData(){ return m_NC;} + + }; + + +#endif \ No newline at end of file diff --git a/VisAtom2017/ClassDiagram1.cd b/VisAtom2017/ClassDiagram1.cd new file mode 100644 index 0000000..a636940 --- /dev/null +++ b/VisAtom2017/ClassDiagram1.cd @@ -0,0 +1,179 @@ + + + + + + AAAABAAAAAAAECAAKAgAAAAAgBAQAAAkAAAAgAAAAAQ= + visatom2013_1.h + + + + + + AAGA5IAAAODAACACKCyAADICgAAQBAI0BEAAgAIEAIQ= + sor\VisAtomwidget.h + + + + + + AAAAAIAACAAAQgCAABBAAhAAAACAAAEAEAAABAEAAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Light.h + + + + + + sMF0X4pikgBQRcjg8QCSD3hrSALkAQj4UaAwQghsfgI= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Scene.h + + + + + + BICAAgAAIAACBAAACAQAAAAAAAAAAAIAEBAAAAAKAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Sphere.h + + + + + + AAAAgAAAAABAAAAAAAAAAAAAAAAAAAAAAQAAAAAMACA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Spheres.h + + + + + + EBAAAAAAACAAggACAIAAAgAACAAIAACgAABkKQEIAQI= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Point.h + + + + + + AAAAAAAAAAAAhgCAAIAAAAAACAAAAACgEABgKQEJAQA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Points.h + + + + + + cEBAAARwgIAQAgAAAAAAAAAAAAAAAAAAACAEAQAIAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\GLCOBJ.H + + + + + + EMgAXkxIQIABAyKIBpJCBASEAAwkAgFSGkEBCAGMc5E= + d:\ESpace\HouQing\Tools\QTVIS\VISATOMSRC\Atoms21.h + + + + + + xI2yTaIQKjiQwiEm2KUChlTOcvqyOm+SBv97FQdobJw= + d:\ESpace\HouQing\Tools\QTVIS\VISATOMSRC\Sample.h + + + + + + oUyIwSAQQECMwiIAEFQgBRAEBhUEAEGCAgBDaGtAmQA= + d:\ESpace\HouQing\Tools\QTVIS\VISATOMSRC\SubSample.h + + + + + + AAAAAQQAiQAQBAAAAAAAAAAAAAAACABIBAAIAAAAAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\STYLE.H + + + + + + AAAEABAAAAAABgAAAQCAAAAACAAAAAAAAAgggAQIAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Arrow.h + + + + + + AACAAgAAAAgABAAAARAAAAAAAAgAAAIAEAABAAAKAAI= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\CIRCLE.H + + + + + + AQAAAAAAAAAAABAAAAAwAAAAAAAAAAAQAAAAAAAIAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Cone.h + + + + + + AAAAAAAA0AAAAACAAEACAAAAKAAAAAAAAAAAAAAIAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\CUBIC.H + + + + + + JACAAAAAAAAABAAACAAAAAAACAAAAAIAAAQAAAAKAAA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Cylinder.h + + + + + + AIAEABAAACAAggOAAIAAAICgCQAIAACAgAAEaAMJAQg= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\Line.h + + + + + + AACAAgAAAAAABAAAAAAAAAAAAAAAAAIAkAAAAAAKgAI= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\SolidCircle.h + + + + + + EBAABAgAAAAABgCgAZAAgAAACgAAAICgAABgKAEIEwI= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\XyPoint.h + + + + + + AAAABAAAIIAABgCwAIAAAAAACgAAAACiEQBgKAEIAQA= + d:\ESpace\HouQing\Tools\QTVIS\GLLIBINC\XyPoints.h + + + + + + AIAAAIAAAAECQAAAAAAAAIAACAQAIAgAgAAAAIAAIAA= + GeneratedFiles\ui_visatom2013_1.h + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAEAAAAAA= + GeneratedFiles\qrc_visatom2013_1.cpp + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + GeneratedFiles\ui_visatom2013_1.h + + + + \ No newline at end of file diff --git a/VisAtom2017/VisAtom2017-a.cpp b/VisAtom2017/VisAtom2017-a.cpp new file mode 100644 index 0000000..89a34eb --- /dev/null +++ b/VisAtom2017/VisAtom2017-a.cpp @@ -0,0 +1,7 @@ +#include "VisAtom2017.h" + +VisAtom2017::VisAtom2017(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); +} diff --git a/VisAtom2017/VisAtom2017-a.h b/VisAtom2017/VisAtom2017-a.h new file mode 100644 index 0000000..476c4cf --- /dev/null +++ b/VisAtom2017/VisAtom2017-a.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "ui_VisAtom2017.h" + +class VisAtom2017 : public QMainWindow +{ + Q_OBJECT + +public: + VisAtom2017(QWidget *parent = Q_NULLPTR); + +private: + Ui::VisAtom2017Class ui; +}; diff --git a/VisAtom2017/VisAtom2017.aps b/VisAtom2017/VisAtom2017.aps new file mode 100644 index 0000000..aa37894 Binary files /dev/null and b/VisAtom2017/VisAtom2017.aps differ diff --git a/VisAtom2017/VisAtom2017.cpp b/VisAtom2017/VisAtom2017.cpp new file mode 100644 index 0000000..908249d --- /dev/null +++ b/VisAtom2017/VisAtom2017.cpp @@ -0,0 +1,2821 @@ +/* This is a class used for in VisAtom, a visualiztion tool for + atomistic simulations. + + AUTHOR: Qing HOU + INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University + HISTROTY: First version: 1998 + LAST MODIFICATION: 2013 +*/ + +#include "visatom2017.h" +#include +#include +#include +#include "Bitmap.h" +#include "VisAtomDataSheet.h" +#include "VisAtomAboutDlg.h" +#include "VisAtomCliper.h" +#include "VisAtom_NewColorPolicyDlg.h" +#include "VisAtom_NewVectorPolicyDlg.h" +#include "VisAtom_NewSizePolicyDlg.h" +#include "VisAtom_SelectSampleDataDlg.h" +#include "visatom_loadtrajecoryThread.h" +#include "visatom_newdisplacementdlg.h" +#include "visatom_atomfilterdlg.h" +#include "visatom_findatomdlg.h" + +#include "VisClusterEnvelope.h" + + +static int CURRENT_EXTNUM = -1; +static QString CURRENT_FNAME = ""; + +VisAtom2017::VisAtom2017(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + //extending the ui + //fill the type of clipping style + this->m_OnUpdateClipParamUI = 1; + QListWidgetItem *style1 = new QListWidgetItem(ui.scenestylelistWidget); + style1->setIcon(QIcon(":/VisAtom2017/images/scenestyle1.png")); + style1->setText(tr("Clipping-OR")); + style1->setTextAlignment(Qt::AlignHCenter); + style1->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QListWidgetItem *style2 = new QListWidgetItem(ui.scenestylelistWidget); + style2->setIcon(QIcon(":/VisAtom2017/images/scenestyle2.png")); + style2->setText(tr("Clipping-AND")); + style2->setTextAlignment(Qt::AlignHCenter ); + style2->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QListWidgetItem *style3 = new QListWidgetItem(ui.scenestylelistWidget); + style3->setIcon(QIcon(":/VisAtom2017/images/scenestyle3.png")); + style3->setText(tr("Clipping-ANYDIR")); + style3->setTextAlignment(Qt::AlignHCenter ); + style3->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + ui.clipDirComboBox->addItem(tr("plane #1")); + ui.scenestylelistWidget->setCurrentRow(0); + this->m_OnUpdateClipParamUI = 0; + + //file options of display box + QTreeWidgetItem*itemzb = new QTreeWidgetItem(); + itemzb->setText(0, tr("X-Y back")); + itemzb->setText(1, tr("Border")); + itemzb->setText(2, tr("Face")); + itemzb->setCheckState(1, Qt::Checked); + itemzb->setCheckState(2, Qt::Checked); + this->ui.boxDisplayTreeWidget->addTopLevelItem(itemzb); + + QTreeWidgetItem*itemxb = new QTreeWidgetItem(); + itemxb->setText(0, tr("Y-Z back")); + itemxb->setText(1, tr("Border")); + itemxb->setText(2, tr("Face")); + itemxb->setCheckState(1, Qt::Checked); + itemxb->setCheckState(2, Qt::Checked); + this->ui.boxDisplayTreeWidget->addTopLevelItem(itemxb); + + QTreeWidgetItem*itemyb = new QTreeWidgetItem(); + itemyb->setText(0, tr("Z-X back")); + itemyb->setText(1, tr("Border")); + itemyb->setText(2, tr("Face")); + itemyb->setCheckState(1, Qt::Checked); + itemyb->setCheckState(2, Qt::Checked); + this->ui.boxDisplayTreeWidget->addTopLevelItem(itemyb); + + QTreeWidgetItem*itemzf = new QTreeWidgetItem(); + itemzf->setText(0, tr("X-Y front")); + itemzf->setText(1, tr("Border")); + itemzf->setText(2, tr("Face")); + itemzf->setCheckState(1, Qt::Checked); + itemzf->setCheckState(2, Qt::Unchecked); + this->ui.boxDisplayTreeWidget->addTopLevelItem(itemzf); + + QTreeWidgetItem*itemxf = new QTreeWidgetItem(); + itemxf->setText(0, tr("Y-Z front")); + itemxf->setText(1, tr("Border")); + itemxf->setText(2, tr("Face")); + itemxf->setCheckState(1, Qt::Checked); + itemxf->setCheckState(2, Qt::Unchecked); + this->ui.boxDisplayTreeWidget->addTopLevelItem(itemxf); + + QTreeWidgetItem*itemyf = new QTreeWidgetItem(); + itemyf->setText(0, tr("Z-X front")); + itemyf->setText(1, tr("Border")); + itemyf->setText(2, tr("Face")); + itemyf->setCheckState(1, Qt::Checked); + itemyf->setCheckState(2, Qt::Unchecked); + this->ui.boxDisplayTreeWidget->addTopLevelItem(itemyf); + + //fill group information + + //file the scalarwinlabels + #define RGBSIZE 255 + float r, g, b; + QColor color; + + VisAtomVisualizingPolicy::GetColorMappingBar(0, r, g, b); + color.setRgb((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap fillcolor0(60,20); + fillcolor0.fill(color); + ui.scalarwin0Label->setPixmap(fillcolor0); + + VisAtomVisualizingPolicy::GetColorMappingBar(1, r, g, b); + color.setRgb((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap fillcolor1(60,20); + fillcolor1.fill(color); + ui.scalarwin1Label->setPixmap(fillcolor1); + + VisAtomVisualizingPolicy::GetColorMappingBar(2, r, g, b); + color.setRgb((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap fillcolor2(60,20); + fillcolor2.fill(color); + ui.scalarwin2Label->setPixmap(fillcolor2); + + VisAtomVisualizingPolicy::GetColorMappingBar(3, r, g, b); + color.setRgb((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap fillcolor3(60,20); + fillcolor3.fill(color); + ui.scalarwin3Label->setPixmap(fillcolor3); + + VisAtomVisualizingPolicy::GetColorMappingBar(4, r, g, b); + color.setRgb((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap fillcolor4(60,20); + fillcolor4.fill(color); + ui.scalarwin4Label->setPixmap(fillcolor4); + + VisAtomVisualizingPolicy::GetColorMappingBar(5, r, g, b); + color.setRgb((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap fillcolor5(60,20); + fillcolor5.fill(color); + ui.scalarwin5Label->setPixmap(fillcolor5); + + + //Reset the subsample list + QStringList header; + header.append(tr("Contents")); + header.append(tr("Property")); + + ui.subsampleListTreeWidget->setHeaderLabels(header); + + // + m_SampleDataSheet = NULL; + //to attach the trjectory objectg to the dataloader, and start load data + this->m_LoadDataThread = new VisAtom_LoadTrajecoryThread(); + this->m_LoadDataThread->AttachRender(this->ui.displayWidget); + QObject::connect(this->m_LoadDataThread, SIGNAL(OnStartLoadFile(QString&,int,int)), this, SLOT(OnStartLoadTrajectory(QString&,int,int))); + QObject::connect(this->m_LoadDataThread, SIGNAL(OnEndLoadFile(QString&,int,int)), this, SLOT(OnEndLoadTrajectory(QString&,int,int))); + + this->statusBar()->addWidget(&this->m_statulabel); + this->statusBar()->addWidget(&this->m_progressbar); + this->statusBar()->addPermanentWidget(&this->m_subsmaplelabel); + this->m_statulabel.hide(); + this->m_progressbar.hide(); + + + ui.displayoptionDockWidget->hide(); + ui.subsampleSumDockWidget->hide(); + ui.actionShow_subsample_options->setEnabled(false); + ui.actionShow_subsample_browser->setEnabled(false); + ui.actionSubsample_filter->setEnabled(false); + ui.actionFind_atoms->setEnabled(false); + + //ui.actionShow_scene_operation->setChecked(true); + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.boxX0SpinBox->setValue((double)xmin); + this->ui.boxX0SpinBox->setMaximum((double)xmax); + //this->ui.boxX0SpinBox->setSingleStep((double)(xmax-xmin)/20); + + this->ui.boxX1SpinBox->setValue((double)xmax); + this->ui.boxX1SpinBox->setMinimum((double)xmin); + //this->ui.boxX1SpinBox->setSingleStep((double)(xmax-xmin)/20); + + this->ui.boxY0SpinBox->setValue((double)ymin); + this->ui.boxY0SpinBox->setMaximum((double)ymax); + //this->ui.boxY0SpinBox->setSingleStep((double)(ymax-ymin)/20); + + this->ui.boxY1SpinBox->setValue((double)ymax); + this->ui.boxY1SpinBox->setMinimum((double)ymin); + //this->ui.boxY1SpinBox->setSingleStep((double)(ymax-ymin)/20); + + this->ui.boxZ0SpinBox->setValue((double)zmin); + this->ui.boxZ0SpinBox->setMaximum((double)zmax); + //this->ui.boxZ0SpinBox->setSingleStep((double)(zmax-zmin)/20); + + this->ui.boxZ1SpinBox->setValue((double)zmax); + this->ui.boxZ1SpinBox->setMinimum((double)zmin); + //this->ui.boxZ1SpinBox->setSingleStep((double)(zmax-zmin)/20); + + if(this->ui.autoboxpos_checkBox->checkState()) + { + this->ui.boxX0SpinBox->setEnabled(false); + this->ui.boxX1SpinBox->setEnabled(false); + this->ui.boxY0SpinBox->setEnabled(false); + this->ui.boxY1SpinBox->setEnabled(false); + this->ui.boxZ0SpinBox->setEnabled(false); + this->ui.boxZ1SpinBox->setEnabled(false); + } + + //for change visiable atoms + m_Atomfilter = NULL; + m_FindatomDlg = NULL; + + // + CURRENT_FNAME.clear(); + CURRENT_EXTNUM = -1; + +} + +VisAtom2017::~VisAtom2017() +{ + if(m_SampleDataSheet) delete m_SampleDataSheet; m_SampleDataSheet = NULL; + if(m_LoadDataThread) delete m_LoadDataThread; m_LoadDataThread = NULL; + if (m_Atomfilter) delete m_Atomfilter; m_Atomfilter = NULL; +} + +void VisAtom2017::OnAboutVisatom2013() +{ + VisAtomAboutDlg aboutdlg(this); + aboutdlg.exec(); +} +int static extract_numb( char*str, int mxCount, char**strnumb) +{ +/* +! Purpose: to extract number from a string +! Input: STRING a string +! Ouput: COUNT the number of numbers found in the string +! REAL_NUMB the number text founded +! Note: the REAL_NUMBi are character varible. These character number +! could be transformed to real number by DRSTR or RSTRi +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + int i, flag, index1, count; + + count=0; + index1=0; + i = 0; + flag = 0; + do + { + if(str[i] == ' ' || str[i] == ',') + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + index1 = 0; + } + flag = 0; + } + else + { + if((str[i] >= '0' && str[i] <= '9') || str[i] == '-' || str[i] == '+' || str[i] == '.' ) + { + if(flag == 0 ) + { + flag = 1; + count ++; + if(count > mxCount) break; + } + } + else + { + if(flag != 1) flag = 2; + } + } + + if(flag == 1) index1 ++; + + i++; + if(i >= strlen(str) ) + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + } + break; + } + } while(1); + return count; +} + +int static adjustl( char*str) +{ +/* +! Purpose: to skip the space ahead of str +! Input: STR a string +! Ouput: STR the strin with the ahead space eliminited +! REAL_NUMB the number text founded +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + int i; + + do + { + if(str[0] == ' ') + { + for(i=0; im_FindatomDlg) this->m_FindatomDlg->hide(); + + QString fileName = QFileDialog::getOpenFileName(this); + QString ext, snum, dot='.'; + QString currentfname; + int index=-1; + + currentfname = CURRENT_FNAME; + if (!fileName.isEmpty()) + { + this->OpenFile(fileName); + + index = fileName.length()-fileName.lastIndexOf(dot); + ext = fileName.section(dot, -1); + CURRENT_EXTNUM = ext.toInt(); + CURRENT_FNAME = fileName; + CURRENT_FNAME.chop(index); + + if(CURRENT_FNAME.isEmpty()) + { + ui.actionNext->setEnabled(false); + ui.actionPrev->setEnabled(false); + } + else + { + ui.actionNext->setEnabled(true); + ui.actionPrev->setEnabled(true); + if(CURRENT_EXTNUM<=0) ui.actionPrev->setEnabled(false); + } + //if filename changed for trajectory + if(!VisAtom_NewDisplacementPolicyDlg::GetFname().isEmpty()) + { + if(CURRENT_FNAME != VisAtom_NewDisplacementPolicyDlg::GetFname()) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("Filename has been changed for trajectories, reset the trajectory data?")); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + if(msgBox.exec() == QMessageBox::Yes) + { + this->OnResetTrajectoryDataPushButton(); + } + } + } + } + return; +} + +void VisAtom2017::OnFileNext() +{ + if (this->m_FindatomDlg) this->m_FindatomDlg->hide(); + + QString fileName, ext,snum; + QFile file; + + int i,to=2000; + for(i=CURRENT_EXTNUM+1; i<=CURRENT_EXTNUM+to; i++) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + else ext="."; + + snum.setNum(i); + ext.append(snum); + fileName = CURRENT_FNAME; + fileName.append(ext); + file.setFileName(fileName); + if (file.exists()) break; + } + if (i>to) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + + QString msg("Cannot find next file"); + msgBox.setText(msg); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + return; + } + + int col[4]; + VisAtom_SelectSampleDataDlg::GetDataCol(col); + if(col[VisAtomDataSheet::COLPROP_POSX] <0 || + col[VisAtomDataSheet::COLPROP_POSY] <0 || + col[VisAtomDataSheet::COLPROP_POSZ] <0) + this->OpenFile(fileName, true); + else + this->OpenFile(fileName, false); + CURRENT_EXTNUM = i; + if(CURRENT_EXTNUM>0) ui.actionPrev->setEnabled(true); + else ui.actionPrev->setEnabled(false); +} + +void VisAtom2017::OnFilePrev() +{ + if (this->m_FindatomDlg) this->m_FindatomDlg->hide(); + + QString fileName, ext,snum; + QFile file; + + int i,to=2000; + if(CURRENT_EXTNUM <= 0) + { + ui.actionPrev->setEnabled(false); + return; + } + + for(i=CURRENT_EXTNUM-1; i>=0; i--) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + else ext="."; + + snum.setNum(i); + ext.append(snum); + fileName = CURRENT_FNAME; + fileName.append(ext); + file.setFileName(fileName); + if (file.exists()) break; + } + if (i<0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + QString msg("Cannot find previous file"); + msgBox.setText(msg); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + return; + } + + + int col[4]; + VisAtom_SelectSampleDataDlg::GetDataCol(col); + if(col[VisAtomDataSheet::COLPROP_POSX] <0 || + col[VisAtomDataSheet::COLPROP_POSY] <0 || + col[VisAtomDataSheet::COLPROP_POSZ] <0) + this->OpenFile(fileName, true); + else + this->OpenFile(fileName, false); + + CURRENT_EXTNUM = i; + if(CURRENT_EXTNUM>0) ui.actionPrev->setEnabled(true); + else ui.actionPrev->setEnabled(false); + +} + +void VisAtom2017::LoadFrom_BOXCFG14(QString fileName) +{ + QFile file(fileName); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + //to determine how many col for each line + int na, nrow=0, ncol=0, i, j, len; + float bl[3], bs[3]; + + char buf[MAXCOL*MAXSTRL+1]; + char*strnumb[MAXCOL]; + for(i=0; im_progressbar.setMaximum(nrow); + this->m_progressbar.show(); + //Add to data sheet + if(!m_SampleDataSheet) m_SampleDataSheet = new VisAtomDataSheet(ncol, na); + else + { + m_SampleDataSheet->Clear(); + m_SampleDataSheet->SetColRow(std::max(ncol,4), na); + } + m_SampleDataSheet->SetBoxSize(bl[0], bl[0]+bs[0], + bl[1], bl[1]+bs[1], + bl[2], bl[2]+bs[2]); + + file.open(QIODevice::ReadOnly|QIODevice::Text); + int progressstep = 0.1*nrow; + if( progressstep == 0) progressstep = 1; + + int ii = 0; + //skip the header + for(j=0; jm_SampleDataSheet->SetDataForRow(j, strnumb); + ii++; + if(ii%progressstep == 0) m_progressbar.setValue(ii); + } + + m_progressbar.setValue(nrow); + file.close(); + for(i=0; im_progressbar.setMaximum(nrow); + this->m_progressbar.show(); + //Add to data sheet + if(!m_SampleDataSheet) m_SampleDataSheet = new VisAtomDataSheet(ncol, na); + else + { + m_SampleDataSheet->Clear(); + m_SampleDataSheet->SetColRow(std::max(ncol,4), na); + } + m_SampleDataSheet->SetBoxSize(bl[0], bl[0]+bs[0], + bl[1], bl[1]+bs[1], + bl[2], bl[2]+bs[2]); + + file.open(QIODevice::ReadOnly|QIODevice::Text); + int progressstep = 0.1*nrow; + if( progressstep == 0) progressstep = 1; + + int ii = 0; + //skip the header + for(j=0; jm_SampleDataSheet->SetDataForRow(j, strnumb); + ii++; + if(ii%progressstep == 0) m_progressbar.setValue(ii); + } + + m_progressbar.setValue(nrow); + file.close(); + for(i=0; im_progressbar.setMaximum(nrow); + this->m_progressbar.show(); + //Add to data sheet + if(!m_SampleDataSheet) m_SampleDataSheet = new VisAtomDataSheet(ncol, nrow); + else + { + m_SampleDataSheet->Clear(); + m_SampleDataSheet->SetColRow(std::max(ncol,4), nrow); + } + // boxsize is unknown + if(!hasbl && !hasbs) + { + m_SampleDataSheet->SetBoxSize(1.f, -1.f, 1.f, -1.f, 1.f, -1.f); + } + + if(hasbs) + { + if(hasbl) m_SampleDataSheet->SetBoxSize(bl[0], bl[0]+bs[0], bl[1], bl[1]+bs[1], bl[2], bl[2]+bs[2]); + else m_SampleDataSheet->SetBoxSize(-bs[0]*0.5f, bs[0]*0.5f, -bs[1]*0.5f, bs[1]*0.5f, -bs[2]*0.5f, bs[2]*0.5f); + } + + + file.open(QIODevice::ReadOnly|QIODevice::Text); + for(i=0; im_SampleDataSheet->SetDataForRow(i, strnumb); + + if(i%progressstep == 0) m_progressbar.setValue(i); + } + m_progressbar.setValue(nrow); + file.close(); + for(i=0; isetCursor(Qt::WaitCursor); + QString statuText = tr("Load data:"); + statuText.append(fileName); + this->m_statulabel.setText(statuText); + this->m_statulabel.show(); + VisAtomDataSheet*olddata = this->m_SampleDataSheet; + + QFile file(fileName); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + char buf[MAXCOL*MAXSTRL+1]; + + //to determine the format of the file + int hlines = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + //skip empty lines + if(len <= 0) {hlines++; continue;} + + //skip comment lines + int lentrim = -1; + int flag = 0; + for(int i=0; iunsetCursor(); + //Choose the columes for the atom type and position of atoms + if((VisAtom_SelectSampleDataDlg::IsShowAgain() && selcoldlg )) + { + VisAtom_SelectSampleDataDlg dataselDlg(this); + dataselDlg.SetDataSheet(this->m_SampleDataSheet); + if(!dataselDlg.exec() == QDialog::Accepted) + { + this->m_statulabel.hide(); + this->m_progressbar.hide(); + return; + } + } + + int col[4]; + VisAtom_SelectSampleDataDlg::GetDataCol(col); + this->m_SampleDataSheet->SetTypeCol(col[VisAtomDataSheet::COLPROP_TYPE]); + this->m_SampleDataSheet->SetPosxCol(col[VisAtomDataSheet::COLPROP_POSX]); + this->m_SampleDataSheet->SetPosyCol(col[VisAtomDataSheet::COLPROP_POSY]); + this->m_SampleDataSheet->SetPoszCol(col[VisAtomDataSheet::COLPROP_POSZ]); + + //Connect the datasheet to the sample + this->ui.displayWidget->SetSampleDataSheet(this->m_SampleDataSheet,false); + + + //if this is not the first file-open, using the current clipping and color style + if(olddata) + { + if((this->ui.displayWidget->CurrentClipper()->GetStyle() == VisAtomCliper::CLIPPING_STYLE_ANYDIR) && + this->ui.clipthroughAtomRadioButton->isChecked() ) + { + if( this->ui.clipthroughAtomSpinBox->value() <= this->m_SampleDataSheet->GetNumRow()) + this->OnClipthroughAtomSpinBox(this->ui.clipthroughAtomSpinBox->value()); + else + this->ui.clipthroughPosRadioButton->setChecked(true); + } + else + this->OnClipEnabled(); + } + else if(this->ui.displayWidget->CurrentClipper()->GetStyle() == VisAtomCliper::CLIPPING_STYLE_ANYDIR) + { + this->OnClipEnabled(); + } + + this->UpdateSubsampleLIST(); + this->UpdateSubsampleUI(); + this->ui.subsampleSumDockWidget->show(); + this->ui.displayoptionDockWidget->show(); + this->ui.actionShow_subsample_options->setEnabled(true); + this->ui.actionShow_subsample_browser->setEnabled(true); + this->ui.actionSubsample_filter->setEnabled(false); + this->ui.actionFind_atoms->setEnabled(true); + + // update scene box UI + if(this->ui.displayWidget->IfAutoNormalizingView()) + { + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.boxX0SpinBox->setValue((double)xmin); + this->ui.boxX0SpinBox->setMaximum((double)xmax); + //this->ui.boxX0SpinBox->setSingleStep((double)(xmax-xmin)/20); + + this->ui.boxX1SpinBox->setValue((double)xmax); + this->ui.boxX1SpinBox->setMinimum((double)xmin); + //this->ui.boxX1SpinBox->setSingleStep((double)(xmax-xmin)/20); + + this->ui.boxY0SpinBox->setValue((double)ymin); + this->ui.boxY0SpinBox->setMaximum((double)ymax); + //this->ui.boxY0SpinBox->setSingleStep((double)(ymax-ymin)/20); + + this->ui.boxY1SpinBox->setValue((double)ymax); + this->ui.boxY1SpinBox->setMinimum((double)ymin); + //this->ui.boxY1SpinBox->setSingleStep((double)(ymax-ymin)/20); + + this->ui.boxZ0SpinBox->setValue((double)zmin); + this->ui.boxZ0SpinBox->setMaximum((double)zmax); + //this->ui.boxZ0SpinBox->setSingleStep((double)(zmax-zmin)/20); + + this->ui.boxZ1SpinBox->setValue((double)zmax); + this->ui.boxZ1SpinBox->setMinimum((double)zmin); + //this->ui.boxZ1SpinBox->setSingleStep((double)(zmax-zmin)/20); + } + + // + QString title = tr("VisAtom2017 - "); + title.append(fileName); + this->m_statulabel.hide(); + this->m_progressbar.hide(); + this->setWindowTitle(title); + return; +} + + + +void VisAtom2017::OnSaveImage() +{ + QString ext = tr("bmp"); + QString fileName = QFileDialog::getSaveFileName + (this, tr("Save image to bitmap file"), NULL, tr("*.bmp"), &ext); + + if(!fileName.isEmpty()) + { + //QPixmap pixmap; + //ui.displayWidget->RenderToPixmap(pixmap); + //pixmap.save ( fileName, "PNG", 100 ); + Bitmap bitmap; + ui.displayWidget->RenderToBitmap(bitmap); + bitmap.SaveToFile(fileName); + } +} + +void VisAtom2017::OnActionCopyImage() +{ + Bitmap bitmap; + ui.displayWidget->RenderToBitmap(bitmap); + bitmap.SaveToClipBoard(); + return; +} + +void VisAtom2017::OnActionRotateX(bool checked) +{ + //this->ui.rotationXtoolButton->setChecked(true); + this->OnSelectRotationX(); +} +void VisAtom2017::OnActionRotateY(bool checked) +{ + //this->ui.rotationYtoolButton->setChecked(true); + this->OnSelectRotationY(); +} + +void VisAtom2017::OnActionRotateZ(bool checked) +{ + //this->ui.rotationZtoolButton->setChecked(true); + this->OnSelectRotationZ(); +} +void VisAtom2017::OnActionZoomview(bool checked) +{ + //this->ui.zoomScenetoolButton->setChecked(true); + this->OnSelectZoomScene(); +} + + +void VisAtom2017::OnSelectRotationX() +{ + this->ui.actionZoom_view->setChecked(false); + this->ui.actionRotate_X->setChecked(true); + this->ui.actionRotate_Y->setChecked(false); + this->ui.actionRotate_Z->setChecked(false); + + this->ui.actionViewport_center->setChecked(false); + + emit this->SetMouseAction(ui.displayWidget->ACTION_ROTATION_X); +} + +void VisAtom2017::OnSelectRotationY() +{ + this->ui.actionZoom_view->setChecked(false); + this->ui.actionRotate_X->setChecked(false); + this->ui.actionRotate_Y->setChecked(true); + this->ui.actionRotate_Z->setChecked(false); + this->ui.actionViewport_center->setChecked(false); + + + emit this->SetMouseAction(ui.displayWidget->ACTION_ROTATION_Y); +} + +void VisAtom2017::OnSelectRotationZ() +{ + this->ui.actionZoom_view->setChecked(false); + this->ui.actionRotate_X->setChecked(false); + this->ui.actionRotate_Y->setChecked(false); + this->ui.actionRotate_Z->setChecked(true); + this->ui.actionViewport_center->setChecked(false); + + + emit this->SetMouseAction(ui.displayWidget->ACTION_ROTATION_Z); +} + +void VisAtom2017::OnSelectZoomScene() +{ + this->ui.actionZoom_view->setChecked(true); + this->ui.actionRotate_X->setChecked(false); + this->ui.actionRotate_Y->setChecked(false); + this->ui.actionRotate_Z->setChecked(false); + this->ui.actionViewport_center->setChecked(false); + + emit this->SetMouseAction(ui.displayWidget->ACTION_ZOOM_SCENE); +} + +void VisAtom2017::OnActionVeiwportCenter(bool checked) +{ + this->ui.actionZoom_view->setChecked(false); + this->ui.actionRotate_X->setChecked(false); + this->ui.actionRotate_Y->setChecked(false); + this->ui.actionRotate_Z->setChecked(false); + this->ui.actionViewport_center->setChecked(true); + + emit this->SetMouseAction(ui.displayWidget->ACTION_VIEWPORT_CENTER); +} + +void VisAtom2017::OnChangeSceneDistance() +{ + int range = ui.distanceSlider->maximum() - ui.distanceSlider->minimum()+1; + emit this->SetSceneDistance(range,ui.distanceSlider->value()); +} + +void VisAtom2017::OnChangeAtomRadiu() +{ + if(m_OnUpdateSubsampleUI) return; + this->OnMultipleSelectSubsample(); + + int range = ui.atomsizeSlider->maximum() - ui.atomsizeSlider->minimum()+1; + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + emit this->SetAtomRadiu(range,ui.atomsizeSlider->value(), all); + +} + +int VisAtom2017::OnEditSizeDataButton() +{ + if(m_OnUpdateSubsampleUI) return 0; + this->OnMultipleSelectSubsample(); + + + VisAtom_NewSizePolicyDlg sizeDlg(this); + sizeDlg.SetDataSheet(this->m_SampleDataSheet); + + if(sizeDlg.exec() == QDialog::Accepted) + { + int col; + float min, max; + sizeDlg.GetData(col, min, max); + //if data not changed, just return + if(col == VisAtomVisualizingPolicy::GetAtomSizeCol() ) return 1; + + VisAtomVisualizingPolicy::SetAtomSizeCol(col); + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + emit this->SetVariableAtomRadiu(true, all); + return 1; + } + + return 0; +} + +void VisAtom2017::OnVariableAtomSize(bool checked) +{ + if(m_OnUpdateSubsampleUI) return; + this->OnMultipleSelectSubsample(); + + VisAtomSubSample*sub=ui.displayWidget->GetSample()->GetCurrentSubsample(); + if(checked) + { //if alread in vairaiable size policy, return; + if(!sub->IsCurAtomHaveUnifiedSize())return; + //if no size data available, select the data + if(VisAtomVisualizingPolicy::GetAtomSizeCol() < 0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("No scalar data available for variable radia, set the scalar data?")); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + if(msgBox.exec() == QMessageBox::No) + { + ui.atomsizeSlider->setEnabled(true); + ui.atomunitsizeRadioButton->setChecked(true); + ui.atomvairablesizeRadioButton->setChecked(false); + ui.atomsizedataButton->setEnabled(false); + return; + } + + VisAtom_NewSizePolicyDlg sizeDlg(this); + sizeDlg.SetDataSheet(this->m_SampleDataSheet); + if(sizeDlg.exec() == QDialog::Accepted) + { + int col; + float min, max; + sizeDlg.GetData(col, min, max); + VisAtomVisualizingPolicy::SetAtomSizeCol(col); + } + else + { + ui.atomsizeSlider->setEnabled(true); + ui.atomunitsizeRadioButton->setChecked(true); + ui.atomvairablesizeRadioButton->setChecked(false); + ui.atomsizedataButton->setEnabled(false); + return; + } + } + + ui.atomsizeSlider->setEnabled(false); + ui.atomunitsizeRadioButton->setChecked(false); + ui.atomsizedataButton->setEnabled(true); + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + emit this->SetVariableAtomRadiu(true, all); + } + +} +void VisAtom2017::OnUnifiedAtomSize(bool checked) +{ + VisAtomSubSample*sub=ui.displayWidget->GetSample()->GetCurrentSubsample(); + if(checked && sub->IsCurAtomHaveUnifiedSize()) return; + + ui.atomsizeSlider->setEnabled(true); + ui.atomsizedataButton->setEnabled(false); + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + emit this->SetVariableAtomRadiu(false, all); +} + + +void VisAtom2017::OnChangeAtomShapeDot(bool checked) +{ + if(!checked) return; + if(m_OnUpdateSubsampleUI) return; + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + this->OnMultipleSelectSubsample(); + emit this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_DOT, all); +} +void VisAtom2017::OnChangeAtomShapeCircle(bool checked) +{ + if(!checked) return; + if(m_OnUpdateSubsampleUI) return; + + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + this->OnMultipleSelectSubsample(); + emit this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_LINE, all); +} +void VisAtom2017::OnChangeAtomShapeWireSphere(bool checked) +{ + if(!checked) return; + if(m_OnUpdateSubsampleUI) return; + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + this->OnMultipleSelectSubsample(); + emit SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE, all); +} +void VisAtom2017::OnChangeAtomShapeSolidSphere(bool checked) +{ + if(!checked) return; + if(m_OnUpdateSubsampleUI) return; + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + this->OnMultipleSelectSubsample(); + emit SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_SOLID, all); +} + +//************************************************************************************************** +void VisAtom2017::OnChangeGraphQuality(int nfai) +{ + if(m_OnUpdateSubsampleUI) return; + this->OnMultipleSelectSubsample(); + emit ChangeGraphQuality(nfai); + return; +} + + +void VisAtom2017::OnChangeAtomColor() +{ + int i; + + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + VisAtomSubSample*subsample; + VisAtomVisualizingPolicy*policy; + + subsample = sample->GetCurrentSubsample(); + policy = subsample->GetCurVisualPolicy(); + + //Update color UI + float r, g, b, a; + #define RGBSIZE 255 + policy->GetColor(r, g, b,a ); + QColor color((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QColorDialog colorsel(color, this); + + if(colorsel.exec()) + { + int R, G, B, A; + color = colorsel.currentColor(); + color.getRgb(&R, &G, &B, &A); + this->OnMultipleSelectSubsample(); + + /*VisAtomSubSample*p = sample->GetCurrentSubsample(); + p->SetColor(R/float(RGBSIZE), G/float(RGBSIZE), B/float(RGBSIZE), 1.f, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + p->SetColor(R/float(RGBSIZE), G/float(RGBSIZE), B/float(RGBSIZE), 1.f, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + sample->LoadCurSubsampleProp();*/ + for(int i=0; iNumberofSubsample(); i++) + { + if(sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*p = sample->GetSubsample(i); + p->SetColor(R/float(RGBSIZE), G/float(RGBSIZE), B/float(RGBSIZE), 1.f, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + p->SetColor(R/float(RGBSIZE), G/float(RGBSIZE), B/float(RGBSIZE), 1.f, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + sample->LoadSubsampleProp(i); + } + } + + QPixmap colicon(QSize(32,16)); + colicon.fill(color); + ui.changeatomColorButton->setIcon(colicon); + ui.displayWidget->updateGL(); + } +} + +void VisAtom2017::OnSelectSceneStyle(QListWidgetItem*current,QListWidgetItem*previous) +{ + if(!current) + current = previous; + + int row = this->ui.scenestylelistWidget->row(current); + + this->ui.scenestylestackedWidget->setCurrentIndex(row); + this->ui.displayWidget->SetCurrentClipperStyle(row, false); + this->OnClipEnabled(); + return; +} + + +void VisAtom2017:: OnClipEnabled() +{ + if (this->m_OnUpdateClipParamUI) return; + VisAtomCliper clip; + clip.SetParameters(ui.displayWidget->CurrentClipper()); + this->GetClipParamFromUI(&clip); + this->ui.displayWidget->SetCurrentCliperParameters(&clip); + return; +} + +void VisAtom2017::OnNewClipDirPushButton() +{ + VisAtomCliper*clip0 = this->ui.displayWidget->CurrentClipper(); + VisAtomCliper*clip = this->ui.displayWidget->NewCliper(); + if (!clip) return; + clip->SetParameters(clip0); + + int i = ui.clipDirComboBox->count(); + QString sname, sindex; + sindex.setNum(i+1); + sname.clear(); + sname.append(tr("Plane #")); + sname.append(sindex); + ui.clipDirComboBox->addItem(sname); + ui.clipDirComboBox->setCurrentIndex(i); +} +void VisAtom2017::OnClipDirComboBoxIndexChanged(int index) +{ + if (this->m_OnUpdateClipParamUI) return; + + VisAtomCliper*clip = ui.displayWidget->SetCurrentClipper(index); + + this->m_OnUpdateClipParamUI = 1; + double axsis[3], pos[3]; + clip->GetClipAxsis(axsis); + this->ui.clipDirXSpinBox->setValue(axsis[0]); + this->ui.clipDirYSpinBox->setValue(axsis[1]); + this->ui.clipDirZSpinBox->setValue(axsis[2]); + + this->ui.clipAnyDirEnablecheckBox->setChecked(clip->IsEnabledClip()); + this->ui.scenestyleDClipDCheckBox->setChecked(clip->IsEnabledDClip()); + + clip->GetClipPos(pos); + this->ui.clipPosXSpinBox->setValue(pos[0]); + this->ui.clipPosYSpinBox->setValue(pos[1]); + this->ui.clipPosZSpinBox->setValue(pos[2]); + + double thick; + thick = clip->GetClipThickness(); + this->ui.clipstepDSpinBox->setValue(thick); + + this->ui.clipDFrontfaceShowCheckBox->setChecked(clip->IsShowFronFace()); + this->ui.clipDBackfaceShowCheckBox->setChecked(clip->IsShowBackFace()); + + double opacity = clip->GetFaceOpacity()*(double)(this->ui.clipOpacitySlider->maximum() - this->ui.clipOpacitySlider->minimum() + 1); + this->ui.clipOpacitySlider->setValue((int)opacity); + + this->m_OnUpdateClipParamUI = 0; + +} + +void VisAtom2017::OnClipDirCheckBoxChanged(bool enable) +{ + VisAtomCliper*clip = ui.displayWidget->CurrentClipper(); + clip->EnableClip(enable); + this->ui.displayWidget->SetCurrentCliperParameters(clip); +} + +void VisAtom2017::GetClipParamFromUI(VisAtomCliper*clip) +{ + int proppage = this->ui.scenestylestackedWidget->currentIndex(); + + if(proppage == 0) + { + clip->SetStyle(this->ui.scenestylelistWidget->currentRow()); + clip->EnableClipX(this->ui.scenestyleClipXGroupBox->isChecked()); + clip->EnableClipY(this->ui.scenestyleClipYGroupBox->isChecked()); + clip->EnableClipZ(this->ui.scenestyleClipZGroupBox->isChecked()); + + clip->EnableDClipX(this->ui.scenestyleDClipXCheckBox->isChecked()); + clip->EnableDClipY(this->ui.scenestyleDClipYCheckBox->isChecked()); + clip->EnableDClipZ(this->ui.scenestyleDClipZCheckBox->isChecked()); + + clip->SetInverseClipX(this->ui.scenestyleclipInvXCheckBox->isChecked()); + clip->SetInverseClipY(this->ui.scenestyleclipInvYCheckBox->isChecked()); + clip->SetInverseClipZ(this->ui.scenestyleclipInvZCheckBox->isChecked()); + + double step[3]; + step[0] = (double)this->ui.clipstepXSpinBox->value(); ///(double)this->ui.clipstepXSpinBox->maximum(); + step[1] = (double)this->ui.clipstepYSpinBox->value(); ///(double)this->ui.clipstepYSpinBox->maximum(); + step[2] = (double)this->ui.clipstepZSpinBox->value(); ///(double)this->ui.clipstepZSpinBox->maximum(); + clip->SetClipStep(step); + } + + else if(proppage == 1) + { + clip->SetStyle(this->ui.scenestylelistWidget->currentRow()); + clip->EnableClipX(this->ui.scenestyleClipXGroupBox1->isChecked()); + clip->EnableClipY(this->ui.scenestyleClipYGroupBox1->isChecked()); + clip->EnableClipZ(this->ui.scenestyleClipZGroupBox1->isChecked()); + + clip->EnableDClipX(this->ui.scenestyleDClipXCheckBox1->isChecked()); + clip->EnableDClipY(this->ui.scenestyleDClipYCheckBox1->isChecked()); + clip->EnableDClipZ(this->ui.scenestyleDClipZCheckBox1->isChecked()); + + clip->SetInverseClipX(this->ui.scenestyleclipInvXCheckBox1->isChecked()); + clip->SetInverseClipY(this->ui.scenestyleclipInvYCheckBox1->isChecked()); + clip->SetInverseClipZ(this->ui.scenestyleclipInvZCheckBox1->isChecked()); + + double step[3]; + step[0] = (double)this->ui.clipstepXSpinBox1->value(); ///(double)this->ui.clipstepXSpinBox1->maximum(); + step[1] = (double)this->ui.clipstepYSpinBox1->value(); ///(double)this->ui.clipstepYSpinBox1->maximum(); + step[2] = (double)this->ui.clipstepZSpinBox1->value(); ///(double)this->ui.clipstepZSpinBox1->maximum(); + clip->SetClipStep(step); + } + + else if(proppage == 2) + { + clip->SetStyle(this->ui.scenestylelistWidget->currentRow()); + + double axsis[3], pos[3]; + axsis[0] = (double)this->ui.clipDirXSpinBox->value(); + axsis[1] = (double)this->ui.clipDirYSpinBox->value(); + axsis[2] = (double)this->ui.clipDirZSpinBox->value(); + clip->SetClipAxsis(axsis); + clip->EnableClip(this->ui.clipAnyDirEnablecheckBox->isChecked()); + clip->EnableDClip(this->ui.scenestyleDClipDCheckBox->isChecked()); + + pos[0] = (double)this->ui.clipPosXSpinBox->value(); /*/ + (double)(this->ui.clipPosXSpinBox->maximum() - this->ui.clipPosXSpinBox->minimum());*/ + pos[1] = (double)this->ui.clipPosYSpinBox->value(); /*/ + (double)(this->ui.clipPosYSpinBox->maximum() - this->ui.clipPosYSpinBox->minimum());*/ + pos[2] = (double)this->ui.clipPosZSpinBox->value(); /*/ + (double)(this->ui.clipPosZSpinBox->maximum() - this->ui.clipPosZSpinBox->minimum());*/ + + clip->SetClipPos(pos); + + double step[3]; + step[0] = step[1] = step[2] =this->ui.clipstepDSpinBox->value(); + // (double)(this->ui.clipstepDSpinBox->value())/(double)this->ui.clipstepXSpinBox1->maximum(); + clip->SetClipStep(step); + + double opacity; + opacity = (double)this->ui.clipOpacitySlider->value()/ + (double)(this->ui.clipOpacitySlider->maximum() - this->ui.clipOpacitySlider->minimum()+1); + clip->SetFaceOpacity(opacity); + + } +} + +//******************************************************************************** +void VisAtom2017::UpdateSubsampleUI() +{ + //on update UI, we do not need to reddraw the scene + m_OnUpdateSubsampleUI = 1; + + //to update ui + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + VisAtomSubSample*subsample; + VisAtomVisualizingPolicy*policy; + + subsample = sample->GetCurrentSubsample(); + policy = subsample->GetCurVisualPolicy(); + + //atom UI + int geomstyle = policy->GetAtomShapeStyle(); + switch(geomstyle&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK) + { + case VisAtomVisualizingPolicy::SHAPE_STYLE_DOT: + this->ui.dotRadioButton->setChecked(true); + break; + case VisAtomVisualizingPolicy::SHAPE_STYLE_LINE: + this->ui.circleRadioButton->setChecked(true); + break; + case VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE: + this->ui.wireRadioButton->setChecked(true); + break; + case VisAtomVisualizingPolicy::SHAPE_STYLE_SOLID: + this->ui.sphereRadioButton->setChecked(true); + break; + } + this->ui.shapeoptionGroupBox->setChecked(policy->IsGeomStyleAtomVisible()); + + //vector style + geomstyle = policy->GetVectorStyle(); + switch(geomstyle&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK) + { + case VisAtomVisualizingPolicy::VECTOR_STYLE_LINE: + this->ui.vectorlineRadioButton->setChecked(true); + break; + case VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID: + this->ui.vectorcylinderRadioButton->setChecked(true); + break; + } + this->ui.vectoroptionGroupBox->setChecked(policy->IsGeomStyleVectorVisible()); + + //trajectory style + geomstyle = policy->GetTrajectoryStyle(); + this->ui.trajectoryOptionGroupBox->setChecked(policy->IsGeomStyleTrajectoryVisible()); + this->ui.trjaectoryThickSpinBox->setValue(policy->GetTrajectoryLinethick()); + // + + //Update size UI + float x0, x1, y0, y1, z0, z1,ds; + sample->GetSampleBoxRangeX(x0, x1); + sample->GetSampleBoxRangeX(y0, y1); + sample->GetSampleBoxRangeX(z0, z1); + + ds = x1 - x0; + if(ds > y1-y0) ds = y1 - y0; + if(ds > z1-z0) ds = z1 - z0; + ds = (ds/4.0); + + float rad = policy->GetAtomSize(); + double ratio = rad/ds; + double range = ui.atomsizeSlider->maximum() - ui.atomsizeSlider->minimum() + 1; + ui.atomsizeSlider->setValue((int)(ratio*range)); + + if(policy->IsAtomHaveUnifiedSize()) + { + ui.atomunitsizeRadioButton->setChecked(true); + ui.atomsizeSlider->setEnabled(true); + ui.atomsizedataButton->setEnabled(false); + } + else + { + ui.atomvairablesizeRadioButton->setChecked(true); + ui.atomsizedataButton->setEnabled(true); + ui.atomsizeSlider->setEnabled(false); + } + + //Update color UI + if(policy->GetColorStyle() == VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE) + { + float r, g, b, a; + #define RGBSIZE 255 + policy->GetColor(r, g, b,a ); + QColor color((int)(r*RGBSIZE), (int)(g*RGBSIZE), (int)(b*RGBSIZE)); + QPixmap colicon(QSize(32,16)); + colicon.fill(color); + ui.changeatomColorButton->setIcon(colicon); + ui.changeatomColorButton->setEnabled(true); + ui.singlecolorRadioButton->setChecked(true); + ui.colorstyleStackedWidget->setCurrentIndex(0); + } + else if(policy->GetColorStyle() == VisAtomVisualizingPolicy::COLOR_STYLE_MAP) + { + ui.mappingcolorRadioButton->setChecked(true); + ui.colorstyleStackedWidget->setCurrentIndex(1); + } + + // + QString title(subsample->GetName()); + title.append(tr(" options")); + ui.displayoptionDockWidget->setWindowTitle(title); + + // + m_OnUpdateSubsampleUI = 0; + + return; +} + +//******************************************************************************** +void VisAtom2017::UpdateSubsampleLIST() +{ + //Update the subsample list + this->ui.subsampleListTreeWidget->clear(); + + QString sname, sindex; + int i,gstyle; + QTreeWidgetItem*item0 = NULL; + for (i = 0; i < this->ui.displayWidget->GetSample()->NumberofSubsample(); i++) + { + VisAtomSubSample*subp = this->ui.displayWidget->GetSample()->GetSubsample(i); + sname = subp->GetName(); + if (sname.isEmpty()) + { + sindex.setNum(i + 1); + sname.clear(); + sname.append(tr("Subsample")); + sname.append(sindex); + subp->SetName(sname); + } + QTreeWidgetItem*item = new QTreeWidgetItem(); if (!item0) item0 = item; + item->setText(0, sname); + item->setText(1, tr("Visible")); + if (subp->IsVisible()) + item->setCheckState(1, Qt::Checked); + else + item->setCheckState(1, Qt::Unchecked); + //fill group information + QTreeWidgetItem*typeitem = new QTreeWidgetItem(); + typeitem->setText(0, tr("Atom type")); + int j; + sname.clear(); + sname.append(tr("type")); + for (j = 0; j < subp->GetNumberofGroup(); j++) + { + //QTreeWidgetItem*aTypeitem = new QTreeWidgetItem(); + sindex.setNum(subp->GetGroupID(j)); + sname.append(tr(" #")); + sname.append(sindex); + //aTypeitem->setText(0, sname); + //typeitem->addChild(aTypeitem); + //typeitem->setText(0, tr("Atom")); + } + typeitem->setText(1, sname); + + item->addChild(typeitem); + + //fill number of atom + QTreeWidgetItem*numatomitem = new QTreeWidgetItem(); + numatomitem->setText(0, QString(tr("Number of atoms"))); + int num = subp->GetNumberofAtoms(); + QString snum; + snum.setNum(num); + numatomitem->setText(1, snum); + item->addChild(numatomitem); + + //fill 3D diaplay information + QTreeWidgetItem*D3item = new QTreeWidgetItem(); + D3item->setText(0, tr("3D")); + if (subp->GetCurVisualPolicy()->IsGeomStyle3DVisible()) + { + D3item->setCheckState(1, Qt::Checked); + } + else + { + D3item->setCheckState(1, Qt::Unchecked); + } + item->addChild(D3item); + + /*if (subp->GetNumberofRegions() <= 0) + { + regionitem->setCheckState(1, Qt::Checked); + regionitem->setText(1, tr("Visible for all")); + } + else + for(int j=0; jGetNumberofRegions(); j++) + { + }*/ + + //fill scalar range information + QTreeWidgetItem*datarangeitem = new QTreeWidgetItem(); + datarangeitem->setText(0, tr("Data range")); + if (subp->GetNumberofScalarRegions() <= 0) + datarangeitem->setText(1, tr("No constraint")); + /*else + for(int j=0; jGetNumberofScalarRegions(); j++) + { + }*/ + + //item->addChild(datarangeitem); + + + //fill projection visibility + QTreeWidgetItem*projectionitem = new QTreeWidgetItem(); + projectionitem->setText(0, QString(tr("Projection"))); + if(subp->GetCurVisualPolicy()->IsGeomStyleProjectionVisible()) + projectionitem->setCheckState(1,Qt::Checked); + else + projectionitem->setCheckState(1,Qt::Unchecked); + + gstyle = subp->GetCurVisualPolicy()->GetProjectionStyle(); + item->addChild(projectionitem); + + QTreeWidgetItem*pX0item = new QTreeWidgetItem(); + pX0item->setText(0, QString(tr("X0-face"))); + pX0item->setText(1, QString(tr("Visible"))); + if(gstyle&VisAtomVisualizingPolicy::PROJECTION_STYLE_X0) + pX0item->setCheckState(1,Qt::Checked); + else + pX0item->setCheckState(1,Qt::Unchecked); + projectionitem->addChild(pX0item); + + QTreeWidgetItem*pX1item = new QTreeWidgetItem(); + pX1item->setText(0, QString(tr("X1-face"))); + pX1item->setText(1, QString(tr("Visible"))); + if(gstyle&VisAtomVisualizingPolicy::PROJECTION_STYLE_X1) + pX1item->setCheckState(1,Qt::Checked); + else + pX1item->setCheckState(1,Qt::Unchecked); + projectionitem->addChild(pX1item); + + QTreeWidgetItem*pY0item = new QTreeWidgetItem(); + pY0item->setText(0, QString(tr("Y0-face"))); + pY0item->setText(1, QString(tr("Visible"))); + if(gstyle&VisAtomVisualizingPolicy::PROJECTION_STYLE_Y0) + pY0item->setCheckState(1,Qt::Checked); + else + pY0item->setCheckState(1,Qt::Unchecked); + projectionitem->addChild(pY0item); + + QTreeWidgetItem*pY1item = new QTreeWidgetItem(); + pY1item->setText(0, QString(tr("Y1-face"))); + pY1item->setText(1, QString(tr("Visible"))); + if(gstyle&VisAtomVisualizingPolicy::PROJECTION_STYLE_Y1) + pY1item->setCheckState(1,Qt::Checked); + else + pY1item->setCheckState(1,Qt::Unchecked); + projectionitem->addChild(pY1item); + + QTreeWidgetItem*pZ0item = new QTreeWidgetItem(); + pZ0item->setText(0, QString(tr("Z0-face"))); + pZ0item->setText(1, QString(tr("Visible"))); + if(gstyle&VisAtomVisualizingPolicy::PROJECTION_STYLE_Z0) + pZ0item->setCheckState(1,Qt::Checked); + else + pZ0item->setCheckState(1,Qt::Unchecked); + projectionitem->addChild(pZ0item); + + QTreeWidgetItem*pZ1item = new QTreeWidgetItem(); + pZ1item->setText(0, QString(tr("Z1-face"))); + pZ1item->setText(1, QString(tr("Visible"))); + if(gstyle&VisAtomVisualizingPolicy::PROJECTION_STYLE_Z1) + pZ1item->setCheckState(1,Qt::Checked); + else + pZ1item->setCheckState(1,Qt::Unchecked); + projectionitem->addChild(pZ1item); + + + this->ui.subsampleListTreeWidget->addTopLevelItem(item); + } + this->ui.subsampleListTreeWidget->expandToDepth(0); + this->ui.subsampleListTreeWidget->setCurrentItem(item0); + //end of updating subsample list + return; +} + +//******************************************************************************** +void VisAtom2017::OnSubsampleListItemChanged(QTreeWidgetItem*item) +{ + if(!item) return; + +/* QString name; + + if(!item->parent()) + { + name = item->text(0); + + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + VisAtomSubSample*subsample = sample->GetSubsample(name); + subsample->SetVisible(checked); + sample->ResetVisibility(); + ui.displayWidget->updateGL(); + }*/ + + QString tname1, tname2; + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + QTreeWidgetItem*item0 = NULL; + QTreeWidgetItem*item1 = NULL; + QTreeWidgetItem*item2 = NULL; + + int i, j, k; + bool checked, checked1, checked2; + for(i=0; iNumberofSubsample(); i++) + { + VisAtomSubSample*subp = sample->GetSubsample(i); + item0 = this->ui.subsampleListTreeWidget->topLevelItem(i); + checked = item0->checkState(1); + subp->SetVisible(checked); + + //check the projection item + for(j=0; jchildCount(); j++) + { + item1 = item0->child(j); + tname1 = item1->text(0); + //check projection state + if(tname1 == QString(tr("Projection"))) + { + checked1 = item1->checkState(1); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleProjectionVisible(checked1); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleProjectionVisible(checked1); + int pstyle =0; + for(k=0; kchildCount(); k++) + { + item2 = item1->child(k); + tname2 = item2->text(0); + checked2 = item2->checkState(1); + if(tname2 == QString(tr("X0-face")) ) + if(checked2) pstyle = pstyle|VisAtomVisualizingPolicy::PROJECTION_STYLE_X0; + if(tname2 == QString(tr("X1-face")) ) + if(checked2) pstyle = pstyle|VisAtomVisualizingPolicy::PROJECTION_STYLE_X1; + if(tname2 == QString(tr("Y0-face")) ) + if(checked2) pstyle = pstyle|VisAtomVisualizingPolicy::PROJECTION_STYLE_Y0; + if(tname2 == QString(tr("Y1-face")) ) + if(checked2) pstyle = pstyle|VisAtomVisualizingPolicy::PROJECTION_STYLE_Y1; + if(tname2 == QString(tr("Z0-face")) ) + if(checked2) pstyle = pstyle|VisAtomVisualizingPolicy::PROJECTION_STYLE_Z0; + if(tname2 == QString(tr("Z1-face")) ) + if(checked2) pstyle = pstyle|VisAtomVisualizingPolicy::PROJECTION_STYLE_Z1; + } + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetProjectionStyle(pstyle); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetProjectionStyle(pstyle); + sample->LoadSubsampleProp(i); + } + else if(tname1 == QString(tr("3D")) ) + { + checked1 = item1->checkState(1); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyle3DVisible(checked1); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyle3DVisible(checked1); + + int pstyle = 0; + pstyle = pstyle | VisAtomVisualizingPolicy::D3_STYLE_INBOX; + pstyle = pstyle | VisAtomVisualizingPolicy::D3_STYLE_OUTBOX; + //subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->Set3DStyle(pstyle); + //subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->Set3DStyle(pstyle); + sample->LoadSubsampleProp(i); + } + } + } + sample->ResetVisibility(); + this->ui.displayWidget->updateGL(); + return; + + return; +} + + +//******************************************************************************** +void VisAtom2017::OnSubsampleListTreeItemDBClick(QTreeWidgetItem*item, int ind) +{ + if (!item) return; + + QString tname1, tname2; + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + QTreeWidgetItem*item0 = NULL; + QTreeWidgetItem*item1 = NULL; + QTreeWidgetItem*item2 = NULL; + + int i, j, k; + bool checked, checked1, checked2; + //to check which item has been double clicked + for (i = 0; iNumberofSubsample(); i++) + { + VisAtomSubSample*subp = sample->GetSubsample(i); + item0 = this->ui.subsampleListTreeWidget->topLevelItem(i); + checked = item0->checkState(1); + subp->SetVisible(checked); + + //check the projection item + if(checked) + { + for (j = 0; j < item0->childCount(); j++) + { + item1 = item0->child(j); + tname1 = item1->text(0); + //check projection state + if(tname1 == QString(tr("Region")) && item1==item) + { + + int num = subp->GetNumberofRegions(); + QString sname, sindex; + QTreeWidgetItem*regionitem = new QTreeWidgetItem; + item1->addChild(regionitem); + sindex.setNum(num + 1); + sname.append(tr("#")); + sname.append(sindex); + regionitem->setText(0,sname); + } + + } + } + } + sample->ResetVisibility(); + this->ui.displayWidget->updateGL(); + + return; +} +//******************************************************************************** +void VisAtom2017::OnSelectSubsample(QTreeWidgetItem*item) +{ + if(!item) return; + + QString subname, curname; + QTreeWidgetItem*present= item; + QTreeWidgetItem*parent = present->parent(); + + while(parent) + { + present = parent; + parent = present->parent(); + } + + subname = present->text(0); + curname = subname; + //to update ui + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + sample->SetCurrentSubsample(subname); + + subname = "Ed:"; + subname.append(curname); + this->m_subsmaplelabel.setText(subname); + this->UpdateSubsampleUI(); + + return; +} + +//******************************************************************************** +void VisAtom2017::OnMultipleSelectSubsample() +{ + //if multiple selection enabled we need to update the list of selected subsample + QString subname; + QTreeWidgetItem*present; + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + int ns = sample->NumberofSubsample(); + int i; + for(i=0; iui.subsampleListTreeWidget->topLevelItem (i); + subname = present->text(0); + if(present->isSelected()) + sample->SetSelSubsample(subname); + else + sample->SetUnselSubsample(subname); + } + return; +} + +//******************************************************************************** +void VisAtom2017::OnSingleColorRadioButton(bool checked) +{ + if(checked) + { + ui.colorstyleStackedWidget->setCurrentIndex(0); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + VisAtomSubSample*subsample = sample->GetCurrentSubsample(); + subsample->SetCurVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sample->LoadCurSubsampleProp(); + ui.displayWidget->updateGL(); + this->UpdateSubsampleUI(); + } +} + +//******************************************************************************** +void VisAtom2017::OnMappingColorRadioButton(bool checked) +{ + if(checked) + { + ui.colorstyleStackedWidget->setCurrentIndex(1); + if(VisAtomVisualizingPolicy::GetScalarCol() < 0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("No scalar data available, set the scalar data?")); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + if(msgBox.exec() == QMessageBox::Yes) + { + VisAtom_NewColorPolicyDlg newcolorDlg(this); + + newcolorDlg.SetDataSheet(this->m_SampleDataSheet); + newcolorDlg.SetSample(ui.displayWidget->GetSample()); + if(newcolorDlg.exec() == QDialog::Accepted) + { + int col; + float dmin, dmax; + newcolorDlg.GetData(col, dmin, dmax); + if(col < 0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr("No scalar data selected.")); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + ui.singlecolorRadioButton->setChecked(true); + return; + } + VisAtomVisualizingPolicy::SetScalarCol(col); + VisAtomVisualizingPolicy::SetScalarRange(dmin, dmax); + VisAtomVisualizingPolicy::SetScalarMappingTab(dmin, dmax); + QString snum; + snum.setNum(dmin, 'e', 2); + ui.scalarminLabel->setText(snum); + snum.setNum(dmax, 'e', 2); + ui.scalarmaxLabel->setText(snum); + + dmin = -1.5*abs(dmin); + dmax = 1.5*abs(dmax); + ui.scalarwin0SpinBox->setMinimum(dmin); + ui.scalarwin0SpinBox->setMaximum(dmax); + ui.scalarwin0SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin0SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(0)); + + ui.scalarwin1SpinBox->setMinimum(dmin); + ui.scalarwin1SpinBox->setMaximum(dmax); + ui.scalarwin1SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin1SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(1)); + + ui.scalarwin2SpinBox->setMinimum(dmin); + ui.scalarwin2SpinBox->setMaximum(dmax); + ui.scalarwin2SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin2SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(2)); + + ui.scalarwin3SpinBox->setMinimum(dmin); + ui.scalarwin3SpinBox->setMaximum(dmax); + ui.scalarwin3SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin3SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(3)); + + ui.scalarwin4SpinBox->setMinimum(dmin); + ui.scalarwin4SpinBox->setMaximum(dmax); + ui.scalarwin4SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin4SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(4)); + + ui.scalarwin5SpinBox->setMinimum(dmin); + ui.scalarwin5SpinBox->setMaximum(dmax); + ui.scalarwin5SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin5SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(5)); + } + else + { + ui.singlecolorRadioButton->setChecked(true); + return; + } + } + //still having no scalar table + if(VisAtomVisualizingPolicy::GetScalarCol() < 0) + { + ui.singlecolorRadioButton->setChecked(true); + return; + } + } + + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + VisAtomSubSample*subsample = sample->GetCurrentSubsample(); + int style = subsample->GetCurVisualPolicy()->GetGeomStyle(); + style = style&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + style = style|VisAtomVisualizingPolicy::COLOR_STYLE_MAP; + subsample->SetCurVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + sample->LoadCurSubsampleProp(); + ui.displayWidget->updateGL(); + this->UpdateSubsampleUI(); + } +} + + +//******************************************************************************** +void VisAtom2017::OnNewColorPolicy() +{ + VisAtom_NewColorPolicyDlg newcolorDlg(this); + + newcolorDlg.SetDataSheet(this->m_SampleDataSheet); + newcolorDlg.SetSample(ui.displayWidget->GetSample()); + if(newcolorDlg.exec() == QDialog::Accepted) + { + int col; + float dmin, dmax; + newcolorDlg.GetData(col, dmin, dmax); + //if(col == VisAtomVisualizingPolicy::GetScalarCol()) return; + + if(col < 0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr("No scalar data selected. Present scalar data to be used.")); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + return; + } + + if(dmin == dmax) dmax = dmin+1; + VisAtomVisualizingPolicy::SetScalarCol(col); + VisAtomVisualizingPolicy::SetScalarRange(dmin, dmax); + VisAtomVisualizingPolicy::SetScalarMappingTab(dmin, dmax); + + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + + QString snum; + snum.setNum(dmin, 'e', 4); + ui.scalarminLabel->setText(snum); + snum.setNum(dmax, 'e', 4); + ui.scalarmaxLabel->setText(snum); + + dmin = -1.5*abs(dmin); + dmax = 1.5*abs(dmax); + ui.scalarwin0SpinBox->setMinimum(dmin); + ui.scalarwin0SpinBox->setMaximum(dmax); + ui.scalarwin0SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin0SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(0)); + + ui.scalarwin1SpinBox->setMinimum(dmin); + ui.scalarwin1SpinBox->setMaximum(dmax); + ui.scalarwin1SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin1SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(1)); + + ui.scalarwin2SpinBox->setMinimum(dmin); + ui.scalarwin2SpinBox->setMaximum(dmax); + ui.scalarwin2SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin2SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(2)); + + ui.scalarwin3SpinBox->setMinimum(dmin); + ui.scalarwin3SpinBox->setMaximum(dmax); + ui.scalarwin3SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin3SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(3)); + + ui.scalarwin4SpinBox->setMinimum(dmin); + ui.scalarwin4SpinBox->setMaximum(dmax); + ui.scalarwin4SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin4SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(4)); + + ui.scalarwin5SpinBox->setMinimum(dmin); + ui.scalarwin5SpinBox->setMaximum(dmax); + ui.scalarwin5SpinBox->setSingleStep((dmax - dmin)/10.f); + ui.scalarwin5SpinBox->setValue(VisAtomVisualizingPolicy::GetScalarMappingTabValue(5)); + + ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnScalarwin0SpinBox(double value) +{ + + VisAtomVisualizingPolicy::SetScalarMappingTab(0, value); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + this->ui.displayWidget->updateGL(); + return; +} +//******************************************************************************** +void VisAtom2017::OnScalarwin1SpinBox(double value) +{ + + VisAtomVisualizingPolicy::SetScalarMappingTab(1, value); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + this->ui.displayWidget->updateGL(); + return; +} + +//******************************************************************************** +void VisAtom2017::OnScalarwin2SpinBox(double value) +{ + + VisAtomVisualizingPolicy::SetScalarMappingTab(2, value); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + this->ui.displayWidget->updateGL(); + return; +} + +//******************************************************************************** +void VisAtom2017::OnScalarwin3SpinBox(double value) +{ + + VisAtomVisualizingPolicy::SetScalarMappingTab(3, value); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + this->ui.displayWidget->updateGL(); + return; +} + +//******************************************************************************** +void VisAtom2017::OnScalarwin4SpinBox(double value) +{ + + VisAtomVisualizingPolicy::SetScalarMappingTab(4, value); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + this->ui.displayWidget->updateGL(); + return; +} + +//******************************************************************************** +void VisAtom2017::OnScalarwin5SpinBox(double value) +{ + + VisAtomVisualizingPolicy::SetScalarMappingTab(5, value); + VisAtomSample*sample = this->ui.displayWidget->GetSample(); + for(int i=0; iNumberofSubsample(); i++) sample->LoadSubsampleProp(i); + this->ui.displayWidget->updateGL(); + return; +} + + + + +//******************************************************************************** +void VisAtom2017::OnNewVectorPolicy() +{ + VisAtom_NewVectorPolicyDlg newvectorDlg(this); + + newvectorDlg.SetDataSheet(this->m_SampleDataSheet); + if(newvectorDlg.exec() == QDialog::Accepted) + { + int vcol[3]; + newvectorDlg.GetVectorColume(vcol); + + if(vcol[0] == vcol[1]) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr("Vx and Vy are assigned the same data.")); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + + } + else if(vcol[0] == vcol[2]) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr("Vx and Vz are assigned the same data.")); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + + } + + if(vcol[1] == vcol[2]) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr("Vy and Vz are assigned the same data.")); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + + } + //if the data has been changed, reset the default vector len scal + int oldcol[3]; + VisAtomVisualizingPolicy::GetVectorCol(oldcol); + // + if(oldcol[0] != vcol[0] || oldcol[1] != vcol[1] || oldcol[2] != vcol[2]) + { + QString slabel, snum; + slabel.append(tr("col. #")); + snum.setNum(vcol[0]+1); + slabel.append(snum); + ui.currenVxdataLabel->setText(slabel); + + slabel.clear(); + slabel.append(tr("col. #")); + snum.setNum(vcol[1]+1); + slabel.append(snum); + ui.currenVydataLabel->setText(slabel); + + slabel.clear(); + slabel.append(tr("col. #")); + snum.setNum(vcol[2]+1); + slabel.append(snum); + ui.currenVzdataLabel->setText(slabel); + // + VisAtomVisualizingPolicy::SetVectorCol(vcol); + float vlenscal, vrad, arrowl, arrowr; + ui.displayWidget->GetSample()->GetDefaultVectorSize(vlenscal,vrad, arrowl, arrowr); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal,vrad, arrowl, arrowr); + this->OnVectorOptionGroupBox(ui.vectoroptionGroupBox->isChecked()); + } + + } + //ui.vectoroptionGroupBox->setEnabled(VisAtomVisualizingPolicy::HasVectorData()); + + return; +} + +//******************************************************************************** +void VisAtom2017::OnVectorOptionGroupBox(bool checked) +{ + if(m_OnUpdateSubsampleUI) return; + + if(checked) + { + if(!VisAtomVisualizingPolicy::HasVectorData()) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("No vector data available, set the vector data?")); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + if(msgBox.exec() == QMessageBox::Yes) + { + this->OnNewVectorPolicy(); + if(!VisAtomVisualizingPolicy::HasVectorData()) + { + ui.vectoroptionGroupBox->setChecked(false); + return; + } + } + else + { + ui.vectoroptionGroupBox->setChecked(false); + return; + } + } + } + ui.vectorlineRadioButton->setEnabled(checked); + ui.vectorcylinderRadioButton->setEnabled(checked); + + ui.vectorarrowlenLabel->setEnabled(checked); + ui.vectorlenMpushButton->setEnabled(checked); + ui.vectorlenPpushButton->setEnabled(checked); + ui.vectorsizeMpushButton->setEnabled(checked); + ui.vectorsizePpushButton->setEnabled(checked); + ui.vectorarrowsizeLabel->setEnabled(checked); + + this->OnMultipleSelectSubsample(); + int style = 0; + if(ui.vectorlineRadioButton->isChecked()) + style = style|VisAtomVisualizingPolicy::VECTOR_STYLE_LINE; + else + style = style|VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID; + + emit this->SetGeomStyleVectorVisible(checked, style, false); +} + +//******************************************************************************** +void VisAtom2017::OnSelectVectorStyleLine(bool checked) +{ + if(!checked) return; + if(m_OnUpdateSubsampleUI) return; + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + this->OnMultipleSelectSubsample(); + emit this->SelectVectorStyleLine(checked); +} + +//******************************************************************************** +void VisAtom2017::OnSelectVectorStyleSolid(bool checked) +{ + if(!checked) return; + if(m_OnUpdateSubsampleUI) return; + + bool all = ui.atomsphaeApplyforAllCheckBox->isChecked(); + this->OnMultipleSelectSubsample(); + emit this->SelectVectorStyleSolid(checked); +} + + +//******************************************************************************** +void VisAtom2017::OnShowSceneOperation(bool checked) +{ + if(checked) + { + if(!this->ui.sceneDockWidget->isVisible()) + this->ui.sceneDockWidget->show(); + } + else + { + if(this->ui.sceneDockWidget->isVisible()) + this->ui.sceneDockWidget->hide(); + } +} + +//******************************************************************************** +void VisAtom2017::OnShowSubsampleOption(bool checked) +{ + if(checked) + { + if(!this->ui.displayoptionDockWidget->isVisible()) + this->ui.displayoptionDockWidget->show(); + } + else + { + if(this->ui.displayoptionDockWidget->isVisible()) + this->ui.displayoptionDockWidget->hide(); + } +} + +//******************************************************************************** +void VisAtom2017::OnShowSubsampleBrowser(bool checked) +{ + if(checked) + { + if(!this->ui.subsampleSumDockWidget->isVisible()) + this->ui.subsampleSumDockWidget->show(); + } + else + { + if(this->ui.subsampleSumDockWidget->isVisible()) + this->ui.subsampleSumDockWidget->hide(); + } +} + +//******************************************************************************** +void VisAtom2017::OnCloseSceneOperation(bool checked) +{ + ui.actionShow_scene_operation->setChecked(checked); +} + +//******************************************************************************** +void VisAtom2017::OnCloseSubsampleOption(bool checked) +{ + ui.actionShow_subsample_options->setChecked(checked); +} +//******************************************************************************** +void VisAtom2017::OnCloseSubsampleBrowser(bool checked) +{ + ui.actionShow_subsample_browser->setChecked(checked); +} + +//******************************************************************************** +void VisAtom2017::OnNormalizeView() +{ + this->ui.displayWidget->FitGraphView(); +} + +//******************************************************************************** +void VisAtom2017::OnTrajectoryOptionGroupBox(bool checked) +{ + + if(checked) + { + if(this->ui.trajectoryDataMRadioButton->isChecked()) + { + if(!VisAtom_NewDisplacementPolicyDlg::HasTrajectData()) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("No trajectory data available, set the data sources?")); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + if(msgBox.exec() == QMessageBox::Yes) + { + //popup the dialog + VisAtom_NewDisplacementPolicyDlg newvtrajectDlg(this); + //initializr the dialog + newvtrajectDlg.SetFilename(CURRENT_FNAME, this->m_SampleDataSheet); + + if(newvtrajectDlg.exec() != QDialog::Accepted) + { + this->ui.trajectoryOptionGroupBox->setChecked(false); + return; + } + } + else + { + this->ui.trajectoryOptionGroupBox->setChecked(false); + return; + } + //update the UI + int colx, coly, colz; + VisAtom_NewDisplacementPolicyDlg::GetDisplacementColume(colx, coly, colz); + this->m_LoadDataThread->SetFileSerial(CURRENT_FNAME, VisAtom_NewDisplacementPolicyDlg::GetStartInd(), + VisAtom_NewDisplacementPolicyDlg::GetEndInd(), + VisAtom_NewDisplacementPolicyDlg::GetIndexStep(), + colx, coly, colz); + + this->ui.trajectfromSpinBox->setValue(VisAtom_NewDisplacementPolicyDlg::GetStartInd()); + this->ui.trajecttoSpinBox->setValue(VisAtom_NewDisplacementPolicyDlg::GetEndInd()); + this->ui.trajectfilenameLineEdit->setText(CURRENT_FNAME); + } + else //load from a single trajectory file + { + } + } + // reload the data if necessary + } + int style; + emit this->SetGeomStyleTrajectyoryVisible(checked, style, false); + + if(!this->m_LoadDataThread->IsDataLoaded()) + this->m_LoadDataThread->StartLoadData(); + else + this->ui.displayWidget->updateGL(); + + return; +} + +//******************************************************************************** +void VisAtom2017::OnShapeOptionGroupBox(bool checked) +{ + int style; + emit this->SetGeomStyleAtomVisible(checked, style, false); + return; + +} + +//******************************************************************************** +void VisAtom2017::OnStartLoadTrajectory(QString& filename, int index, int total) +{ + this->setCursor(Qt::WaitCursor); + QString title; + title = tr("Load trajectory data..."); + title.append(filename); + this->m_statulabel.setText(title); + this->m_progressbar.setMaximum(total); + this->m_statulabel.show(); + this->m_progressbar.show(); + return; +} + +//******************************************************************************** +void VisAtom2017::OnEndLoadTrajectory(QString& filename, int index, int total) +{ + QString title; + title = tr("Data loaded from:"); + title.append(filename); + this->m_statulabel.setText(title); + this->m_statulabel.show(); + + this->m_progressbar.setValue(index+1); + this->m_progressbar.show(); + this->ui.displayWidget->updateGL(); + this->unsetCursor(); + + if(index+1 == total) + { + this->m_statulabel.hide(); + this->m_progressbar.hide(); + } + return; +} + + + +//******************************************************************************** +void VisAtom2017:: OnTrajectoryThickChanged(double thick) +{ + + emit SetTrajectoryThickChanged(thick,false); + return; +} + +//******************************************************************************** +void VisAtom2017::OnClipthroughPosRadioButton(bool checked) +{ + this->ui.clipPosXSpinBox->setReadOnly(false); + this->ui.clipPosYSpinBox->setReadOnly(false); + this->ui.clipPosZSpinBox->setReadOnly(false); + this->ui.clipthroughAtomSpinBox->setReadOnly(true); +} + +//******************************************************************************** +void VisAtom2017::OnClipthroughAtomRadioButton(bool checked) +{ + this->ui.clipPosXSpinBox->setReadOnly(true); + this->ui.clipPosYSpinBox->setReadOnly(true); + this->ui.clipPosZSpinBox->setReadOnly(true); + this->ui.clipthroughAtomSpinBox->setReadOnly(false); + int atomid = this->ui.clipthroughAtomSpinBox->value(); + + if(this->m_SampleDataSheet) + { + this->ui.clipthroughAtomSpinBox->setMaximum(this->m_SampleDataSheet->GetNumRow()); + float*x = this->m_SampleDataSheet->GetData(this->m_SampleDataSheet->GetPosXCol()); + float*y = this->m_SampleDataSheet->GetData(this->m_SampleDataSheet->GetPosYCol()); + float*z = this->m_SampleDataSheet->GetData(this->m_SampleDataSheet->GetPosZCol()); + + if(x && y && z) + { + this->ui.clipPosXSpinBox->setValue(x[atomid-1]); + this->ui.clipPosYSpinBox->setValue(y[atomid-1]); + this->ui.clipPosZSpinBox->setValue(z[atomid-1]); + } + } + return; +} + +//******************************************************************************** +void VisAtom2017::OnClipthroughAtomSpinBox(int atomid) +{ + if(this->m_SampleDataSheet) + { + float*x = this->m_SampleDataSheet->GetData(this->m_SampleDataSheet->GetPosXCol()); + float*y = this->m_SampleDataSheet->GetData(this->m_SampleDataSheet->GetPosYCol()); + float*z = this->m_SampleDataSheet->GetData(this->m_SampleDataSheet->GetPosZCol()); + + if(x && y && z) + { + this->ui.clipPosXSpinBox->setValue(x[atomid-1]); + this->ui.clipPosYSpinBox->setValue(y[atomid-1]); + this->ui.clipPosZSpinBox->setValue(z[atomid-1]); + } + } + return; +} + + +//******************************************************************************** +void VisAtom2017::OnResetTrajectoryDataPushButton() +{ + if(this->ui.trajectoryDataMRadioButton->isChecked()) + { + //reserve old set + int startind = VisAtom_NewDisplacementPolicyDlg::GetStartInd(); + int endind = VisAtom_NewDisplacementPolicyDlg::GetEndInd(); + int indstep = VisAtom_NewDisplacementPolicyDlg::GetIndexStep(); + + //popup the dialog + VisAtom_NewDisplacementPolicyDlg newvtrajectDlg(this); + //initializr the dialog + newvtrajectDlg.SetFilename(CURRENT_FNAME, this->m_SampleDataSheet); + if(newvtrajectDlg.exec() != QDialog::Accepted) return; + + //update the UI + int colx, coly, colz; + VisAtom_NewDisplacementPolicyDlg::GetDisplacementColume(colx, coly, colz); + + //check if data files have been changed + if(startind != VisAtom_NewDisplacementPolicyDlg::GetStartInd() || + endind != VisAtom_NewDisplacementPolicyDlg::GetEndInd() || + indstep != VisAtom_NewDisplacementPolicyDlg::GetIndexStep()|| + CURRENT_FNAME != this->ui.trajectfilenameLineEdit->text() ) + { + this->m_LoadDataThread->SetFileSerial(CURRENT_FNAME, VisAtom_NewDisplacementPolicyDlg::GetStartInd(), + VisAtom_NewDisplacementPolicyDlg::GetEndInd(), + VisAtom_NewDisplacementPolicyDlg::GetIndexStep(), + colx, coly, colz); + this->ui.trajectfromSpinBox->setValue(VisAtom_NewDisplacementPolicyDlg::GetStartInd()); + this->ui.trajecttoSpinBox->setValue(VisAtom_NewDisplacementPolicyDlg::GetEndInd()); + this->ui.trajectfilenameLineEdit->setText(CURRENT_FNAME); + + int style; + if(this->ui.trajectoryOptionGroupBox->isChecked()) + emit this->SetGeomStyleTrajectyoryVisible(true, style, false); + this->m_LoadDataThread->StartLoadData(); + } + else + { + this->m_LoadDataThread->SetDataCol(colx, coly, colz); + if(!this->m_LoadDataThread->IsDataLoaded()) + this->m_LoadDataThread->StartLoadData(); + else + this->ui.displayWidget->updateGL(); + } + } + else // loads from a single trajectory fiel + { + } + + return; +} + + +//******************************************************************************** +void VisAtom2017::OnTrajectoryDataSRadioButton(bool checked) +{ + if(!checked) return; + + + this->ui.trajectfromSpinBox->setEnabled(false); + this->ui.trajecttoSpinBox->setEnabled(false); + this->ui.trajectstepSpinBox->setEnabled(false); + + + return; +} + +//******************************************************************************** +void VisAtom2017::OnTrajectoryDataMRadioButton(bool checked) +{ + if(!checked) return; + this->ui.trajectfromSpinBox->setEnabled(true); + this->ui.trajecttoSpinBox->setEnabled(true); + this->ui.trajectstepSpinBox->setEnabled(true); + return; +} + + +//******************************************************************************** +void VisAtom2017::OnBoxX0Changed(double newX0) +{ + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + + if(abs(newX0 - (double)xmin) > 0.1) + { + xmin = newX0; + this->ui.displayWidget->SetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnBoxX1Changed(double newX1) +{ + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + + if(abs(newX1 - (double)xmax) > 0.1) + { + xmax = newX1; + this->ui.displayWidget->SetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnBoxY0Changed(double newY0) +{ + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + + if(abs(newY0 - (double)ymin) > 0.1) + { + ymin = newY0; + this->ui.displayWidget->SetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnBoxY1Changed(double newY1) +{ + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + + if(abs(newY1 - (double)ymax) > 0.1) + { + ymax = newY1; + this->ui.displayWidget->SetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnBoxZ0Changed(double newZ0) +{ + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + + if(abs(newZ0 - (double)zmin) > 0.1) + { + zmin = newZ0; + this->ui.displayWidget->SetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnBoxZ1Changed(double newZ1) +{ + float xmin, xmax, ymin, ymax, zmin, zmax; + this->ui.displayWidget->GetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + + if(abs(newZ1 - (double)zmax) > 0.1) + { + zmax = newZ1; + this->ui.displayWidget->SetSceneVolume(xmin, xmax, ymin, ymax, zmin, zmax); + this->ui.displayWidget->updateGL(); + } +} + +//******************************************************************************** +void VisAtom2017::OnBoxAutoPostion(bool checked) +{ + this->ui.boxX0SpinBox->setEnabled(!checked); + this->ui.boxX1SpinBox->setEnabled(!checked); + this->ui.boxY0SpinBox->setEnabled(!checked); + this->ui.boxY1SpinBox->setEnabled(!checked); + this->ui.boxZ0SpinBox->setEnabled(!checked); + this->ui.boxZ1SpinBox->setEnabled(!checked); + + if(checked) + this->ui.displayWidget->SetAutoNormalizingView(); + else + this->ui.displayWidget->SetNoAutoNormalizingView(); + + VisAtomVisualizingPolicy::SetAutoProjectionBox(checked); + +} + +//******************************************************************************** +void VisAtom2017::OnClusterEvelope() +{ + QString ext, snum, dot='.', caption, dir, selfilter; + QString currentfname; + if(CURRENT_EXTNUM>= 0) + { + ext = tr("*."); + snum.setNum(CURRENT_EXTNUM); + if(CURRENT_EXTNUM < 10) + ext.append(tr("000")); + else if(CURRENT_EXTNUM < 100) + ext.append(tr("00")); + else if(CURRENT_EXTNUM < 1000) + ext.append(tr("0")); + + ext.append(snum); + } + selfilter = tr("("); + selfilter.append(ext); + selfilter.append(tr(");;(*,*)")); + + + QString fileName = QFileDialog::getOpenFileName(this, caption, dir, ext, &selfilter); + + if (!fileName.isEmpty()) + { + VisClusterEnvelope*pObj = new VisClusterEnvelope(); + if(pObj->LoadData(fileName)) + emit this->OpenExtendedObject(pObj, fileName); + } + + return; +} + +void VisAtom2017::OnActionSubsample_filter(bool checked) +{ + if (!this->m_Atomfilter) + { + this->m_Atomfilter = new Visatom_AtomfilterDlg(this); + } + this->m_Atomfilter->setVisible(checked); +} + +void VisAtom2017::OnActionFindatom() +{ + if (!this->m_FindatomDlg) + { + this->m_FindatomDlg = new Visatom_FindatomDlg(this); + } + this->m_FindatomDlg->SetAtomSample(this->ui.displayWidget); + + this->m_FindatomDlg->setVisible(true); + this->ui.displayWidget->OnActionFindatom(); +} + + + diff --git a/VisAtom2017/VisAtom2017.h b/VisAtom2017/VisAtom2017.h new file mode 100644 index 0000000..5e30fe0 --- /dev/null +++ b/VisAtom2017/VisAtom2017.h @@ -0,0 +1,149 @@ +#ifndef VISATOM2017_H +#define VISATOM2017_H + +#include +#include "ui_visatom2017.h" +class VisAtomDataSheet; +class VisAtom_LoadTrajecoryThread; +class VisAtomExtendObject; +class Visatom_AtomfilterDlg; +class Visatom_FindatomDlg; + +class VisAtom2017 : public QMainWindow +{ + Q_OBJECT + +public: + VisAtom2017(QWidget *parent = Q_NULLPTR); + ~VisAtom2017(); + +private: + Ui::VisAtom2017Class ui; + + VisAtomDataSheet*m_SampleDataSheet; + VisAtom_LoadTrajecoryThread*m_LoadDataThread; + + void UpdateSubsampleUI(); + void UpdateSubsampleLIST(); + int m_OnUpdateSubsampleUI; + int m_OnUpdateClipParamUI; + + QLabel m_statulabel; + QLabel m_subsmaplelabel; + QProgressBar m_progressbar; + Visatom_AtomfilterDlg* m_Atomfilter; + Visatom_FindatomDlg* m_FindatomDlg; + + +public slots: + +private slots: + void OnFileOpen(); + void OnFileNext(); + void OnFilePrev(); + void OpenFile(QString fname, bool selcoldlg = true); + void LoadFrom_FMTUNKNOWN(QString fileName); + void LoadFrom_BOXCFG14(QString fileName); + void LoadFrom_BOXCFG16(QString fileName); + void OnSaveImage(); + void OnAboutVisatom2013(); + + void OnActionCopyImage(); + void OnActionRotateX(bool checked); + void OnActionRotateY(bool checked); + void OnActionRotateZ(bool checked); + void OnActionSubsample_filter(bool checked); + void OnActionZoomview(bool checked); + void OnActionVeiwportCenter(bool checked); + void OnActionFindatom(); + void OnSelectRotationX(); + void OnSelectRotationY(); + void OnSelectRotationZ(); + void OnSelectZoomScene(); + void OnChangeSceneDistance(); + void OnChangeAtomShapeDot(bool checked); + void OnChangeAtomShapeCircle(bool checked); + void OnChangeAtomShapeWireSphere(bool checked); + void OnChangeAtomShapeSolidSphere(bool checked); + void OnChangeAtomRadiu(); + void OnVariableAtomSize(bool checked); + void OnUnifiedAtomSize(bool checked); + int OnEditSizeDataButton(); + void OnChangeAtomColor(); + void OnSingleColorRadioButton(bool checked); + void OnMappingColorRadioButton(bool checked); + void OnNewColorPolicy(); + void OnScalarwin0SpinBox(double value); + void OnScalarwin1SpinBox(double value); + void OnScalarwin2SpinBox(double value); + void OnScalarwin3SpinBox(double value); + void OnScalarwin4SpinBox(double value); + void OnScalarwin5SpinBox(double value); + void OnChangeGraphQuality(int nfai); + + void OnNewVectorPolicy(); + void OnVectorOptionGroupBox(bool checked); + void OnSelectVectorStyleLine(bool checked); + void OnSelectVectorStyleSolid(bool checked); + + + void OnSelectSceneStyle(QListWidgetItem*,QListWidgetItem*); + void OnClipEnabled(); + void OnClipthroughPosRadioButton(bool checked); + void OnClipthroughAtomRadioButton(bool checked); + void OnClipthroughAtomSpinBox(int atomid); + void OnNewClipDirPushButton(); + void OnClipDirComboBoxIndexChanged(int index); + void OnClipDirCheckBoxChanged(bool enable); + + void GetClipParamFromUI(VisAtomCliper*clip); + void OnSelectSubsample(QTreeWidgetItem*item); + void OnSubsampleListItemChanged(QTreeWidgetItem*item); + void OnSubsampleListTreeItemDBClick(QTreeWidgetItem*, int index); + void OnMultipleSelectSubsample(); + + void OnShowSceneOperation(bool checked); + void OnShowSubsampleOption(bool checked); + void OnShowSubsampleBrowser(bool checked); + void OnCloseSceneOperation(bool checked); + void OnCloseSubsampleOption(bool checked); + void OnCloseSubsampleBrowser(bool checked); + void OnNormalizeView(); + + void OnTrajectoryOptionGroupBox(bool checked); + void OnTrajectoryDataSRadioButton(bool checkd); + void OnTrajectoryDataMRadioButton(bool checkd); + void OnShapeOptionGroupBox(bool checked); + + void OnStartLoadTrajectory(QString& filename, int index, int total); + void OnEndLoadTrajectory(QString& filename, int index, int total); + void OnTrajectoryThickChanged(double thick); + void OnResetTrajectoryDataPushButton(); + + void OnBoxX0Changed(double X0); + void OnBoxX1Changed(double X1); + void OnBoxY0Changed(double Y0); + void OnBoxY1Changed(double Y1); + void OnBoxZ0Changed(double Z0); + void OnBoxZ1Changed(double Z1); + void OnBoxAutoPostion(bool checked); + + void OnClusterEvelope(); +signals: + void SetMouseAction(int action); + void SetSceneDistance(int range,int value); + void SetAtomRadiu(int range, int value, bool all=false); + void SetAtomShape(int shape, bool all); + void SetVariableAtomRadiu(bool variable, bool all); + void SetGeomStyleVectorVisible(bool show, int style, bool all); + void SetGeomStyleTrajectyoryVisible(bool show, int style, bool all); + void SetGeomStyleAtomVisible(bool show, int style, bool all); + void SetTrajectoryThickChanged(double thick,bool all); + void ChangeGraphQuality(int); + void SelectVectorStyleLine(bool checked); + void SelectVectorStyleSolid(bool checked); + void OpenExtendedObject(VisAtomExtendObject*ptrObj, QString fname); + +}; + +#endif // VISATOM2017_H diff --git a/VisAtom2017/VisAtom2017.qrc0 b/VisAtom2017/VisAtom2017.qrc0 new file mode 100644 index 0000000..e999999 --- /dev/null +++ b/VisAtom2017/VisAtom2017.qrc0 @@ -0,0 +1,4 @@ + + + + diff --git a/VisAtom2017/VisAtom2017.rc b/VisAtom2017/VisAtom2017.rc new file mode 100644 index 0000000..cad1344 --- /dev/null +++ b/VisAtom2017/VisAtom2017.rc @@ -0,0 +1,61 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 4, 2 +#pragma code_page(936) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/VisAtom2017/VisAtom2017.sln b/VisAtom2017/VisAtom2017.sln new file mode 100644 index 0000000..c6a8978 --- /dev/null +++ b/VisAtom2017/VisAtom2017.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2027 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VisAtom2017", "VisAtom2017.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9BD21358-4775-4F78-88A8-1F9B4077954B} + EndGlobalSection +EndGlobal diff --git a/VisAtom2017/VisAtom2017.ui b/VisAtom2017/VisAtom2017.ui new file mode 100644 index 0000000..777e72c --- /dev/null +++ b/VisAtom2017/VisAtom2017.ui @@ -0,0 +1,6546 @@ + + + VisAtom2017Class + + + + 0 + 0 + 1227 + 762 + + + + + 0 + 0 + + + + VisAtom2017 + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + true + + + true + + + true + + + QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks + + + + + 0 + 0 + + + + false + + + background-color: rgb(207, 207, 207); + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 100 + 100 + + + + + 100 + 100 + + + + false + + + + + + + + + + + 0 + 0 + 1227 + 23 + + + + + &File + + + + Extended Objects + + + + + + + + + + + + + &Action + + + true + + + + + + + + + + + + + + + + + + &View + + + + + + + + + + About + + + + + + + + + + + + 0 + 0 + + + + true + + + Qt::StrongFocus + + + Qt::ActionsContextMenu + + + Qt::LeftToRight + + + true + + + Qt::BottomToolBarArea|Qt::LeftToolBarArea|Qt::RightToolBarArea + + + + 24 + 24 + + + + TopToolBarArea + + + false + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 314 + 667 + + + + + 524287 + 524287 + + + + + :/VisAtom2013_1/solidsphere.png:/VisAtom2013_1/solidsphere.png + + + QDockWidget::AllDockWidgetFeatures + + + Scene operation + + + 1 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + QTabWidget::South + + + 2 + + + + 16 + 16 + + + + false + + + + Clipping + + + + 4 + + + 4 + + + 4 + + + + + + 0 + 0 + + + + Clipping styles + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 100 + + + + false + + + QFrame::StyledPanel + + + QFrame::Plain + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAsNeeded + + + false + + + 16 + + + + 48 + 48 + + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + QListView::TopToBottom + + + QListView::Fixed + + + QListView::SinglePass + + + QListView::IconMode + + + 0 + + + true + + + true + + + -1 + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 12 + + + + + + + + QFrame::NoFrame + + + 2 + + + + + + + Clipping along X + + + true + + + false + + + + + + Double clipping + + + + + + + Inverse direction + + + + + + + + + + 0 + 0 + + + + Clipping step: + + + + + + + + 0 + 0 + + + + + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 68 + 0 + + + + + 68 + 16777215 + + + + Position: + + + clipXbackButton + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + < + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + > + + + + + + + + + + + + Clipping along Y + + + true + + + false + + + + + + Double clipping + + + + + + + Inverse direction + + + + + + + + + Clipping step: + + + + + + + + 0 + 0 + + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + 0 + + + + + + 68 + 0 + + + + + 68 + 16777215 + + + + Position: + + + clipYbackButton + + + + + + + < + + + + + + + > + + + + + + + + + + + + + 0 + 0 + + + + Clipping along Z + + + true + + + false + + + + + + Double clipping + + + + + + + Inverse direction + + + + + + + + + Clipping step: + + + + + + + + 0 + 0 + + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + 0 + + + + + + 68 + 0 + + + + + 68 + 16777215 + + + + Position: + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + < + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + > + + + + + + + + + + + + Qt::Vertical + + + + 20 + 73 + + + + + + + + + + + + + 0 + 0 + + + + Clipping along X + + + true + + + false + + + + + + Double clipping + + + + + + + Inverse direction + + + + + + + + + + 0 + 0 + + + + Clipping step: + + + + + + + + 0 + 0 + + + + + + + 999.990000000000009 + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 68 + 0 + + + + + 68 + 16777215 + + + + Position: + + + clipXbackButton + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + < + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + > + + + + + + + + + + + + Clipping along Y + + + true + + + false + + + + + + Double clipping + + + + + + + Inverse direction + + + + + + + + + Clipping step: + + + clipstepYSpinBox + + + + + + + + 0 + 0 + + + + 999.990000000000009 + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + 68 + 0 + + + + + 68 + 16777215 + + + + Position: + + + clipYbackButton + + + + + + + < + + + + + + + > + + + + + + + + + + + + + 0 + 0 + + + + Clipping along Z + + + true + + + false + + + + + + Double clipping + + + + + + + Inverse direction + + + + + + + + + Clipping step: + + + clipstepZSpinBox + + + + + + + + 0 + 0 + + + + 999.990000000000009 + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + 0 + + + + + + 68 + 0 + + + + + 68 + 16777215 + + + + Position: + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + < + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + > + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + New plane + + + + + + + + + + + 16 + 0 + + + + + 16 + 16777215 + + + + Enable + + + true + + + + + + + + + Direction + + + + + + -100 + + + 100 + + + 1 + + + + + + + X index: + + + clipDirXSpinBox + + + + + + + Y index: + + + clipDirYSpinBox + + + + + + + -100 + + + 100 + + + 1 + + + + + + + -100 + + + 100 + + + 1 + + + + + + + Z index + + + clipDirZSpinBox + + + + + + + + + + Through + + + + + + Poisition + + + true + + + + + + + 6 + + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + X: + + + clipPosXSpinBox + + + + + + + + + + 4 + + + -999.990000000000009 + + + 999.990000000000009 + + + + + + + + 32 + 0 + + + + Y: + + + + + + + 4 + + + -999.990000000000009 + + + 999.990000000000009 + + + + + + + + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + Z: + + + + + + + 4 + + + -999.990000000000009 + + + 999.990000000000009 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 19 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + Atom: + + + + + + + true + + + 1 + + + 99999999 + + + 1 + + + + + + + + + + + + Double clipping + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 9 + 20 + + + + + + + + + 0 + 0 + + + + Thickness: + + + clipstepXSpinBox + + + + + + + + 0 + 0 + + + + + + + 4 + + + 999.990000000000009 + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + + + Show: + + + + + + Opacity: + + + + + + + 30 + + + 3 + + + 10 + + + 9 + + + Qt::Horizontal + + + + + + + Back face + + + true + + + + + + + Front face + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + Property + + + + + + Backgroud color... + + + false + + + + + + + + 16777215 + 104 + + + + Project type + + + + + + + + Ortho + + + + + + + Perspective + + + true + + + + + + + + + + + Scene distance: + + + distanceSlider + + + + + + + Qt::Horizontal + + + + + + + + + + + + + 16777215 + 100 + + + + Coordinate system + + + + + + Body + + + true + + + + + + + Labrotary + + + + + + + + + + Moving steps + + + + + + + + + 0 + 0 + + + + + 48 + 0 + + + + + 68 + 16777215 + + + + RotX: + + + + + + + 1 + + + 90 + + + 10 + + + Qt::Horizontal + + + + + + + + + + + + 0 + 0 + + + + + 48 + 0 + + + + + 68 + 16777215 + + + + RotY: + + + + + + + 1 + + + 90 + + + 10 + + + Qt::Horizontal + + + + + + + + + + + + 0 + 0 + + + + + 48 + 0 + + + + + 68 + 16777215 + + + + Rot-Z: + + + + + + + 1 + + + 90 + + + 10 + + + Qt::Horizontal + + + + + + + + + + + + 0 + 0 + + + + + 48 + 0 + + + + + 48 + 16777215 + + + + Zoom: + + + + + + + 1 + + + 50 + + + 10 + + + Qt::Horizontal + + + + + + + + + + + + Focus + + + + + + Poisition + + + true + + + + + + + 6 + + + + + + 0 + 0 + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + X + + + clipPosXSpinBox + + + + + + + + + + -999.990000000000009 + + + 999.990000000000009 + + + + + + + + 0 + 0 + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + Y + + + + + + + -999.990000000000009 + + + 999.990000000000009 + + + + + + + + + + + + 0 + 0 + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + Z: + + + + + + + -999.990000000000009 + + + 999.990000000000009 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + Atom: + + + + + + + true + + + 1 + + + 99999999 + + + 1 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + SceneBox + + + + + + Box position + + + + + + Automatically + + + true + + + + + + + + + + 24 + 16777215 + + + + X0 + + + + + + + true + + + 4 + + + -20000.000000000000000 + + + 20000.000000000000000 + + + 1.000000000000000 + + + + + + + + 24 + 16777215 + + + + X1 + + + + + + + true + + + 4 + + + -20000.000000000000000 + + + 20000.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + + 24 + 16777215 + + + + Y0 + + + + + + + true + + + 4 + + + -20000.000000000000000 + + + 20000.000000000000000 + + + 1.000000000000000 + + + + + + + + 24 + 16777215 + + + + Y1 + + + + + + + true + + + 4 + + + -20000.000000000000000 + + + 20000.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + + 24 + 16777215 + + + + Z0 + + + + + + + true + + + 4 + + + -20000.000000000000000 + + + 20000.000000000000000 + + + 1.000000000000000 + + + + + + + + 24 + 16777215 + + + + Z1 + + + + + + + true + + + 4 + + + -20000.000000000000000 + + + 20000.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 80 + + + + Display options + + + + + + + Microsoft Sans Serif + + + + QFrame::Box + + + 3 + + + false + + + + 1 + + + + + 2 + + + + + 3 + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 340 + + + + + + + + + + + + + + + 0 + 0 + + + + + 282 + 559 + + + + + 524287 + 524287 + + + + QDockWidget::AllDockWidgetFeatures + + + Qt::AllDockWidgetAreas + + + Subsample options + + + 2 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QTabWidget::South + + + 0 + + + + Shape and Color + + + + + + + 0 + 0 + + + + Atom shape + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + false + + + true + + + + + + Dot + + + true + + + + + + + Solid sphere + + + + + + + Filled cycle + + + + + + + Circle + + + + + + + Size + + + + + + Unified size + + + true + + + + + + + Change sphere size + + + 1 + + + 500 + + + 10 + + + Qt::Horizontal + + + + + + + Variable size + + + + + + + false + + + Edit size data + + + + + + + + + + Graph quality: + + + graphqualitySlider + + + + + + + 6 + + + 36 + + + 3 + + + 12 + + + Qt::Horizontal + + + + + + + Apply for all subsamples + + + + + + + + + + + 0 + 0 + + + + Atom color style + + + + + + + + Single color + + + true + + + + + + + Mapping + + + + + + + + + + 0 + 0 + + + + 1 + + + 1 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Change atom color + + + + 32 + 16 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + Reset scalar table... + + + + :/VisAtom2013_1/images/colormap.png:/VisAtom2013_1/images/colormap.png + + + + 48 + 16 + + + + + + + + QLayout::SetFixedSize + + + 6 + + + + + + 0 + 0 + + + + Min + + + + + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + 0 + 0 + + + + Max + + + + + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + 0 + 0 + + + + Data range: + + + + + + + + + + + + 0 + 0 + + + + Window = : + + + false + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + <= + + + + + + + 4 + + + + + + + + + + + + 0 + 0 + + + + Window = : + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + = + + + + + + + 4 + + + + + + + + + + + + 0 + 0 + + + + Window =: + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + = + + + + + + + 4 + + + + + + + + + + + + 0 + 0 + + + + Window =: + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + = + + + + + + + 4 + + + + + + + + + + + + 0 + 0 + + + + Window =: + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + = + + + + + + + 4 + + + + + + + + + + + + 0 + 0 + + + + Window =: + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + >= + + + + + + + 4 + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + Vector + + + + + + true + + + Show vector + + + false + + + true + + + false + + + + + + false + + + Line + + + true + + + + + + + false + + + Solid + + + + + + + false + + + Adjust length: + + + + + + + 0 + + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + < + + + + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + > + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + false + + + Adjust size: + + + + + + + 0 + + + + + + 32 + 16777215 + + + + < + + + + + + + + 32 + 16777215 + + + + > + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Current vector data + + + + + + + 0 + 19 + + + + Vx: + + + + + + + + 0 + 19 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + 0 + 19 + + + + Vy: + + + + + + + + 0 + 19 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + 0 + 19 + + + + Vz: + + + + + + + + 0 + 19 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + + + Edit vector data + + + + + + + Qt::Vertical + + + + 20 + 128 + + + + + + + + + Trajectory + + + + + + Show trajectory + + + true + + + false + + + + + + true + + + Intermediate sites + + + + + + + true + + + Start site + + + + + + + true + + + End site + + + + + + + false + + + trjectory line + + + true + + + + + + + + + thickness + + + + + + + + 0 + 0 + + + + + 32 + 0 + + + + 1 + + + 1.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + + Data set + + + + + + Load from trajectory file + + + + + + + Load from configure files + + + true + + + + + + + + + Filename + + + + + + + true + + + not defined + + + true + + + + + + + + + + + Index from: + + + + + + + true + + + true + + + -1 + + + 9999 + + + -1 + + + + + + + to: + + + + + + + true + + + true + + + -1 + + + 9999 + + + -1 + + + + + + + + + + + by step: + + + + + + + + 0 + 0 + + + + + 48 + 0 + + + + true + + + 1 + + + 100 + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Edit trajectory data... + + + + + + + + + + Qt::Vertical + + + + 20 + 107 + + + + + + + + + + + + + + Subsample browser + + + 2 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Microsoft Sans Serif + + + + true + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + 20 + + + true + + + true + + + 2 + + + true + + + true + + + 150 + + + true + + + + 1 + + + + + 2 + + + + + + + + + + + :/VisAtom2017/images/open.png:/VisAtom2017/images/open.png + + + &Open + + + Open a file + + + + + + :/VisAtom2013_1/save.png:/VisAtom2013_1/save.png + + + &Save + + + + + + + + About VisAtom2017 + + + + + + :/VisAtom2017/images/fit-page-32.png:/VisAtom2017/images/fit-page-32.png + + + &Fit to viewport + + + + + true + + + + :/VisAtom2017/images/rotationx.png:/VisAtom2017/images/rotationx.png + + + Rotate-X + + + Rotatte aropund X + + + + + true + + + + :/VisAtom2017/images/rotationy.png:/VisAtom2017/images/rotationy.png + + + Rotate-Y + + + Rotate around Y + + + + + true + + + false + + + + :/VisAtom2017/images/rotationz.png:/VisAtom2017/images/rotationz.png + + + Rotate-Z + + + Rotate around Z + + + + + true + + + true + + + + :/VisAtom2017/images/zoomin.png:/VisAtom2017/images/zoomin.png + + + Zoom view + + + + + + :/VisAtom2017/images/copy.png:/VisAtom2017/images/copy.png + + + Copy image + + + + + false + + + + :/VisAtom2017/images/next.png:/VisAtom2017/images/next.png + + + Next + + + Next file + + + + + false + + + + :/VisAtom2017/images/prev.png:/VisAtom2017/images/prev.png + + + Previous + + + Previous file + + + + + true + + + false + + + Scene operation + + + + + true + + + true + + + Subsample options + + + + + true + + + true + + + Subsample browser + + + + + + :/VisAtom2013_1/images/cursor-sizeh.png:/VisAtom2013_1/images/cursor-sizeh.png + + + Translate-X + + + + + + :/VisAtom2013_1/images/cursor-sizev.png:/VisAtom2013_1/images/cursor-sizev.png + + + Translate-Y + + + + + + :/VisAtom2013_1/images/cursor-sizeb.png:/VisAtom2013_1/images/cursor-sizeb.png + + + Translate-Z + + + + + true + + + + :/VisAtom2017/images/adjustsize.png:/VisAtom2017/images/adjustsize.png + + + Translate + + + Translate viewport center + + + + + Cluster envelope + + + + + true + + + Subsample filter + + + + + Find atoms... + + + sceneDockWidget + displayoptionDockWidget + subsampleSumDockWidget + + + + + VisAtomWidget + QWidget +
VisAtomwidget.h
+ 1 + + SelectMouseAction(int) + OnChangeSceneBackground() + OnProjecttypeOrtho() + OnProjecttypePerspect() + SetSceneDistance(int,int) + OnCoordinatBody() + OnCoordinatLab() + OnSelectShapeDot(bool) + OnSelectShapeSolidSphere(bool) + OnSelectShapeWireSphere(bool) + OnSelectShapeCircle(bool) + SetAtomRadiu(int,int,bool) + OnChangeAtomColor() + OnShowSceneBox(int) + OnClipZForward() + OnClipZBack() + OnClipYForward() + OnClipYBack() + OnClipXForward() + OnClipXBack() + OnShowSceneBackfaceX(int) + OnShowSceneBackfaceY(int) + OnShowSceneBackfaceZ(int) + OnShowSceneFrontfaceX(int) + OnShowSceneFrontfaceY(int) + OnShowSceneFrontfaceZ(int) + OnShowClipANYDIRFrontface(bool) + OnShowClipANYDIRBackface(bool) + SetAtomShape(int,bool) + OnRotationXStep(int) + OnRotationYStep(int) + OnRotationZStep(int) + OnZoomStep(int) + OnChangeGraphQuality(int) + SetGeomStyleVectorVisible(bool,int,bool) + OnVectorLenMinus() + OnVectorLenPlus() + OnVectorSizeMinus() + OnVectorSizePlus() + OnSelectVectorStyleLine(bool) + OnSelectVectorStyleSolid(bool) + SetVariableAtomRadiu(bool,bool) + SetGeomStyleTrajectyoryVisible(bool,int,bool) + SetGeomStyleAtomVisible(bool,int,bool) + SetTrajectoryThickChanged(double,bool) + ChangeGraphQuality(int) + OnOpenExtendedObject(VisAtomExtendObject*,QString) + OnBoxDisplayOption(QTreeWidgetItem*) + OnFindatomchanged() + +
+
+ + + + + + action_Open + triggered() + VisAtom2017Class + OnFileOpen() + + + -1 + -1 + + + 451 + 354 + + + + + VisAtom2017Class + SetMouseAction(int) + displayWidget + SelectMouseAction(int) + + + 469 + 324 + + + 487 + 341 + + + + + changeSceneColor + pressed() + displayWidget + OnChangeSceneBackground() + + + 126 + 427 + + + 578 + 330 + + + + + distanceSlider + valueChanged(int) + VisAtom2017Class + OnChangeSceneDistance() + + + 121 + 467 + + + 566 + 375 + + + + + VisAtom2017Class + SetSceneDistance(int,int) + displayWidget + SetSceneDistance(int,int) + + + 566 + 375 + + + 578 + 372 + + + + + coordsysBody + clicked() + displayWidget + OnCoordinatBody() + + + 44 + 522 + + + 579 + 372 + + + + + coordsysLab + clicked() + displayWidget + OnCoordinatLab() + + + 59 + 544 + + + 579 + 372 + + + + + dotRadioButton + toggled(bool) + VisAtom2017Class + OnChangeAtomShapeDot(bool) + + + 825 + 117 + + + 513 + 400 + + + + + sphereRadioButton + toggled(bool) + VisAtom2017Class + OnChangeAtomShapeSolidSphere(bool) + + + 970 + 117 + + + 513 + 400 + + + + + wireRadioButton + toggled(bool) + VisAtom2017Class + OnChangeAtomShapeWireSphere(bool) + + + 849 + 139 + + + 513 + 400 + + + + + circleRadioButton + toggled(bool) + VisAtom2017Class + OnChangeAtomShapeCircle(bool) + + + 970 + 139 + + + 513 + 400 + + + + + atomsizeSlider + valueChanged(int) + VisAtom2017Class + OnChangeAtomRadiu() + + + 922 + 163 + + + 531 + 375 + + + + + VisAtom2017Class + SetAtomRadiu(int,int,bool) + displayWidget + SetAtomRadiu(int,int,bool) + + + 531 + 375 + + + 471 + 372 + + + + + changeatomColorButton + pressed() + VisAtom2017Class + OnChangeAtomColor() + + + 912 + 99 + + + 513 + 400 + + + + + actionAbout_VisAtom2013 + triggered() + VisAtom2017Class + OnAboutVisatom2013() + + + -1 + -1 + + + 531 + 375 + + + + + scenestylelistWidget + currentItemChanged(QListWidgetItem*,QListWidgetItem*) + VisAtom2017Class + OnSelectSceneStyle(QListWidgetItem*,QListWidgetItem*) + + + 126 + 311 + + + 531 + 375 + + + + + scenestyleClipXGroupBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 382 + + + 531 + 376 + + + + + scenestyleDClipXCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 351 + + + 531 + 376 + + + + + scenestyleclipInvXCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 373 + + + 531 + 376 + + + + + scenestyleClipYGroupBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 510 + + + 531 + 376 + + + + + scenestyleDClipYCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 479 + + + 531 + 376 + + + + + scenestyleclipInvYCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 501 + + + 531 + 376 + + + + + scenestyleClipZGroupBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 641 + + + 531 + 376 + + + + + scenestyleDClipZCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 607 + + + 531 + 376 + + + + + scenestyleclipInvZCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 141 + 629 + + + 531 + 376 + + + + + action_Fit_graph_to_view + triggered() + VisAtom2017Class + OnNormalizeView() + + + -1 + -1 + + + 513 + 361 + + + + + clipXbackButton + clicked() + displayWidget + OnClipXBack() + + + 115 + 452 + + + 494 + 415 + + + + + clipXforwardButton + clicked() + displayWidget + OnClipXForward() + + + 190 + 452 + + + 494 + 415 + + + + + clipYbackButton + clicked() + displayWidget + OnClipYBack() + + + 115 + 587 + + + 494 + 415 + + + + + clipYforwardButton + clicked() + displayWidget + OnClipYForward() + + + 190 + 587 + + + 494 + 415 + + + + + clipZbackButton + clicked() + displayWidget + OnClipZBack() + + + 115 + 722 + + + 494 + 415 + + + + + clipZforwardButton + clicked() + displayWidget + OnClipZForward() + + + 190 + 722 + + + 494 + 415 + + + + + scenestyleClipXGroupBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 400 + + + 513 + 397 + + + + + scenestyleClipYGroupBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 535 + + + 513 + 397 + + + + + scenestyleClipZGroupBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 670 + + + 513 + 397 + + + + + scenestyleDClipXCheckBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 365 + + + 513 + 397 + + + + + scenestyleDClipYCheckBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 500 + + + 513 + 397 + + + + + scenestyleDClipZCheckBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 635 + + + 513 + 397 + + + + + scenestyleclipInvXCheckBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 387 + + + 513 + 397 + + + + + scenestyleclipInvYCheckBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 522 + + + 513 + 397 + + + + + scenestyleclipInvZCheckBox1 + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 125 + 657 + + + 513 + 397 + + + + + clipXbackButton1 + clicked(bool) + displayWidget + OnClipXBack() + + + 115 + 442 + + + 494 + 415 + + + + + clipXforwardButton1 + clicked() + displayWidget + OnClipXForward() + + + 190 + 442 + + + 494 + 415 + + + + + clipYbackButton1 + clicked() + displayWidget + OnClipYBack() + + + 115 + 577 + + + 494 + 415 + + + + + clipYforwardButton1 + clicked() + displayWidget + OnClipYForward() + + + 190 + 577 + + + 494 + 415 + + + + + clipZbackButton1 + clicked() + displayWidget + OnClipZBack() + + + 115 + 712 + + + 494 + 415 + + + + + clipZforwardButton1 + clicked() + displayWidget + OnClipZForward() + + + 190 + 712 + + + 494 + 415 + + + + + clipDirXSpinBox + valueChanged(int) + VisAtom2017Class + OnClipEnabled() + + + 180 + 372 + + + 513 + 400 + + + + + clipDirYSpinBox + valueChanged(int) + VisAtom2017Class + OnClipEnabled() + + + 180 + 398 + + + 513 + 400 + + + + + clipDirZSpinBox + valueChanged(int) + VisAtom2017Class + OnClipEnabled() + + + 180 + 424 + + + 513 + 400 + + + + + scenestyleDClipDCheckBox + clicked(bool) + VisAtom2017Class + OnClipEnabled() + + + 126 + 570 + + + 513 + 400 + + + + + actionRotate_X + triggered(bool) + VisAtom2017Class + OnActionRotateX(bool) + + + -1 + -1 + + + 513 + 400 + + + + + actionRotate_Y + triggered(bool) + VisAtom2017Class + OnActionRotateY(bool) + + + -1 + -1 + + + 513 + 400 + + + + + actionRotate_Z + triggered(bool) + VisAtom2017Class + OnActionRotateZ(bool) + + + -1 + -1 + + + 513 + 400 + + + + + actionZoom_view + triggered(bool) + VisAtom2017Class + OnActionZoomview(bool) + + + -1 + -1 + + + 513 + 400 + + + + + clipDFrontfaceShowCheckBox + clicked(bool) + displayWidget + OnShowClipANYDIRFrontface(bool) + + + 69 + 542 + + + 494 + 417 + + + + + clipDBackfaceShowCheckBox + clicked(bool) + displayWidget + OnShowClipANYDIRBackface(bool) + + + 69 + 570 + + + 494 + 417 + + + + + clipOpacitySlider + valueChanged(int) + VisAtom2017Class + OnClipEnabled() + + + 171 + 563 + + + 513 + 400 + + + + + subsampleListTreeWidget + currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*) + VisAtom2017Class + OnSelectSubsample(QTreeWidgetItem*) + + + 877 + 674 + + + 513 + 400 + + + + + subsampleListTreeWidget + itemChanged(QTreeWidgetItem*,int) + VisAtom2017Class + OnSubsampleListItemChanged(QTreeWidgetItem*) + + + 877 + 674 + + + 513 + 400 + + + + + VisAtom2017Class + SetAtomShape(int,bool) + displayWidget + SetAtomShape(int,bool) + + + 513 + 400 + + + 513 + 417 + + + + + rotationstepXSlider + valueChanged(int) + displayWidget + OnRotationXStep(int) + + + 162 + 397 + + + 513 + 417 + + + + + rotationstepYSlider + valueChanged(int) + displayWidget + OnRotationYStep(int) + + + 162 + 422 + + + 513 + 417 + + + + + rotationstepZSlider + valueChanged(int) + displayWidget + OnRotationZStep(int) + + + 162 + 447 + + + 513 + 417 + + + + + rotationstepZoomSlider + valueChanged(int) + displayWidget + OnZoomStep(int) + + + 162 + 472 + + + 513 + 417 + + + + + graphqualitySlider + valueChanged(int) + VisAtom2017Class + OnChangeGraphQuality(int) + + + 946 + 188 + + + 510 + 393 + + + + + newcolorpolicyButton + clicked() + VisAtom2017Class + OnNewColorPolicy() + + + 898 + 436 + + + 513 + 400 + + + + + singlecolorRadioButton + toggled(bool) + VisAtom2017Class + OnSingleColorRadioButton(bool) + + + 837 + 258 + + + 513 + 361 + + + + + mappingcolorRadioButton + toggled(bool) + VisAtom2017Class + OnMappingColorRadioButton(bool) + + + 947 + 258 + + + 513 + 361 + + + + + action_Save + triggered() + VisAtom2017Class + OnSaveImage() + + + -1 + -1 + + + 513 + 361 + + + + + actionCopy_image + triggered() + VisAtom2017Class + OnActionCopyImage() + + + -1 + -1 + + + 513 + 361 + + + + + newvectorpolicyButton + clicked() + VisAtom2017Class + OnNewVectorPolicy() + + + 896 + 275 + + + 513 + 361 + + + + + vectoroptionGroupBox + clicked(bool) + VisAtom2017Class + OnVectorOptionGroupBox(bool) + + + 896 + 172 + + + 513 + 361 + + + + + VisAtom2017Class + SetGeomStyleVectorVisible(bool,int,bool) + displayWidget + SetGeomStyleVectorVisible(bool,int,bool) + + + 513 + 361 + + + 511 + 379 + + + + + vectorlenMpushButton + clicked() + displayWidget + OnVectorLenMinus() + + + 915 + 144 + + + 521 + 379 + + + + + vectorlenPpushButton + clicked() + displayWidget + OnVectorLenPlus() + + + 947 + 144 + + + 521 + 379 + + + + + vectorsizeMpushButton + clicked() + displayWidget + OnVectorSizeMinus() + + + 915 + 175 + + + 521 + 379 + + + + + vectorsizePpushButton + clicked() + displayWidget + OnVectorSizePlus() + + + 947 + 175 + + + 521 + 379 + + + + + vectorlineRadioButton + clicked(bool) + VisAtom2017Class + OnSelectVectorStyleLine(bool) + + + 816 + 117 + + + 510 + 393 + + + + + vectorcylinderRadioButton + clicked(bool) + VisAtom2017Class + OnSelectVectorStyleSolid(bool) + + + 943 + 117 + + + 510 + 393 + + + + + clipstepDSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 167 + 483 + + + 513 + 361 + + + + + clipPosXSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 132 + 372 + + + 513 + 361 + + + + + clipPosYSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 132 + 398 + + + 513 + 361 + + + + + clipPosZSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 132 + 424 + + + 513 + 361 + + + + + clipstepXSpinBox1 + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 170 + 307 + + + 513 + 361 + + + + + clipstepYSpinBox1 + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 170 + 442 + + + 513 + 361 + + + + + clipstepZSpinBox1 + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 170 + 577 + + + 513 + 361 + + + + + clipstepXSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 170 + 307 + + + 513 + 361 + + + + + clipstepYSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 170 + 442 + + + 513 + 361 + + + + + clipstepZSpinBox + valueChanged(double) + VisAtom2017Class + OnClipEnabled() + + + 170 + 577 + + + 513 + 361 + + + + + actionNext + triggered() + VisAtom2017Class + OnFileNext() + + + -1 + -1 + + + 513 + 361 + + + + + actionPrev + triggered() + VisAtom2017Class + OnFilePrev() + + + -1 + -1 + + + 513 + 361 + + + + + actionShow_scene_operation + triggered(bool) + VisAtom2017Class + OnShowSceneOperation(bool) + + + -1 + -1 + + + 513 + 361 + + + + + actionShow_subsample_browser + triggered(bool) + VisAtom2017Class + OnShowSubsampleBrowser(bool) + + + -1 + -1 + + + 513 + 361 + + + + + actionShow_subsample_options + triggered(bool) + VisAtom2017Class + OnShowSubsampleOption(bool) + + + -1 + -1 + + + 513 + 361 + + + + + sceneDockWidget + visibilityChanged(bool) + VisAtom2017Class + OnCloseSceneOperation(bool) + + + 127 + 379 + + + 513 + 361 + + + + + displayoptionDockWidget + visibilityChanged(bool) + VisAtom2017Class + OnCloseSubsampleOption(bool) + + + 899 + 272 + + + 513 + 361 + + + + + subsampleSumDockWidget + visibilityChanged(bool) + VisAtom2017Class + OnCloseSubsampleBrowser(bool) + + + 899 + 599 + + + 513 + 361 + + + + + atomunitsizeRadioButton + clicked(bool) + VisAtom2017Class + OnUnifiedAtomSize(bool) + + + 849 + 183 + + + 513 + 361 + + + + + atomvairablesizeRadioButton + clicked(bool) + VisAtom2017Class + OnVariableAtomSize(bool) + + + 849 + 205 + + + 513 + 361 + + + + + atomsizedataButton + clicked() + VisAtom2017Class + OnEditSizeDataButton() + + + 948 + 209 + + + 513 + 361 + + + + + VisAtom2017Class + SetVariableAtomRadiu(bool,bool) + displayWidget + SetVariableAtomRadiu(bool,bool) + + + 513 + 361 + + + 501 + 379 + + + + + actionViewport_center + triggered(bool) + VisAtom2017Class + OnActionVeiwportCenter(bool) + + + -1 + -1 + + + 513 + 361 + + + + + scalarwin0SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwinminSpinBox(double) + + + 880 + 407 + + + 513 + 361 + + + + + trajectoryOptionGroupBox + clicked(bool) + VisAtom2017Class + OnTrajectoryOptionGroupBox(bool) + + + 869 + 165 + + + 521 + 361 + + + + + VisAtom2017Class + SetGeomStyleTrajectyoryVisible(bool,int,bool) + displayWidget + SetGeomStyleTrajectyoryVisible(bool,int,bool) + + + 521 + 361 + + + 508 + 379 + + + + + shapeoptionGroupBox + clicked(bool) + VisAtom2017Class + OnShapeOptionGroupBox(bool) + + + 880 + 191 + + + 510 + 361 + + + + + VisAtom2017Class + SetGeomStyleAtomVisible(bool,int,bool) + displayWidget + SetGeomStyleAtomVisible(bool,int,bool) + + + 510 + 361 + + + 498 + 379 + + + + + trjaectoryThickSpinBox + valueChanged(double) + VisAtom2017Class + OnTrajectoryThickChanged(double) + + + 970 + 122 + + + 510 + 361 + + + + + VisAtom2017Class + SetTrajectoryThickChanged(double,bool) + displayWidget + SetTrajectoryThickChanged(double,bool) + + + 510 + 361 + + + 490 + 379 + + + + + clipthroughPosRadioButton + toggled(bool) + VisAtom2017Class + OnClipthroughPosRadioButton(bool) + + + 126 + 381 + + + 510 + 361 + + + + + clipthroughAtomRadioButton + toggled(bool) + VisAtom2017Class + OnClipthroughAtomRadioButton(bool) + + + 59 + 462 + + + 510 + 361 + + + + + clipthroughAtomSpinBox + valueChanged(int) + VisAtom2017Class + OnClipthroughAtomSpinBox(int) + + + 156 + 462 + + + 510 + 361 + + + + + resetTrajectoryDataPushButton + pressed() + VisAtom2017Class + OnResetTrajectoryDataPushButton() + + + 872 + 323 + + + 510 + 361 + + + + + scalarwin0SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwin0SpinBox(double) + + + 925 + 407 + + + 510 + 393 + + + + + scalarwin1SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwin1SpinBox(double) + + + 925 + 435 + + + 510 + 393 + + + + + scalarwin2SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwin2SpinBox(double) + + + 925 + 463 + + + 510 + 393 + + + + + scalarwin3SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwin3SpinBox(double) + + + 925 + 491 + + + 510 + 393 + + + + + scalarwin4SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwin4SpinBox(double) + + + 925 + 519 + + + 510 + 393 + + + + + scalarwin5SpinBox + valueChanged(double) + VisAtom2017Class + OnScalarwin5SpinBox(double) + + + 925 + 547 + + + 510 + 393 + + + + + VisAtom2017Class + ChangeGraphQuality(int) + displayWidget + ChangeGraphQuality(int) + + + 510 + 393 + + + 490 + 410 + + + + + VisAtom2017Class + SelectVectorStyleLine(bool) + displayWidget + OnSelectVectorStyleLine(bool) + + + 510 + 393 + + + 490 + 410 + + + + + VisAtom2017Class + SelectVectorStyleSolid(bool) + displayWidget + OnSelectVectorStyleSolid(bool) + + + 510 + 393 + + + 490 + 410 + + + + + trajectoryDataSRadioButton + toggled(bool) + VisAtom2017Class + OnTrajectoryDataSRadioButton(bool) + + + 879 + 271 + + + 510 + 393 + + + + + trajectoryDataMRadioButton + toggled(bool) + VisAtom2017Class + OnTrajectoryDataMRadioButton(bool) + + + 879 + 293 + + + 510 + 393 + + + + + boxX0SpinBox + valueChanged(double) + VisAtom2017Class + OnBoxX0Changed(double) + + + 87 + 270 + + + 449 + 393 + + + + + boxX1SpinBox + valueChanged(double) + VisAtom2017Class + OnBoxX1Changed(double) + + + 195 + 270 + + + 449 + 393 + + + + + boxY0SpinBox + valueChanged(double) + VisAtom2017Class + OnBoxY0Changed(double) + + + 87 + 298 + + + 449 + 393 + + + + + boxY1SpinBox + valueChanged(double) + VisAtom2017Class + OnBoxY1Changed(double) + + + 195 + 298 + + + 449 + 393 + + + + + boxZ0SpinBox + valueChanged(double) + VisAtom2017Class + OnBoxZ0Changed(double) + + + 87 + 326 + + + 449 + 393 + + + + + boxZ1SpinBox + valueChanged(double) + VisAtom2017Class + OnBoxZ1Changed(double) + + + 195 + 326 + + + 449 + 393 + + + + + autoboxpos_checkBox + toggled(bool) + VisAtom2017Class + OnBoxAutoPostion(bool) + + + 126 + 245 + + + 449 + 393 + + + + + actionCluster_envelope + triggered() + VisAtom2017Class + OnClusterEvelope() + + + -1 + -1 + + + 449 + 393 + + + + + VisAtom2017Class + OpenExtendedObject(VisAtomExtendObject*,QString) + displayWidget + OnOpenExtendedObject(VisAtomExtendObject*,QString) + + + 449 + 393 + + + 429 + 410 + + + + + subsampleListTreeWidget + itemDoubleClicked(QTreeWidgetItem*,int) + VisAtom2017Class + OnSubsampleListTreeItemDBClick(QTreeWidgetItem*,int) + + + 749 + 703 + + + 449 + 393 + + + + + projectPerspective + clicked() + displayWidget + OnProjecttypePerspect() + + + 65 + 451 + + + 584 + 372 + + + + + projectOrtho + clicked() + displayWidget + OnProjecttypeOrtho() + + + 47 + 429 + + + 584 + 372 + + + + + boxDisplayTreeWidget + itemChanged(QTreeWidgetItem*,int) + displayWidget + OnBoxDisplayOption(QTreeWidgetItem*) + + + 148 + 161 + + + 564 + 398 + + + + + newClipDirPushButton + clicked() + VisAtom2017Class + OnNewClipDirPushButton() + + + 84 + 243 + + + 565 + 380 + + + + + clipDirComboBox + currentIndexChanged(int) + VisAtom2017Class + OnClipDirComboBoxIndexChanged(int) + + + 196 + 242 + + + 565 + 380 + + + + + clipAnyDirEnablecheckBox + clicked(bool) + VisAtom2017Class + OnClipDirCheckBoxChanged(bool) + + + 266 + 242 + + + 565 + 380 + + + + + actionSubsample_filter + triggered(bool) + VisAtom2017Class + OnActionSubsample_filter(bool) + + + -1 + -1 + + + 613 + 380 + + + + + actionFind_atoms + triggered() + VisAtom2017Class + OnActionFindatom() + + + -1 + -1 + + + 613 + 380 + + + + + + SetMouseAction(int) + SetSceneDistance(int,int) + SetAtomRadiu(int,int,bool) + SetAtomShape(int,bool) + SetGeomStyleVectorVisible(bool,int,bool) + SetVariableAtomRadiu(bool,bool) + SetGeomStyleTrajectyoryVisible(bool,int,bool) + SetGeomStyleAtomVisible(bool,int,bool) + SetTrajectoryThickChanged(double,bool) + ChangeGraphQuality(int) + SelectVectorStyleSolid(bool) + SelectVectorStyleLine(bool) + OpenExtendedObject(VisAtomExtendObject*,QString) + OnFileOpen() + OnSelectRotationX() + OnSelectRotationY() + OnSelectRotationZ() + OnSelectZoomScene() + OnChangeSceneBackground() + OnChangeSceneDistance() + OnChangeAtomRadiu() + OnAboutVisatom2013() + OnSelectSceneStyle(QListWidgetItem*,QListWidgetItem*) + OnClipEnabled() + OnActionRotateX(bool) + OnActionRotateY(bool) + OnActionRotateZ(bool) + OnActionZoomview(bool) + OnSelectSubsample(QTreeWidgetItem*) + OnSubsampleListItemChanged(QTreeWidgetItem*) + OnChangeAtomColor() + OnChangeAtomShapeDot(bool) + OnChangeAtomShapeCircle(bool) + OnChangeAtomShapeWireSphere(bool) + OnChangeAtomShapeSolidSphere(bool) + OnNewColorPolicy() + OnSingleColorRadioButton(bool) + OnMappingColorRadioButton(bool) + OnSaveImage() + OnActionCopyImage() + OnScalarminSlider(int) + OnScalarmaxSlider(int) + OnNewVectorPolicy() + OnVectorOptionGroupBox(bool) + OnFileNext() + OnFilePrev() + OnShowSceneOperation(bool) + OnShowSubsampleOption(bool) + OnShowSubsampleBrowser(bool) + OnCloseSceneOperation(bool) + OnCloseSubsampleOption(bool) + OnCloseSubsampleBrowser(bool) + OnUnifiedAtomSize(bool) + OnVariableAtomSize(bool) + OnEditSizeDataButton() + OnActionVeiwportCenter(bool) + OnNormalizeView() + OnTrajectoryOptionGroupBox(bool) + OnShapeOptionGroupBox(bool) + OnTrajectoryThickChanged(double) + OnClipthroughPosRadioButton(bool) + OnClipthroughAtomRadioButton(bool) + OnClipthroughAtomSpinBox(int) + OnResetTrajectoryDataPushButton() + OnScalarwin0SpinBox(double) + OnScalarwin1SpinBox(double) + OnScalarwin2SpinBox(double) + OnScalarwin3SpinBox(double) + OnScalarwin4SpinBox(double) + OnScalarwin5SpinBox(double) + OnChangeGraphQuality(int) + OnSelectVectorStyleLine(bool) + OnSelectVectorStyleSolid(bool) + OnTrajectoryDataSRadioButton(bool) + OnTrajectoryDataMRadioButton(bool) + OnBoxX0Changed(double) + OnBoxX1Changed(double) + OnBoxY0Changed(double) + OnBoxY1Changed(double) + OnBoxZ0Changed(double) + OnBoxZ1Changed(double) + OnBoxAutoPostion(bool) + OnClusterEvelope() + OnSubsampleListTreeItemDBClick(QTreeWidgetItem*,int) + OnNewClipDirPushButton() + OnClipDirComboBoxIndexChanged(int) + OnClipDirCheckBoxChanged(bool) + OnActionSubsample_filter(bool) + OnActionFindatom() + OnFindatomchanged() + +
diff --git a/VisAtom2017/VisAtom2017.vcxproj b/VisAtom2017/VisAtom2017.vcxproj new file mode 100644 index 0000000..2e4a070 --- /dev/null +++ b/VisAtom2017/VisAtom2017.vcxproj @@ -0,0 +1,240 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {B12702AD-ABFB-343A-A199-8E24837244A3} + Qt4VSv1.0 + 10.0.14393.0 + + + + Application + v141 + + + Application + v141 + + + + + true + UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_OPENGLEXTENSIONS_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtOpenGLExtensions;$(QTDIR)\include\QtWidgets;..\VISATOMSRC;..\GLLIBSRC;%(AdditionalIncludeDirectories) + + MultiThreadedDLL + true + false + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5OpenGL.lib;opengl32.lib;glu32.lib;Qt5OpenGLExtensions.lib;Qt5Widgets.lib;%(AdditionalDependencies) + + + %(FullPath) + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + output + Moc'ing %(Identity)... + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtOpenGLExtensions;$(QTDIR)\include\QtWidgets;.\..\VISATOMSRC;.\..\GLLIBSRC + UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_OPENGLEXTENSIONS_LIB;QT_WIDGETS_LIB + $(QTDIR) + + + Uic'ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h + false + + + Rcc'ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp + + + + $(MSBuildProjectDirectory)\QtMsBuild + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + + + + + + + + + + + + + + + + UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_OPENGLEXTENSIONS_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtOpenGLExtensions;$(QTDIR)\include\QtWidgets;..\VISATOMSRC;..\GLLIBSRC;..\GLLIBSRC;..\VISATOMSRC;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + true + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5OpenGLd.lib;opengl32.lib;glu32.lib;Qt5OpenGLExtensionsd.lib;Qt5Widgetsd.lib;%(AdditionalDependencies) + + + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + Moc'ing %(Identity)... + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtOpenGL;$(QTDIR)\include\QtOpenGLExtensions;$(QTDIR)\include\QtWidgets;.\..\VISATOMSRC;.\..\GLLIBSRC + UNICODE;_UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_OPENGLEXTENSIONS_LIB;QT_WIDGETS_LIB + + + Uic'ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h + + + Rcc'ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisAtom2017/VisAtom2017.vcxproj.filters b/VisAtom2017/VisAtom2017.vcxproj.filters new file mode 100644 index 0000000..cf3ab47 --- /dev/null +++ b/VisAtom2017/VisAtom2017.vcxproj.filters @@ -0,0 +1,279 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + Form Files + + + + + Resource Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file diff --git a/VisAtom2017/VisAtom2017.vcxproj.user b/VisAtom2017/VisAtom2017.vcxproj.user new file mode 100644 index 0000000..c7086de --- /dev/null +++ b/VisAtom2017/VisAtom2017.vcxproj.user @@ -0,0 +1,12 @@ + + + + + C:\Qt\Qt5.10.1\5.10.1\msvc2017_64 + PATH=$(QTDIR)\bin%3b$(PATH) + + + C:\Qt\Qt5.10.1\5.10.1\msvc2017_64 + PATH=$(QTDIR)\bin%3b$(PATH) + + \ No newline at end of file diff --git a/VisAtom2017/VisAtom20171.rc b/VisAtom2017/VisAtom20171.rc new file mode 100644 index 0000000..0cb84c3 Binary files /dev/null and b/VisAtom2017/VisAtom20171.rc differ diff --git a/VisAtom2017/VisAtoms21.ico b/VisAtom2017/VisAtoms21.ico new file mode 100644 index 0000000..9c9fe45 Binary files /dev/null and b/VisAtom2017/VisAtoms21.ico differ diff --git a/VisAtom2017/VisAtomwidget.cpp b/VisAtom2017/VisAtomwidget.cpp new file mode 100644 index 0000000..791cf56 --- /dev/null +++ b/VisAtom2017/VisAtomwidget.cpp @@ -0,0 +1,1392 @@ + +#include +#include +#include + +#include "Scene.h" +#include "Sphere.h" +#include "Circle.h" +#include "SolidCircle.h" +#include "Bitmap.h" +#include "Arrow.h" +#include "VisAtomwidget.h" +#include "VisAtomCliper.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtom_NewVectorPolicyDlg.h" +#include "visatom_atominfo.h" +#include "VisAtomTrajectory.h" +#include "VisAtomExtendObject.h" + +#define COLORMAPBARSZIEX 32 +#define COLORMAPBARSZIEY 480 +#define COORDSYSVIEWSIZE 148 + +VisAtomWidget::VisAtomWidget(QWidget *parent) + : QGLWidget(parent) +{ + int i; + m_Scene = new Scene(); + m_ColorbarView = new Scene(); + m_Sample = new VisAtomSample(); + + //default action options for scene + m_AutoNormalizingView = true; + m_MouseAction = ACTION_ZOOM_SCENE; + m_MouseState = BUTTON_RELEASED; + + //clipping + //m_Cliper = new VisAtomCliper*[VisAtomCliper::CLIPPING_STYLE_NUM]; + m_pCliper = new QList[VisAtomCliper::CLIPPING_STYLE_NUM]; + for(i=0; iAttachScene(m_Scene); + pCliper->SetStyle(i); + if (i == VisAtomCliper::CLIPPING_STYLE_ANYDIR) pCliper->EnableClip(); + m_pCliper[i].append(pCliper); + } + m_curCliperStyle = 0; + m_curCliper = m_pCliper[m_curCliperStyle][0]; + m_Sample->SetCliper(m_pCliper[m_curCliperStyle]); + + //default display options for scene + m_Backgroud[0] = m_Backgroud[1] = m_Backgroud[2] = 1.f; + m_Backgroud[3] = 1.f; + + //invoke a timer + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(OnTimerout())); + m_Timestep = 300; + timer->start(m_Timestep); + + //for picked atom infomation + m_pickedAtomInfo = new VisAtom_AtomInfo(); + m_pickedAtomInfo->setVisible(false); + + //for atom trajectory + m_Trajectory = new VisAtomTrajectory(); + m_Trajectory->AttachSample(m_Sample); + m_Sample->AttachTrajectory(m_Trajectory); + +} + +VisAtomWidget::~VisAtomWidget() +{ + makeCurrent(); + int i,j,nc; + if(m_Scene) delete m_Scene; m_Scene=NULL; + if(m_Sample) delete m_Sample; m_Sample=NULL; + for(i=0; im_pCliper[i].size(); + for (j = 0; j < nc; j++) + { + VisAtomCliper*pCliper = this->m_pCliper[i][j]; + delete pCliper; + } + this->m_pCliper[i].clear(); + } + if(m_pickedAtomInfo) delete m_pickedAtomInfo; m_pickedAtomInfo= NULL; + if(m_Trajectory) delete m_Trajectory; m_Trajectory= NULL; + +} + +void VisAtomWidget::SetSampleDataSheet(VisAtomDataSheet*pData, BOOL redraw) +{ + //Update the data + if(m_Sample) m_Sample-> SetDataSheet(pData); + + if(this->m_AutoNormalizingView) + this->NormalizingView(); + + if(redraw) this->updateGL(); +} + +void VisAtomWidget::NormalizingView() +{ + makeCurrent(); + //to atutomatically normalize the view + float left, right,top, bottom,nearz, farz, z0; + m_Sample->GetSampleBoxRangeX(left, right); + m_Sample->GetSampleBoxRangeY(bottom, top); + m_Sample->GetSampleBoxRangeZ(nearz, farz); + + z0 = std::max(fabs(nearz), fabs(farz)); + farz = z0; + nearz = -z0; + + m_Scene->CreateScene(left, right, bottom, top, nearz, farz); + + //to update the projection box size + if(VisAtomVisualizingPolicy::IsAutoProjectionBox()) + { + VisAtomVisualizingPolicy::SetProjectionBox(left, right, bottom, top, nearz, farz); + } + + return; +} + +void VisAtomWidget::FitGraphView() +{ + makeCurrent(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + this->m_Scene->ChangeZoomScale(1.f); + this->updateGL(); +} + +void VisAtomWidget::SelectMouseAction(int action) +{ + this->m_MouseAction = action; +} + + +void VisAtomWidget::initializeGL() +{ + m_Scene->CreateScene(); + m_Scene->TurnLighton(1); + m_Scene->TurnLighton(2); + m_Scene->TurnLighton(3); +} + +void VisAtomWidget::paintEvent(QPaintEvent *event) +{ + QGLWidget::paintEvent(event); + return; +} + +void VisAtomWidget::hideEvent(QHideEvent *event) +{ + if (this->m_pickedAtomInfo)this->m_pickedAtomInfo->hide(); + return; +} + +void VisAtomWidget::paintGL() +{ + + int i; + glClearColor(m_Backgroud[0],m_Backgroud[1], m_Backgroud[2], m_Backgroud[3]); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + this->m_Scene->MakeCurrent(); + for (i = 0; i < this->m_pCliper[m_curCliperStyle].size(); i++) + { + if (this->m_pCliper[m_curCliperStyle][i]->IsEnabledClip()) + this->m_pCliper[m_curCliperStyle][i]->PaintEdge(); + } + + // draw the sample + this->m_Sample->Paint(); + for(i=0; im_ExtObjs.size(); i++) + { + this->m_ExtObjs[i]->Paint(); + } + //if there are selected atom, draw them + this->m_Sample->HighlightFoundAtoms(); + this->m_Sample->HighlightSelectedAtoms(); + + + //this->m_Trajectory->Paint(); + //delete this later + //this->m_Sample->DrawWignerSeizVolume("..\\HE32000_2_a\\VTDATA__V_P0000_0001.0000"); + for (i = 0; i < this->m_pCliper[m_curCliperStyle].size(); i++) + { + if(this->m_pCliper[m_curCliperStyle][i]->IsEnabledClip()) + this->m_pCliper[m_curCliperStyle][i]->PaintFace(); + } + this->m_Scene->Paint(); + + + //draw 2D colormap bar + for( i=0; im_Sample->NumberofSubsample(); i++) + { + VisAtomVisualizingPolicy*p = this->m_Sample->GetSubsample(i)->GetCurVisualPolicy(); + if(p->GetColorStyle() == VisAtomVisualizingPolicy::COLOR_STYLE_MAP) + { + int x0, y0, w0, h0; + int x1, y1, w1, h1; + int x, y; + int lablepos[VisAtomVisualizingPolicy::CORLOR_MAP_SIZE]; + QFont font("arial", 9); + QFontMetrics metrics = QFontMetrics(font); + QRect rect; + QString label; + + this->m_ColorbarView->GetViewport(x1, y1, w1, h1); + this->m_ColorbarView->MakeCurrent(); + this->m_Sample->DrawColorMappinBar(lablepos); + + this->m_Scene->GetViewport(x0, y0, w0, h0); + this->m_Scene->MakeCurrent(); + glColor3f(1.f-m_Backgroud[0], 1.f-m_Backgroud[1], 1.f-m_Backgroud[2]); + for(int i= VisAtomVisualizingPolicy::GetColorMappingNumBar()-1; i>=0; i--) + { + label.setNum(VisAtomVisualizingPolicy::GetScalarMappingTabValue(i), 'e', 2); + rect = metrics.boundingRect(label); + x = x1 - rect.width()-2; + y = h0 - lablepos[i]; // +0.5*rect.height(); // h0 - y1 - i * step + 0.5*rect.height(); + this->renderText (x, y, label, font); + } + break; + } + } + + //draw coordinate axsis in a small viewport + /*{ + int x0, y0, w, h; + this->m_Scene->GetViewport( x0, y0, w, h); + if(w>h) + glViewport(0, 0, COORDSYSVIEWSIZE, COORDSYSVIEWSIZE*(float)h/(float)w); + else + glViewport(0, 0, COORDSYSVIEWSIZE*(float)w/(float)h, COORDSYSVIEWSIZE); + + glDisable(GL_DEPTH_TEST); + Arrow aX(0.f, 0.f, 0.f, 1.f, 0.f, 0.f); + Arrow aY(0.f, 0.f, 0.f, 0.f, 1.f, 0.f); + Arrow aZ(0.f, 0.f, 0.f, 0.f, 0.f, 1.f); + float scal = this->m_Scene->CurrentZoomScale(); + float sx = this->m_Scene->GetVolumeX1()*0.8/scal; + float sy = this->m_Scene->GetVolumeY1()*0.8/scal; + float sz = this->m_Scene->GetVolumeZ1()*0.8/scal; + //use the same length and size for axsis + aX.ResetEndPoint(sx, 0.f, 0.f); + aY.ResetEndPoint(0.f, sx, 0.f); + aZ.ResetEndPoint(0.f, 0.f, sx); + aX.ChangeSize(0.15f*sx); + aY.ChangeSize(0.15f*sx); + aZ.ChangeSize(0.15f*sx); + aX.ChangeColor(1.f, 0.f, 0.f); + aY.ChangeColor(0.f, 1.f, 0.f); + aZ.ChangeColor(0.f, 0.f, 1.f); + glPushMatrix(); + this->m_Scene->TransDevice(); + aX.Paint(); + aY.Paint(); + aZ.Paint(); + glPopMatrix(); + }*/ + + //restore the viewport to 3D render + this->m_Scene->MakeCurrent(); + + //draw the cover + if(!this->m_Sample->GetDataSheet()) + { + qglColor(QColor(255*(1-m_Backgroud[0]), 255*(1-m_Backgroud[1]), 255*(1-m_Backgroud[2]))); + int x = 32; + int y = 100; + QFont font("times", 26); + QFontMetrics metrics = QFontMetrics(font); + QString str("Welcome to VisAtom2017"); + this->renderText (x, y, str, font) ; + y = y + metrics.height()*1.5; + QFont font1("times", 16); + QFontMetrics metrics1 = QFontMetrics(font1); + str = "HOU, Qing" ; + this->renderText (x, y, str, font1) ; + y = y + metrics1.height()*1.5; + str = "Key Lab for Radiation Physics and Technology"; + this->renderText (x, y, str, font1) ; + y = y + metrics1.height()*1.5; + str = "Institute of Nuclear Science and Technology"; + this->renderText (x, y, str, font1) ; + y = y + metrics1.height()*1.5; + str = "Sichuan University"; + this->renderText (x, y, str, font1) ; + } +} + +void VisAtomWidget::RenderToPixmap(QPixmap&pixmap) +{ + QSize s = this->size(); + pixmap = this->renderPixmap(s.width(), s.height()); + + +} + +void VisAtomWidget::RenderToBitmap(Bitmap&bitmap) +{ + //this->makeCurrent(); + this->updateGL(); + + int x0, y0, w0, h0; + this->m_Scene->GetViewport( x0, y0, w0, h0); + bitmap.ReadFromViewport(x0, y0, w0,h0); + return; +} + +void VisAtomWidget::resizeGL(int width, int height) +{ + //To store the old rotation matrix + this->makeCurrent(); + + if(height == 0) height = 1; + if(width == 0) width = 1; + //create the main scene for 3D redering + m_Scene->SetViewport(0, 0, width, height); + m_Scene->MakeCurrent(); + m_Scene->CreateScene(); + m_Scene->TurnLighton(1); + m_Scene->TurnLighton(2); + m_Scene->TurnLighton(3); + + int clipState = m_Scene->IsClipPlaneEnabled(1); + m_Scene->Response(action_Object_Clipx); + m_Scene->Response(action_Object_ClipDP); + if( clipState ==2) + m_Scene->Response(action_Object_ClipEP); + else + if(clipState == 1) m_Scene->Response(action_Object_ClipE); + + clipState = m_Scene->IsClipPlaneEnabled(2); + m_Scene->Response(action_Object_Clipy); + m_Scene->Response(action_Object_ClipDP); + if( clipState ==2) + m_Scene->Response(action_Object_ClipEP); + else + if(clipState == 1) m_Scene->Response(action_Object_ClipE); + + clipState = m_Scene->IsClipPlaneEnabled(3); + m_Scene->Response(action_Object_Clipz); + m_Scene->Response(action_Object_ClipDP); + if( clipState ==2) + m_Scene->Response(action_Object_ClipEP); + else + if(clipState == 1) m_Scene->Response(action_Object_ClipE); + + //create the AUX scene for 2D redering + this->m_ColorbarView->SetViewport(width-COLORMAPBARSZIEX-16, (height-COLORMAPBARSZIEY)/2, COLORMAPBARSZIEX, COLORMAPBARSZIEY); + this->m_Scene->MakeCurrent(); + return; +} + + +void VisAtomWidget::mousePressEvent(QMouseEvent *event) +{ + this->makeCurrent(); + if(event->buttons() & Qt::LeftButton) this->m_MouseState = LBUTTON_PRESSED; + else if(event->buttons() & Qt::RightButton) this->m_MouseState = RBUTTON_PRESSED; + + int pickedatom; + pickedatom = -1; + if( QApplication::queryKeyboardModifiers() == Qt::ControlModifier) + { + if (!this->m_pickedAtomInfo->isVisible()) + { + //to pick the atom + this->m_pickedAtomInfo->StartPickAtomInfo(event->globalX(), event->globalY()); + float curX, curY, curZ; + this->m_Sample->PickAtom(event->pos().x(), event->pos().y(), this->m_Scene, &curX, &curY, &curZ); + pickedatom = this->m_Sample->GetCurAtom(); + this->m_pickedAtomInfo->ShowAtomInfo(event->globalX(), event->globalY(), this->m_Sample, pickedatom); + } + /* else + { + this->m_pickedAtomInfo->hide(); + this->m_Sample->unSelect_aAtom(); + }*/ + + } + else + { + if (!this->m_pickedAtomInfo->isVisible()) + { + switch (this->m_MouseAction) + { + case this->ACTION_ROTATION_X: + case this->ACTION_ROTATION_Y: + case this->ACTION_ROTATION_Z: + case this->ACTION_ZOOM_SCENE: + this->ProcessCurrentAction(); + break; + case this->ACTION_VIEWPORT_CENTER: + { + if (this->m_MouseState == LBUTTON_PRESSED) + this->m_Scene->TransDevice(event->x(), event->y()); + + if (this->m_MouseState == RBUTTON_PRESSED) + this->m_Scene->TransDevice(); + break; + } + } + } + else + { + this->m_pickedAtomInfo->hide(); + this->m_Sample->unSelect_aAtom(); + } + } + + this->updateGL(); +} + +void VisAtomWidget::ProcessCurrentAction() +{ + int keystate = QApplication::queryKeyboardModifiers(); + + switch(this->m_MouseAction) + { + case this->ACTION_ROTATION_X: + if(keystate == Qt::ShiftModifier) + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateX(90.f); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateX(-90.f); + } + else + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateXf(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateXb(); + } + break; + case this->ACTION_ROTATION_Y: + if(keystate == Qt::ShiftModifier) + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateY(90.f); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateY(-90.f); + } + else + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateYf(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateYb(); + } + break; + case this->ACTION_ROTATION_Z: + if(keystate == Qt::ShiftModifier) + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateZ(90.f); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateZ(-90.f); + } + else + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateZf(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateZb(); + } + break; + case this->ACTION_ZOOM_SCENE: + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->ZoomIn(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->ZoomOut(); + break; + } + +} + +void VisAtomWidget::mouseReleaseEvent ( QMouseEvent * event ) +{ + this->m_MouseState = BUTTON_RELEASED; + if (QApplication::queryKeyboardModifiers() == Qt::ControlModifier) + { + this->m_pickedAtomInfo->hide(); + this->m_Sample->unSelect_aAtom(); + } + +} + +void VisAtomWidget::mouseMoveEvent(QMouseEvent *event) +{ + int dx = event->x() - lastPos.x(); + int dy = event->y() - lastPos.y(); + + /*if (event->buttons() & Qt::LeftButton) { + setXRotation(xRot + 8 * dy); + setYRotation(yRot + 8 * dx); + } else if (event->buttons() & Qt::RightButton) { + setXRotation(xRot + 8 * dy); + setZRotation(zRot + 8 * dx); + }*/ + lastPos = event->pos(); +} + +#define RGBSIZE 255 +void VisAtomWidget::OnChangeSceneBackground() +{ + int R = m_Backgroud[0]*RGBSIZE; + int G = m_Backgroud[1]*RGBSIZE; + int B = m_Backgroud[2]*RGBSIZE; + int A = m_Backgroud[3]*RGBSIZE; + QColorDialog colorsel(QColor(R, G, B, A), this); + + if(colorsel.exec()) + { + + QColor color = colorsel.currentColor(); + color.getRgb(&R, &G, &B, &A); + m_Backgroud[0] = R/float(RGBSIZE); + m_Backgroud[1] = G/float(RGBSIZE); + m_Backgroud[2] = B/float(RGBSIZE); + m_Backgroud[3] = A/float(RGBSIZE); + this->makeCurrent(); + glClearColor(m_Backgroud[0],m_Backgroud[1], m_Backgroud[2], m_Backgroud[3]); + this->updateGL(); + } +} + +void VisAtomWidget:: OnProjecttypeOrtho() +{ + this->makeCurrent(); + this->m_Scene->SetAsOrtho(); + this->m_Scene->CreateScene(); + this->updateGL(); + +} +void VisAtomWidget::OnProjecttypePerspect() +{ + this->makeCurrent(); + this->m_Scene->SetAsPerspective(); + this->m_Scene->CreateScene(); + this->updateGL(); +} +void VisAtomWidget::SetSceneDistance(int range, int value) +{ + this->makeCurrent(); + float inc = 4.0*(this->m_Scene->GetVolumeZ1()-this->m_Scene->GetVolumeZ0())/float(range); + float dist = value*inc; + + this->m_Scene->SetDistance(dist); + this->m_Scene->CreateScene(); + this->updateGL(); +} + +void VisAtomWidget::OnBoxDisplayOption(QTreeWidgetItem*item) +{ + QString tname = item->text(0); + int checked1 = item->checkState(1); + int checked2 = item->checkState(2); + int style = 0; + if (checked1) style = style + 1; + if (checked2) style = style + 2; + + if (tname == tr("X-Y back")) + { + this->m_Scene->ShowBackfaceZ(style); + } + else if (tname == tr("Y-Z back")) + { + this->m_Scene->ShowBackfaceX(style); + } + else if (tname == tr("Z-X back")) + { + this->m_Scene->ShowBackfaceY(style); + } + else if (tname == tr("X-Y front")) + { + this->m_Scene->ShowFrontfaceZ(style); + } + else if (tname == tr("Y-Z front")) + { + this->m_Scene->ShowFrontfaceX(style); + } + else if (tname == tr("Z-X front")) + { + this->m_Scene->ShowFrontfaceY(style); + } + this->updateGL(); + return; +} +void VisAtomWidget::OnShowSceneBox(int show) +{ + this->m_Scene->ShowBoxBorder(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneBackfaceX(int show) +{ + this->m_Scene->ShowBackfaceX(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneBackfaceY(int show) +{ + this->m_Scene->ShowBackfaceY(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneBackfaceZ(int show) +{ + this->m_Scene->ShowBackfaceZ(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneFrontfaceX(int show) +{ + this->m_Scene->ShowFrontfaceX(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneFrontfaceY(int show) +{ + this->m_Scene->ShowFrontfaceY(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneFrontfaceZ(int show) +{ + this->m_Scene->ShowFrontfaceZ(show); + this->updateGL(); +} + +VisAtomCliper* VisAtomWidget::NewCliper() +{ + if (this->m_curCliper->GetStyle() == VisAtomCliper::CLIPPING_STYLE_ANYDIR) + { + VisAtomCliper*pCliper = new VisAtomCliper(); + pCliper->SetStyle(VisAtomCliper::CLIPPING_STYLE_ANYDIR); + pCliper->AttachScene(this->m_Scene); + this->m_pCliper[VisAtomCliper::CLIPPING_STYLE_ANYDIR].append(pCliper); + this->m_curCliper = pCliper; + this->m_Sample->AddCliper(pCliper); + return pCliper; + } + else + { + return NULL; + } +} + +VisAtomCliper* VisAtomWidget::SetCurrentClipper(int index) +{ + switch (m_curCliper->GetStyle()) + { + case VisAtomCliper::CLIPPING_STYLE_AND: + case VisAtomCliper::CLIPPING_STYLE_OR: + break; + case VisAtomCliper::CLIPPING_STYLE_ANYDIR: + + m_curCliper = this->m_pCliper[VisAtomCliper::CLIPPING_STYLE_ANYDIR][index]; + } + return m_curCliper; +}; + +void VisAtomWidget::SetCurrentCliperParameters(VisAtomCliper*sor) +{ + int style = sor->GetStyle(); + //note: style is the index of m_pCliper in VisAtomWidget class + this->m_curCliper->SetParameters(sor); + this->m_Sample->ResetVisibility(); + this->updateGL(); +} + +void VisAtomWidget::SetCurrentClipperStyle(int curstyle, bool redraw) +{ + if (curstyle == this->m_curCliperStyle) + { + return; + } + this->m_curCliperStyle = curstyle; + this->m_curCliper = this->m_pCliper[curstyle][0]; + this->m_Sample->SetCliper(this->m_pCliper[curstyle]); + if(redraw) this->updateGL(); +} + +void VisAtomWidget::OnClipXBack() +{ + VisAtomCliper*p = this->CurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipX()) pos[0] = pos[0]+step[0]; + else pos[0] = pos[0]-step[0]; + + //to prevent the sample moving out ofbox + if(pos[0] < p->GetAttachedScene()->GetVolumeX0()) + pos[0] = p->GetAttachedScene()->GetVolumeX0(); + + if(pos[0] > p->GetAttachedScene()->GetVolumeX1()) + pos[0] = p->GetAttachedScene()->GetVolumeX1(); + + p->SetClipPos(pos); + this->m_Sample->SetCliper(this->m_pCliper[this->m_curCliperStyle]); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipXForward() +{ + VisAtomCliper*p = this->CurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipX()) pos[0] = pos[0]-step[0]; + else pos[0] = pos[0]+step[0]; + + //to prevent the sample moving out ofbox + if(pos[0] < p->GetAttachedScene()->GetVolumeX0()) + pos[0] = p->GetAttachedScene()->GetVolumeX0(); + + if(pos[0] > p->GetAttachedScene()->GetVolumeX1()) + pos[0] = p->GetAttachedScene()->GetVolumeX1(); + + p->SetClipPos(pos); + this->m_Sample->SetCliper(this->m_pCliper[this->m_curCliperStyle]); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipYBack() +{ + VisAtomCliper*p = this->CurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipY()) pos[1] = pos[1]+step[1]; + else pos[1] = pos[1]-step[1]; + + //to prevent the sample moving out ofbox + if(pos[1] < p->GetAttachedScene()->GetVolumeY0()) + pos[1] = p->GetAttachedScene()->GetVolumeY0(); + + if(pos[1] > p->GetAttachedScene()->GetVolumeY1()) + pos[1] = p->GetAttachedScene()->GetVolumeY1(); + + + p->SetClipPos(pos); + this->m_Sample->SetCliper(this->m_pCliper[this->m_curCliperStyle]); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipYForward() +{ + VisAtomCliper*p = this->CurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipY()) pos[1] = pos[1]-step[1]; + else pos[1] = pos[1]+step[1]; + + //to prevent the sample moving out ofbox + if(pos[1] < p->GetAttachedScene()->GetVolumeY0()) + pos[1] = p->GetAttachedScene()->GetVolumeY0(); + + if(pos[1] > p->GetAttachedScene()->GetVolumeY1()) + pos[1] = p->GetAttachedScene()->GetVolumeY1(); + + p->SetClipPos(pos); + this->m_Sample->SetCliper(this->m_pCliper[this->m_curCliperStyle]); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipZBack() +{ + VisAtomCliper*p = this->CurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipZ()) pos[2] = pos[2]+step[2]; + else pos[2] = pos[2]-step[2]; + + //to prevent the sample moving out ofbox + if(pos[2] < p->GetAttachedScene()->GetVolumeZ0()) + pos[2] = p->GetAttachedScene()->GetVolumeZ0(); + + if(pos[2] > p->GetAttachedScene()->GetVolumeZ1()) + pos[2] = p->GetAttachedScene()->GetVolumeZ1(); + + + p->SetClipPos(pos); + this->m_Sample->SetCliper(this->m_pCliper[this->m_curCliperStyle]); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipZForward() +{ + VisAtomCliper*p = this->CurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipZ()) pos[2] = pos[2]-step[2]; + else pos[2] = pos[2]+step[2]; + + + //to prevent the sample moving out ofbox + if(pos[2] < p->GetAttachedScene()->GetVolumeZ0()) + pos[2] = p->GetAttachedScene()->GetVolumeZ0(); + + if(pos[2] > p->GetAttachedScene()->GetVolumeZ1()) + pos[2] = p->GetAttachedScene()->GetVolumeZ1(); + + + p->SetClipPos(pos); + this->m_Sample->SetCliper(this->m_pCliper[this->m_curCliperStyle]); + this->updateGL(); + return; +} + +void VisAtomWidget::OnShowClipANYDIRFrontface(bool show) +{ + VisAtomCliper*p = this->CurrentClipper(); + p->ShowFronFace(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowClipANYDIRBackface(bool show) +{ + VisAtomCliper*p = this->CurrentClipper(); + p->ShowBackFace(show); + this->updateGL(); +} + + +void VisAtomWidget::OnCoordinatBody() +{ + this->m_Scene->SetAsRelativeSystem(); +} + +void VisAtomWidget::OnCoordinatLab() +{ + this->m_Scene->SetAsLaboratorySystem(); +} + + +void VisAtomWidget::OnTimerout() +{ + return; + if(this->m_pickedAtomInfo->isVisible()) return; + + if(this->m_MouseState == LBUTTON_PRESSED || this->m_MouseState == RBUTTON_PRESSED) + { + this->makeCurrent(); + this->ProcessCurrentAction(); + this->updateGL(); + } +} + + +void VisAtomWidget::OnSelectShapeDot(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_DOT, false); +} + +void VisAtomWidget::OnSelectShapeSolidSphere(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_SOLID, false); +} + +void VisAtomWidget::OnSelectShapeWireSphere(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE, false); +} + +void VisAtomWidget::OnSelectShapeCircle(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_LINE, false); +} + + +void VisAtomWidget::OnChangeAtomColor() +{ + int i; + + int R = 1.0*RGBSIZE; + int G = 1.0*RGBSIZE; + int B = 1.0*RGBSIZE; + int A = 1.0*RGBSIZE; + + QColorDialog colorsel(QColor(R, G, B, A), this); + + if(colorsel.exec()) + { + + QColor color = colorsel.currentColor(); + color.getRgb(&R, &G, &B, &A); + + this->m_Sample->SetColorForCurrentSubsample(R/float(RGBSIZE), G/float(RGBSIZE), B/float(RGBSIZE)); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL(); + } +} + +void VisAtomWidget::SetAtomRadiu(int range, int value, bool all) +{ + float ratio = (float)value/(float)range; + + float ds = this->m_Scene->GetVolumeX1() - this->m_Scene->GetVolumeX0(); + if(ds > this->m_Scene->GetVolumeY1() - this->m_Scene->GetVolumeY0()) + ds = this->m_Scene->GetVolumeY1() - this->m_Scene->GetVolumeY0(); + if(ds > this->m_Scene->GetVolumeZ1() - this->m_Scene->GetVolumeZ0()) + ds = this->m_Scene->GetVolumeZ1() - this->m_Scene->GetVolumeZ0(); + ds = (ds/4.0)*ratio; + + float rad; + VisAtomSubSample*sub = this->m_Sample->GetCurrentSubsample(); + sub->GetCurAtomSize(rad); + + if(abs(ds-rad) >0.00001) + { + if(!all) + { + /*sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp();*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomSize(ds, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomSize(ds, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + } +} + +void VisAtomWidget::SetVariableAtomRadiu(bool variable,bool all) +{ + VisAtomSubSample*sub = this->m_Sample->GetCurrentSubsample(); + + if(!all) + { + /*sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp();*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomHaveUnifiedSize(!variable, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomHaveUnifiedSize(!variable, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + return; +} + + +//************************************************************************************************** +void VisAtomWidget::SetAtomShape(int shape, bool all) +{ + VisAtomVisualizingPolicy*policy; + + if(!all) + { + /*VisAtomSubSample*sub = this->m_Sample->GetCurrentSubsample(); + policy = sub->GetCurVisualPolicy(); + int ageom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK; + if(ageom != shape) + { + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL(); + }*/ + bool changed = false; + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*sub = this->m_Sample->GetSubsample(i); + policy = sub->GetCurVisualPolicy(); + int ageom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK; + if(ageom != shape) + { + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = true; + } + } + } + if(changed) this->updateGL(); + } + else + { + bool changed = false; + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + VisAtomSubSample*sub = this->m_Sample->GetSubsample(i); + policy = sub->GetCurVisualPolicy(); + int ageom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK; + if(ageom != shape) + { + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = true; + } + } + if(changed) this->updateGL(); + } + return; +} + +//************************************************************************************************** +void VisAtomWidget::OnRotationXStep(int step) +{ + this->m_Scene->ChangeRotationStepx((float)step); +} + +//************************************************************************************************** +void VisAtomWidget::OnRotationYStep(int step) +{ + this->m_Scene->ChangeRotationStepy((float)step); + +} + +//************************************************************************************************** +void VisAtomWidget::OnRotationZStep(int step) +{ + this->m_Scene->ChangeRotationStepz((float)step); + +} + +//************************************************************************************************** +void VisAtomWidget:: OnZoomStep(int step) +{ + this->m_Scene->ChangeZoomPercent(1.-(float)step/100.f); +} + +//************************************************************************************************** +void VisAtomWidget::OnChangeGraphQuality(int nfai) +{ + Sphere::Set(nfai, nfai); + Circle::Set(nfai); + SolidCircle::Set(nfai); + this->updateGL(); + return; +} + +//************************************************************************************************** +void VisAtomWidget::ChangeGraphQuality(int nfai) +{ + Sphere::Set(nfai, nfai); + Circle::Set(nfai); + SolidCircle::Set(nfai); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::SetGeomStyleVectorVisible(bool show, int style, bool all) +{ + VisAtomSubSample*subp = this->m_Sample->GetCurrentSubsample(); + + if(show) + { + //dtermine if need creating initial lenscal + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + if(vlenscal < 0) + { + this->m_Sample->GetDefaultVectorSize(vlenscal,vrad, arrowl, arrowr); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad); + } + } + + if(!all) + { + /*subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleVectorVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleVectorVisible(show); + for(int i=0; im_Sample->NumberofSubsample(); i++) + this->m_Sample->LoadSubsampleProp(i);*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleVectorVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleVectorVisible(show); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + } + return; +} + +//********************************************************************************************************** +#define VECTOR_INCREMENT 0.1 +void VisAtomWidget::OnVectorLenMinus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vlenscal = vlenscal*(1.-VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} +void VisAtomWidget:: OnVectorLenPlus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vlenscal = vlenscal*(1.+VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnVectorSizeMinus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vrad = vrad*(1.-VECTOR_INCREMENT); + arrowr = arrowr*(1.-VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + //for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnVectorSizePlus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vrad = vrad*(1.+VECTOR_INCREMENT); + arrowr = arrowr*(1.+VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + //for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnSelectVectorStyleLine(bool checked) +{ + bool changed = 0; + if(checked) + { + /*VisAtomSubSample*subp = this->m_Sample->GetCurrentSubsample(); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + //reserve the shape of atoms + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_LINE) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL(); + }*/ + + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*subp = this->m_Sample->GetSubsample(i); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_LINE) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = 1; + } + } + } + } + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnSelectVectorStyleSolid(bool checked) +{ + bool changed = 0; + if(checked) + { + /*VisAtomSubSample*subp = this->m_Sample->GetCurrentSubsample(); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + //reserve the shape of atoms + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL();*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*subp = this->m_Sample->GetSubsample(i); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = 1; + } + } + } + } + if(changed) this->updateGL(); + + return; +} + +//********************************************************************************************************** +void VisAtomWidget::GetSceneVolume(float&xmin, float&xmax, float&ymin, float&ymax, float&zmin, float&zmax) +{ + if(!this->m_Scene) return; + xmin = this->m_Scene->GetVolumeX0(); + xmax = this->m_Scene->GetVolumeX1(); + ymin = this->m_Scene->GetVolumeY0(); + ymax = this->m_Scene->GetVolumeY1(); + zmin = this->m_Scene->GetVolumeZ0(); + zmax = this->m_Scene->GetVolumeZ1(); + return; +} +//********************************************************************************************************** +void VisAtomWidget::SetSceneVolume(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax) +{ + if(!this->m_Scene) return; + this->m_Scene->SetVolumeX0(xmin); + this->m_Scene->SetVolumeX1(xmax); + this->m_Scene->SetVolumeY0(ymin); + this->m_Scene->SetVolumeY1(ymax); + this->m_Scene->SetVolumeZ0(zmin); + this->m_Scene->SetVolumeZ1(zmax); + this->m_Scene->CreateScene(); + + + VisAtomVisualizingPolicy::SetProjectionBox(xmin, xmax, ymin, ymax, zmin, zmax); + return; +} +//********************************************************************************************************** +void VisAtomWidget::SetGeomStyleTrajectyoryVisible(bool show,int style,bool all) +{ + + VisAtomSubSample*subp; + + if(!all) + { + subp = this->m_Sample->GetCurrentSubsample(); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleTrajectoryVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleTrajectoryVisible(show); + this->m_Sample->LoadCurSubsampleProp(); + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleTrajectoryVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleTrajectoryVisible(show); + this->m_Sample->LoadSubsampleProp(i); + } + } + return; + +} + +//********************************************************************************************************** +void VisAtomWidget::SetGeomStyleAtomVisible(bool show,int style,bool all) +{ + + VisAtomSubSample*subp; + + if(!all) + { + subp = this->m_Sample->GetCurrentSubsample(); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleAtomVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleAtomVisible(show); + this->m_Sample->LoadCurSubsampleProp(); + + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleAtomVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleAtomVisible(show); + this->m_Sample->LoadSubsampleProp(i); + } + + } + this->updateGL(); + return; +} + + +//********************************************************************************************************** +void VisAtomWidget::SetTrajectoryThickChanged(double thick, bool all) +{ + VisAtomSubSample*subp; + if(!all) + { + subp = this->m_Sample->GetCurrentSubsample(); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetTrajectoryLinethick(thick); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetTrajectoryLinethick(thick); + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetTrajectoryLinethick(thick); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetTrajectoryLinethick(thick); + } + + } + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnOpenExtendedObject(VisAtomExtendObject*ptrObj, QString fname) +{ + int i; + for(i=0; im_ExtObjs.size(); i++) + { + if(this->m_ExtObjs[i]->RUNTIME_CLASSNAME() == ptrObj->RUNTIME_CLASSNAME()) + { + delete this->m_ExtObjs[i]; + if(ptrObj->HasData()) + this->m_ExtObjs[i] = ptrObj; + else + this->m_ExtObjs.removeAt(i); + + break; + } + } + + if(ptrObj->HasData() && i == this->m_ExtObjs.size()) + { + this->m_ExtObjs.append(ptrObj); + } + this->updateGL(); + return; +} + +void VisAtomWidget::OnActionFindatom() +{ + this->m_pickedAtomInfo->hide(); +} \ No newline at end of file diff --git a/VisAtom2017/VisAtomwidget.h b/VisAtom2017/VisAtomwidget.h new file mode 100644 index 0000000..bc63e24 --- /dev/null +++ b/VisAtom2017/VisAtomwidget.h @@ -0,0 +1,197 @@ + +#ifndef VISATOMWIDGET_H +#define VISATOMWIDGET_H + +#include +#include "VisAtomSample.h" +class Scene; +class Bitmap; +class VisAtomDataSheet; +class VisAtomCliper; +class VisAtom_AtomInfo; +class VisAtomTrajectory; +class VisAtomExtendObject; +class VisAtomWidget : public QGLWidget +{ + Q_OBJECT + +public: + VisAtomWidget(QWidget *parent = 0); + ~VisAtomWidget(); + + enum ACTION_OTPION + { + ACTION_ROTATION_X = 0, + ACTION_ROTATION_Y = 1, + ACTION_ROTATION_Z = 2, + ACTION_ZOOM_SCENE = 3, + ACTION_VIEWPORT_CENTER = 4 + }; + + enum ACTION_MOUSE_STATE + { + BUTTON_RELEASED = 0, + LBUTTON_PRESSED = 1, + RBUTTON_PRESSED = 2 + }; + + +public slots: + + +signals: + +protected: + void initializeGL(); + void paintGL(); + void paintEvent(QPaintEvent *event); + void resizeGL(int width, int height); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent( QMouseEvent * event); + void mouseMoveEvent(QMouseEvent *event); + void hideEvent(QHideEvent *event); + + //VisAtomData type + Scene*m_Scene; + Scene*m_ColorbarView; + VisAtomSample*m_Sample; + //VisAtomCliper**m_Cliper; + QList*m_pCliper; + VisAtomCliper*m_curCliper; + int m_curCliperStyle; + + //extension objects + VisAtomTrajectory*m_Trajectory; + QListm_ExtObjs; + + //Properties for concerning scene + BOOL m_AutoNormalizingView; + int m_MouseAction; + int m_MouseState; + float m_Backgroud[4]; + + QTimer *m_Timer; + int m_Timestep; + + //Methods for VisAtom + void NormalizingView(); + void ProcessCurrentAction(); + + VisAtom_AtomInfo*m_pickedAtomInfo; + + +private slots: + void SelectMouseAction(int action); + void OnChangeSceneBackground(); + void OnProjecttypeOrtho(); + void OnProjecttypePerspect(); + void SetSceneDistance(int range, int value); + void OnCoordinatBody(); + void OnCoordinatLab(); + void OnBoxDisplayOption(QTreeWidgetItem*); + void OnShowSceneBox(int show); + void OnShowSceneBackfaceX(int show); + void OnShowSceneBackfaceY(int show); + void OnShowSceneBackfaceZ(int show); + void OnShowSceneFrontfaceX(int show); + void OnShowSceneFrontfaceY(int show); + void OnShowSceneFrontfaceZ(int show); + void OnClipXBack(); + void OnClipXForward(); + void OnClipYBack(); + void OnClipYForward(); + void OnClipZBack(); + void OnClipZForward(); + void OnRotationXStep(int step); + void OnRotationYStep(int step); + void OnRotationZStep(int step); + void OnZoomStep(int step); + void OnShowClipANYDIRFrontface(bool show); + void OnShowClipANYDIRBackface(bool show); + + + void OnTimerout(); + + void OnSelectShapeDot(bool checked); + void OnSelectShapeSolidSphere(bool checked); + void OnSelectShapeWireSphere(bool checked); + void OnSelectShapeCircle(bool checked); + void OnChangeAtomColor(); + void OnChangeGraphQuality(int nfai); + + void SetAtomRadiu(int range, int value, bool all=false); + void SetAtomShape(int shape, bool all); + void SetGeomStyleVectorVisible(bool show, int style, bool all); + void SetVariableAtomRadiu(bool variable,bool all); + void ChangeGraphQuality(int nfai); + + void OnVectorLenMinus(); + void OnVectorLenPlus(); + void OnVectorSizeMinus(); + void OnVectorSizePlus(); + void OnSelectVectorStyleLine(bool checked); + void OnSelectVectorStyleSolid(bool checked); + + void SetGeomStyleAtomVisible(bool show,int style,bool all); + void SetGeomStyleTrajectyoryVisible(bool show,int style,bool all); + void SetTrajectoryThickChanged(double thick,bool all); + + void OnOpenExtendedObject(VisAtomExtendObject*ptrObj, QString fname); + +private: + + QPoint lastPos; + +public: + VisAtomSample * GetSample() + { + return m_Sample; + }; + VisAtomTrajectory*GetTrajectory() + { + return m_Trajectory; + }; + void SetSampleDataSheet(VisAtomDataSheet*pData, BOOL redraw=true); + + BOOL IfAutoNormalizingView() + { + return m_AutoNormalizingView; + }; + void SetAutoNormalizingView() + { + m_AutoNormalizingView = true; + }; + void SetNoAutoNormalizingView() + { + m_AutoNormalizingView = false; + }; + + void FitGraphView(); + void GetSceneVolume(float&xmin, float&xmax, float&ymin, float&ymax, float&zmin, float&zmax); + void SetSceneVolume(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax); + + + //Clipping routines + int CurrentClipperStyle() + { + return m_curCliperStyle; + }; + void SetCurrentClipperStyle(int curstyle, bool redraw=true); + + VisAtomCliper* SetCurrentClipper(int index); + + VisAtomCliper* CurrentClipper() + { + return m_curCliper; + }; + void SetCurrentCliperParameters(VisAtomCliper*sor); + VisAtomCliper*NewCliper(); + + //IO + void RenderToPixmap(QPixmap&pixmap); + void RenderToBitmap(Bitmap&bitmap); + + void OnActionFindatom(); +}; + +#endif diff --git a/VisAtom2017/cursor-sizeb.png b/VisAtom2017/cursor-sizeb.png new file mode 100644 index 0000000..f37d7b9 Binary files /dev/null and b/VisAtom2017/cursor-sizeb.png differ diff --git a/VisAtom2017/cursor-sizeh.png b/VisAtom2017/cursor-sizeh.png new file mode 100644 index 0000000..a9f40cb Binary files /dev/null and b/VisAtom2017/cursor-sizeh.png differ diff --git a/VisAtom2017/cursor-sizev.png b/VisAtom2017/cursor-sizev.png new file mode 100644 index 0000000..1edbab2 Binary files /dev/null and b/VisAtom2017/cursor-sizev.png differ diff --git a/VisAtom2017/images/About1.png b/VisAtom2017/images/About1.png new file mode 100644 index 0000000..050b7ab Binary files /dev/null and b/VisAtom2017/images/About1.png differ diff --git a/VisAtom2017/images/Image7.gif b/VisAtom2017/images/Image7.gif new file mode 100644 index 0000000..fa51f72 Binary files /dev/null and b/VisAtom2017/images/Image7.gif differ diff --git a/VisAtom2017/images/SCU.png b/VisAtom2017/images/SCU.png new file mode 100644 index 0000000..b3bbd26 Binary files /dev/null and b/VisAtom2017/images/SCU.png differ diff --git a/VisAtom2017/images/SCUlogo.jpg b/VisAtom2017/images/SCUlogo.jpg new file mode 100644 index 0000000..8e3a0ef Binary files /dev/null and b/VisAtom2017/images/SCUlogo.jpg differ diff --git a/VisAtom2017/images/SCUlogo.png b/VisAtom2017/images/SCUlogo.png new file mode 100644 index 0000000..609945f Binary files /dev/null and b/VisAtom2017/images/SCUlogo.png differ diff --git a/VisAtom2017/images/SCUlogo1.png b/VisAtom2017/images/SCUlogo1.png new file mode 100644 index 0000000..a2afb40 Binary files /dev/null and b/VisAtom2017/images/SCUlogo1.png differ diff --git a/VisAtom2017/images/adjustsize.png b/VisAtom2017/images/adjustsize.png new file mode 100644 index 0000000..c4d884c Binary files /dev/null and b/VisAtom2017/images/adjustsize.png differ diff --git a/VisAtom2017/images/colormap.png b/VisAtom2017/images/colormap.png new file mode 100644 index 0000000..cd5e77b Binary files /dev/null and b/VisAtom2017/images/colormap.png differ diff --git a/VisAtom2017/images/copy.png b/VisAtom2017/images/copy.png new file mode 100644 index 0000000..2aeb282 Binary files /dev/null and b/VisAtom2017/images/copy.png differ diff --git a/VisAtom2017/images/cross.png b/VisAtom2017/images/cross.png new file mode 100644 index 0000000..fe38e74 Binary files /dev/null and b/VisAtom2017/images/cross.png differ diff --git a/VisAtom2017/images/cursor-sizeb.png b/VisAtom2017/images/cursor-sizeb.png new file mode 100644 index 0000000..e6a071d Binary files /dev/null and b/VisAtom2017/images/cursor-sizeb.png differ diff --git a/VisAtom2017/images/cursor-sizeh.png b/VisAtom2017/images/cursor-sizeh.png new file mode 100644 index 0000000..06ce5b0 Binary files /dev/null and b/VisAtom2017/images/cursor-sizeh.png differ diff --git a/VisAtom2017/images/cursor-sizev.png b/VisAtom2017/images/cursor-sizev.png new file mode 100644 index 0000000..98d5942 Binary files /dev/null and b/VisAtom2017/images/cursor-sizev.png differ diff --git a/VisAtom2017/images/cut.png b/VisAtom2017/images/cut.png new file mode 100644 index 0000000..54638e9 Binary files /dev/null and b/VisAtom2017/images/cut.png differ diff --git a/VisAtom2017/images/fit-page-24.png b/VisAtom2017/images/fit-page-24.png new file mode 100644 index 0000000..c7b39d8 Binary files /dev/null and b/VisAtom2017/images/fit-page-24.png differ diff --git a/VisAtom2017/images/fit-page-32.png b/VisAtom2017/images/fit-page-32.png new file mode 100644 index 0000000..98bc12d Binary files /dev/null and b/VisAtom2017/images/fit-page-32.png differ diff --git a/VisAtom2017/images/new.png b/VisAtom2017/images/new.png new file mode 100644 index 0000000..12131b0 Binary files /dev/null and b/VisAtom2017/images/new.png differ diff --git a/VisAtom2017/images/next.png b/VisAtom2017/images/next.png new file mode 100644 index 0000000..a585cab Binary files /dev/null and b/VisAtom2017/images/next.png differ diff --git a/VisAtom2017/images/open.png b/VisAtom2017/images/open.png new file mode 100644 index 0000000..45fa288 Binary files /dev/null and b/VisAtom2017/images/open.png differ diff --git a/VisAtom2017/images/paste.png b/VisAtom2017/images/paste.png new file mode 100644 index 0000000..c14425c Binary files /dev/null and b/VisAtom2017/images/paste.png differ diff --git a/VisAtom2017/images/prev.png b/VisAtom2017/images/prev.png new file mode 100644 index 0000000..612fb34 Binary files /dev/null and b/VisAtom2017/images/prev.png differ diff --git a/VisAtom2017/images/qml-gradient.png b/VisAtom2017/images/qml-gradient.png new file mode 100644 index 0000000..5eefdd2 Binary files /dev/null and b/VisAtom2017/images/qml-gradient.png differ diff --git a/VisAtom2017/images/radialGradient.png b/VisAtom2017/images/radialGradient.png new file mode 100644 index 0000000..b6ab6c8 Binary files /dev/null and b/VisAtom2017/images/radialGradient.png differ diff --git a/VisAtom2017/images/rotation.png b/VisAtom2017/images/rotation.png new file mode 100644 index 0000000..eecde4b Binary files /dev/null and b/VisAtom2017/images/rotation.png differ diff --git a/VisAtom2017/images/rotationx.png b/VisAtom2017/images/rotationx.png new file mode 100644 index 0000000..7c1fb69 Binary files /dev/null and b/VisAtom2017/images/rotationx.png differ diff --git a/VisAtom2017/images/rotationx1.png b/VisAtom2017/images/rotationx1.png new file mode 100644 index 0000000..eecde4b Binary files /dev/null and b/VisAtom2017/images/rotationx1.png differ diff --git a/VisAtom2017/images/rotationy.png b/VisAtom2017/images/rotationy.png new file mode 100644 index 0000000..5fb26e0 Binary files /dev/null and b/VisAtom2017/images/rotationy.png differ diff --git a/VisAtom2017/images/rotationz.png b/VisAtom2017/images/rotationz.png new file mode 100644 index 0000000..da8cce0 Binary files /dev/null and b/VisAtom2017/images/rotationz.png differ diff --git a/VisAtom2017/images/save.png b/VisAtom2017/images/save.png new file mode 100644 index 0000000..daba865 Binary files /dev/null and b/VisAtom2017/images/save.png differ diff --git a/VisAtom2017/images/scenestyle1.png b/VisAtom2017/images/scenestyle1.png new file mode 100644 index 0000000..f91f79a Binary files /dev/null and b/VisAtom2017/images/scenestyle1.png differ diff --git a/VisAtom2017/images/scenestyle2.png b/VisAtom2017/images/scenestyle2.png new file mode 100644 index 0000000..b9c1414 Binary files /dev/null and b/VisAtom2017/images/scenestyle2.png differ diff --git a/VisAtom2017/images/scenestyle3.png b/VisAtom2017/images/scenestyle3.png new file mode 100644 index 0000000..dd396b2 Binary files /dev/null and b/VisAtom2017/images/scenestyle3.png differ diff --git a/VisAtom2017/images/softmgr48.png b/VisAtom2017/images/softmgr48.png new file mode 100644 index 0000000..9cc2eb2 Binary files /dev/null and b/VisAtom2017/images/softmgr48.png differ diff --git a/VisAtom2017/images/solidsphere.png b/VisAtom2017/images/solidsphere.png new file mode 100644 index 0000000..36b09a2 Binary files /dev/null and b/VisAtom2017/images/solidsphere.png differ diff --git a/VisAtom2017/images/svg-image.png b/VisAtom2017/images/svg-image.png new file mode 100644 index 0000000..5a71ea7 Binary files /dev/null and b/VisAtom2017/images/svg-image.png differ diff --git a/VisAtom2017/images/zoomin.png b/VisAtom2017/images/zoomin.png new file mode 100644 index 0000000..d46f5af Binary files /dev/null and b/VisAtom2017/images/zoomin.png differ diff --git a/VisAtom2017/main.cpp b/VisAtom2017/main.cpp new file mode 100644 index 0000000..bacd6dc --- /dev/null +++ b/VisAtom2017/main.cpp @@ -0,0 +1,10 @@ +#include "VisAtom2017.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + VisAtom2017 w; + w.show(); + return a.exec(); +} diff --git a/VisAtom2017/resource.h b/VisAtom2017/resource.h new file mode 100644 index 0000000..2ca4659 --- /dev/null +++ b/VisAtom2017/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by VisAtom2013_1.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/VisAtom2017/resource1.h b/VisAtom2017/resource1.h new file mode 100644 index 0000000..497c65d --- /dev/null +++ b/VisAtom2017/resource1.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by VisAtom20171.rc + +// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/VisAtom2017/sor/VisAtomwidget.cpp b/VisAtom2017/sor/VisAtomwidget.cpp new file mode 100644 index 0000000..ad82a01 --- /dev/null +++ b/VisAtom2017/sor/VisAtomwidget.cpp @@ -0,0 +1,1302 @@ + +#include +#include +#include + +#include "Scene.h" +#include "Sphere.h" +#include "Circle.h" +#include "SolidCircle.h" +#include "Bitmap.h" +#include "Arrow.h" +#include "VisAtomwidget.h" +#include "VisAtomCliper.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtom_NewVectorPolicyDlg.h" +#include "visatom_atominfo.h" +#include "VisAtomTrajectory.h" +#include "VisAtomExtendObject.h" + +#define COLORMAPBARSZIEX 32 +#define COLORMAPBARSZIEY 480 +#define COORDSYSVIEWSIZE 148 + +VisAtomWidget::VisAtomWidget(QWidget *parent) + : QGLWidget(parent) +{ + int i; + m_Scene = new Scene(); + m_ColorbarView = new Scene(); + m_Sample = new VisAtomSample(); + + //default action options for scene + m_AutoNormalizingView = true; + m_MouseAction = ACTION_ZOOM_SCENE; + m_MouseState = BUTTON_RELEASED; + + //clipping + m_Cliper = new VisAtomCliper*[VisAtomCliper::CLIPPING_STYLE_NUM]; + for(i=0; iAttachScene(m_Scene); + m_Cliper[i]->SetStyle(i); + + } + m_currentCliper = 0; + + //default display options for scene + m_Backgroud[0] = m_Backgroud[1] = m_Backgroud[2] = 1.f; + m_Backgroud[4] = 1.f; + + //invoke a timer + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(OnTimerout())); + m_Timestep = 300; + timer->start(m_Timestep); + + //for picked atom infomation + m_pickedAtomInfo = new VisAtom_AtomInfo(); + m_pickedAtomInfo->setVisible(false); + + //for atom trajectory + m_Trajectory = new VisAtomTrajectory(); + m_Trajectory->AttachSample(m_Sample); + m_Sample->AttachTrajectory(m_Trajectory); + +} + +VisAtomWidget::~VisAtomWidget() +{ + makeCurrent(); + int i; + if(m_Scene) delete m_Scene; m_Scene=NULL; + if(m_Sample) delete m_Sample; m_Sample=NULL; + for(i=0; i SetDataSheet(pData); + + if(this->m_AutoNormalizingView) + this->NormalizingView(); + + if(redraw) this->updateGL(); +} + +void VisAtomWidget::NormalizingView() +{ + makeCurrent(); + //to atutomatically normalize the view + float left, right,top, bottom,nearz, farz, z0; + m_Sample->GetSampleBoxRangeX(left, right); + m_Sample->GetSampleBoxRangeY(bottom, top); + m_Sample->GetSampleBoxRangeZ(nearz, farz); + + z0 = std::max(fabs(nearz), fabs(farz)); + farz = z0; + nearz = -z0; + + m_Scene->CreateScene(left, right, bottom, top, nearz, farz); + + //to update the projection box size + if(VisAtomVisualizingPolicy::IsAutoProjectionBox()) + { + VisAtomVisualizingPolicy::SetProjectionBox(left, right, bottom, top, nearz, farz); + } + + return; +} + +void VisAtomWidget::FitGraphView() +{ + makeCurrent(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + this->m_Scene->ChangeZoomScale(1.f); + this->updateGL(); +} + +void VisAtomWidget::SelectMouseAction(int action) +{ + this->m_MouseAction = action; +} + + +void VisAtomWidget::initializeGL() +{ + m_Scene->CreateScene(); + m_Scene->TurnLighton(1); + m_Scene->TurnLighton(2); + m_Scene->TurnLighton(3); +} + +void VisAtomWidget::paintEvent(QPaintEvent *event) +{ + QGLWidget::paintEvent(event); + return; +} + +void VisAtomWidget::paintGL() +{ + + int i; + glClearColor(m_Backgroud[0],m_Backgroud[1], m_Backgroud[2], m_Backgroud[3]); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + this->m_Scene->MakeCurrent(); + this->m_Sample->Paint(); + for(i=0; im_ExtObjs.size(); i++) + { + this->m_ExtObjs[i]->Paint(); + } + + //this->m_Trajectory->Paint(); + //delete this later + //this->m_Sample->DrawWignerSeizVolume("..\\HE32000_2_a\\VTDATA__V_P0000_0001.0000"); + + this->GetCurrentClipper()->Paint(); + this->m_Scene->Paint(); + + + //draw 2D colormap bar + for( i=0; im_Sample->NumberofSubsample(); i++) + { + VisAtomVisualizingPolicy*p = this->m_Sample->GetSubsample(i)->GetCurVisualPolicy(); + if(p->GetColorStyle() == VisAtomVisualizingPolicy::COLOR_STYLE_MAP) + { + int x0, y0, w0, h0; + int x1, y1, w1, h1; + int x, y; + int lablepos[VisAtomVisualizingPolicy::CORLOR_MAP_SIZE]; + QFont font("arial", 9); + QFontMetrics metrics = QFontMetrics(font); + QRect rect; + QString label; + + this->m_ColorbarView->GetViewport(x1, y1, w1, h1); + this->m_ColorbarView->MakeCurrent(); + this->m_Sample->DrawColorMappinBar(lablepos); + + this->m_Scene->GetViewport(x0, y0, w0, h0); + this->m_Scene->MakeCurrent(); + glColor3f(1.f-m_Backgroud[0], 1.f-m_Backgroud[1], 1.f-m_Backgroud[2]); + for(int i= VisAtomVisualizingPolicy::GetColorMappingNumBar()-1; i>=0; i--) + { + label.setNum(VisAtomVisualizingPolicy::GetScalarMappingTabValue(i), 'e', 2); + rect = metrics.boundingRect(label); + x = x1 - rect.width()-2; + y = h0 - lablepos[i]; // +0.5*rect.height(); // h0 - y1 - i * step + 0.5*rect.height(); + this->renderText (x, y, label, font); + } + break; + } + } + + //draw coordinate axsis in a small viewport + /*{ + int x0, y0, w, h; + this->m_Scene->GetViewport( x0, y0, w, h); + if(w>h) + glViewport(0, 0, COORDSYSVIEWSIZE, COORDSYSVIEWSIZE*(float)h/(float)w); + else + glViewport(0, 0, COORDSYSVIEWSIZE*(float)w/(float)h, COORDSYSVIEWSIZE); + + glDisable(GL_DEPTH_TEST); + Arrow aX(0.f, 0.f, 0.f, 1.f, 0.f, 0.f); + Arrow aY(0.f, 0.f, 0.f, 0.f, 1.f, 0.f); + Arrow aZ(0.f, 0.f, 0.f, 0.f, 0.f, 1.f); + float scal = this->m_Scene->CurrentZoomScale(); + float sx = this->m_Scene->GetVolumeX1()*0.8/scal; + float sy = this->m_Scene->GetVolumeY1()*0.8/scal; + float sz = this->m_Scene->GetVolumeZ1()*0.8/scal; + //use the same length and size for axsis + aX.ResetEndPoint(sx, 0.f, 0.f); + aY.ResetEndPoint(0.f, sx, 0.f); + aZ.ResetEndPoint(0.f, 0.f, sx); + aX.ChangeSize(0.15f*sx); + aY.ChangeSize(0.15f*sx); + aZ.ChangeSize(0.15f*sx); + aX.ChangeColor(1.f, 0.f, 0.f); + aY.ChangeColor(0.f, 1.f, 0.f); + aZ.ChangeColor(0.f, 0.f, 1.f); + glPushMatrix(); + this->m_Scene->TransDevice(); + aX.Paint(); + aY.Paint(); + aZ.Paint(); + glPopMatrix(); + }*/ + + //restore the viewport to 3D render + this->m_Scene->MakeCurrent(); + + //draw the cover + if(!this->m_Sample->GetDataSheet()) + { + qglColor(QColor(255*(1-m_Backgroud[0]), 255*(1-m_Backgroud[1]), 255*(1-m_Backgroud[2]))); + int x = 32; + int y = 100; + QFont font("times", 26); + QFontMetrics metrics = QFontMetrics(font); + QString str("Welcome to VisAtom2017"); + this->renderText (x, y, str, font) ; + y = y + metrics.height()*1.5; + QFont font1("times", 16); + QFontMetrics metrics1 = QFontMetrics(font1); + str = "HOU, Qing" ; + this->renderText (x, y, str, font1) ; + y = y + metrics1.height()*1.5; + str = "Key Lab for Radiation Physics and Technology"; + this->renderText (x, y, str, font1) ; + y = y + metrics1.height()*1.5; + str = "Institute of Nuclear Science and Technology"; + this->renderText (x, y, str, font1) ; + y = y + metrics1.height()*1.5; + str = "Sichuan University"; + this->renderText (x, y, str, font1) ; + } +} + +void VisAtomWidget::RenderToPixmap(QPixmap&pixmap) +{ + QSize s = this->size(); + pixmap = this->renderPixmap(s.width(), s.height()); + + +} + +void VisAtomWidget::RenderToBitmap(Bitmap&bitmap) +{ + //this->makeCurrent(); + this->updateGL(); + + int x0, y0, w0, h0; + this->m_Scene->GetViewport( x0, y0, w0, h0); + bitmap.ReadFromViewport(x0, y0, w0,h0); + return; +} + +void VisAtomWidget::resizeGL(int width, int height) +{ + //To store the old rotation matrix + this->makeCurrent(); + + if(height == 0) height = 1; + if(width == 0) width = 1; + //create the main scene for 3D redering + m_Scene->SetViewport(0, 0, width, height); + m_Scene->MakeCurrent(); + m_Scene->CreateScene(); + m_Scene->TurnLighton(1); + m_Scene->TurnLighton(2); + m_Scene->TurnLighton(3); + + int clipState = m_Scene->IsClipPlaneEnabled(1); + m_Scene->Response(action_Object_Clipx); + m_Scene->Response(action_Object_ClipDP); + if( clipState ==2) + m_Scene->Response(action_Object_ClipEP); + else + if(clipState == 1) m_Scene->Response(action_Object_ClipE); + + clipState = m_Scene->IsClipPlaneEnabled(2); + m_Scene->Response(action_Object_Clipy); + m_Scene->Response(action_Object_ClipDP); + if( clipState ==2) + m_Scene->Response(action_Object_ClipEP); + else + if(clipState == 1) m_Scene->Response(action_Object_ClipE); + + clipState = m_Scene->IsClipPlaneEnabled(3); + m_Scene->Response(action_Object_Clipz); + m_Scene->Response(action_Object_ClipDP); + if( clipState ==2) + m_Scene->Response(action_Object_ClipEP); + else + if(clipState == 1) m_Scene->Response(action_Object_ClipE); + + //create the AUX scene for 2D redering + this->m_ColorbarView->SetViewport(width-COLORMAPBARSZIEX-16, (height-COLORMAPBARSZIEY)/2, COLORMAPBARSZIEX, COLORMAPBARSZIEY); + this->m_Scene->MakeCurrent(); + return; +} + + +void VisAtomWidget::mousePressEvent(QMouseEvent *event) +{ + this->makeCurrent(); + if(event->buttons() & Qt::LeftButton) this->m_MouseState = LBUTTON_PRESSED; + else if(event->buttons() & Qt::RightButton) this->m_MouseState = RBUTTON_PRESSED; + + int pickedatom; + pickedatom = -1; + if( QApplication::queryKeyboardModifiers() == Qt::ControlModifier) + { + //to pick the atom + this->m_pickedAtomInfo-> StarPickAtomInfo(event->globalX(), event->globalY()); + float curX, curY, curZ; + this->m_Sample->PickAtom(event->pos().x(), event->pos().y(), this->m_Scene, &curX, &curY, &curZ); + pickedatom = this->m_Sample->GetCurAtom(); + this->m_pickedAtomInfo->ShowAtomInfo(event->globalX(), event->globalY(), this->m_Sample, pickedatom); + + } + else + { + switch(this->m_MouseAction) + { + case this->ACTION_ROTATION_X: + case this->ACTION_ROTATION_Y: + case this->ACTION_ROTATION_Z: + case this->ACTION_ZOOM_SCENE: + this->ProcessCurrentAction(); + break; + case this->ACTION_VIEWPORT_CENTER: + { + if(this->m_MouseState == LBUTTON_PRESSED) + this->m_Scene->TransDevice(event->x(), event->y()); + + if(this->m_MouseState == RBUTTON_PRESSED) + this->m_Scene->TransDevice(); + break; + } + } + } + + this->updateGL(); +} + +void VisAtomWidget::ProcessCurrentAction() +{ + int keystate = QApplication::queryKeyboardModifiers(); + + switch(this->m_MouseAction) + { + case this->ACTION_ROTATION_X: + if(keystate == Qt::ShiftModifier) + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateX(90.f); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateX(-90.f); + } + else + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateXf(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateXb(); + } + break; + case this->ACTION_ROTATION_Y: + if(keystate == Qt::ShiftModifier) + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateY(90.f); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateY(-90.f); + } + else + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateYf(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateYb(); + } + break; + case this->ACTION_ROTATION_Z: + if(keystate == Qt::ShiftModifier) + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateZ(90.f); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateZ(-90.f); + } + else + { + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->RotateZf(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->RotateZb(); + } + break; + case this->ACTION_ZOOM_SCENE: + if(this->m_MouseState==LBUTTON_PRESSED) this->m_Scene->ZoomIn(); + else if(this->m_MouseState==RBUTTON_PRESSED) this->m_Scene->ZoomOut(); + break; + } + +} + +void VisAtomWidget::mouseReleaseEvent ( QMouseEvent * event ) +{ + this->m_MouseState = BUTTON_RELEASED; + this->m_pickedAtomInfo->hide(); + +} + +void VisAtomWidget::mouseMoveEvent(QMouseEvent *event) +{ + int dx = event->x() - lastPos.x(); + int dy = event->y() - lastPos.y(); + + /*if (event->buttons() & Qt::LeftButton) { + setXRotation(xRot + 8 * dy); + setYRotation(yRot + 8 * dx); + } else if (event->buttons() & Qt::RightButton) { + setXRotation(xRot + 8 * dy); + setZRotation(zRot + 8 * dx); + }*/ + lastPos = event->pos(); +} + +#define RGBSIZE 255 +void VisAtomWidget::OnChangeSceneBackground() +{ + int R = m_Backgroud[0]*RGBSIZE; + int G = m_Backgroud[1]*RGBSIZE; + int B = m_Backgroud[2]*RGBSIZE; + int A = m_Backgroud[3]*RGBSIZE; + QColorDialog colorsel(QColor(R, G, B, A), this); + + if(colorsel.exec()) + { + + QColor color = colorsel.currentColor(); + color.getRgb(&R, &G, &B, &A); + m_Backgroud[0] = R/float(RGBSIZE); + m_Backgroud[1] = G/float(RGBSIZE); + m_Backgroud[2] = B/float(RGBSIZE); + m_Backgroud[3] = A/float(RGBSIZE); + this->makeCurrent(); + glClearColor(m_Backgroud[0],m_Backgroud[1], m_Backgroud[2], m_Backgroud[3]); + this->updateGL(); + } +} + +void VisAtomWidget:: OnProjecttypeOrtho() +{ + this->makeCurrent(); + this->m_Scene->SetAsOrtho(); + this->m_Scene->CreateScene(); + this->updateGL(); + +} +void VisAtomWidget::OnProjecttypePerspect() +{ + this->makeCurrent(); + this->m_Scene->SetAsPerspective(); + this->m_Scene->CreateScene(); + this->updateGL(); +} +void VisAtomWidget::SetSceneDistance(int range, int value) +{ + this->makeCurrent(); + float inc = 4.0*(this->m_Scene->GetVolumeZ1()-this->m_Scene->GetVolumeZ0())/float(range); + float dist = value*inc; + + this->m_Scene->SetDistance(dist); + this->m_Scene->CreateScene(); + this->updateGL(); +} + +void VisAtomWidget::OnBoxDisplayOption(QTreeWidgetItem*item) +{ + QString tname = item->text(0); + int checked1 = item->checkState(1); + int checked2 = item->checkState(2); + int style = 0; + if (checked1) style = style + 1; + if (checked2) style = style + 2; + + if (tname == tr("X-Y back")) + { + this->m_Scene->ShowBackfaceZ(style); + } + else if (tname == tr("Y-Z back")) + { + this->m_Scene->ShowBackfaceX(style); + } + else if (tname == tr("Z-X back")) + { + this->m_Scene->ShowBackfaceY(style); + } + else if (tname == tr("X-Y front")) + { + this->m_Scene->ShowFrontfaceZ(style); + } + else if (tname == tr("Y-Z front")) + { + this->m_Scene->ShowFrontfaceX(style); + } + else if (tname == tr("Z-X front")) + { + this->m_Scene->ShowFrontfaceY(style); + } + this->updateGL(); + return; +} +void VisAtomWidget::OnShowSceneBox(int show) +{ + this->m_Scene->ShowBoxBorder(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneBackfaceX(int show) +{ + this->m_Scene->ShowBackfaceX(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneBackfaceY(int show) +{ + this->m_Scene->ShowBackfaceY(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneBackfaceZ(int show) +{ + this->m_Scene->ShowBackfaceZ(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneFrontfaceX(int show) +{ + this->m_Scene->ShowFrontfaceX(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneFrontfaceY(int show) +{ + this->m_Scene->ShowFrontfaceY(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowSceneFrontfaceZ(int show) +{ + this->m_Scene->ShowFrontfaceZ(show); + this->updateGL(); +} + + + +void VisAtomWidget::SetCliperParameters(VisAtomCliper*sor) +{ + int style = sor->GetStyle(); + + + this->m_Cliper[style]->SetParameters(sor); + this->m_Sample->SetCliper(this->GetCurrentClipper()); + this->updateGL(); +} + +void VisAtomWidget::SetCurrentCliper(int current, bool redraw) +{ + if(current == this->m_currentCliper) return; + this->m_currentCliper = current; + this->m_Sample->SetCliper(this->GetCurrentClipper()); + if(redraw) this->updateGL(); +} + +void VisAtomWidget::OnClipXBack() +{ + VisAtomCliper*p = this->GetCurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipX()) pos[0] = pos[0]+step[0]; + else pos[0] = pos[0]-step[0]; + + //to prevent the sample moving out ofbox + if(pos[0] < p->GetAttachedScene()->GetVolumeX0()) + pos[0] = p->GetAttachedScene()->GetVolumeX0(); + + if(pos[0] > p->GetAttachedScene()->GetVolumeX1()) + pos[0] = p->GetAttachedScene()->GetVolumeX1(); + + p->SetClipPos(pos); + this->m_Sample->SetCliper(p); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipXForward() +{ + VisAtomCliper*p = this->GetCurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipX()) pos[0] = pos[0]-step[0]; + else pos[0] = pos[0]+step[0]; + + //to prevent the sample moving out ofbox + if(pos[0] < p->GetAttachedScene()->GetVolumeX0()) + pos[0] = p->GetAttachedScene()->GetVolumeX0(); + + if(pos[0] > p->GetAttachedScene()->GetVolumeX1()) + pos[0] = p->GetAttachedScene()->GetVolumeX1(); + + p->SetClipPos(pos); + this->m_Sample->SetCliper(p); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipYBack() +{ + VisAtomCliper*p = this->GetCurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipY()) pos[1] = pos[1]+step[1]; + else pos[1] = pos[1]-step[1]; + + //to prevent the sample moving out ofbox + if(pos[1] < p->GetAttachedScene()->GetVolumeY0()) + pos[1] = p->GetAttachedScene()->GetVolumeY0(); + + if(pos[1] > p->GetAttachedScene()->GetVolumeY1()) + pos[1] = p->GetAttachedScene()->GetVolumeY1(); + + + p->SetClipPos(pos); + this->m_Sample->SetCliper(p); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipYForward() +{ + VisAtomCliper*p = this->GetCurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipY()) pos[1] = pos[1]-step[1]; + else pos[1] = pos[1]+step[1]; + + //to prevent the sample moving out ofbox + if(pos[1] < p->GetAttachedScene()->GetVolumeY0()) + pos[1] = p->GetAttachedScene()->GetVolumeY0(); + + if(pos[1] > p->GetAttachedScene()->GetVolumeY1()) + pos[1] = p->GetAttachedScene()->GetVolumeY1(); + + p->SetClipPos(pos); + this->m_Sample->SetCliper(p); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipZBack() +{ + VisAtomCliper*p = this->GetCurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipZ()) pos[2] = pos[2]+step[2]; + else pos[2] = pos[2]-step[2]; + + //to prevent the sample moving out ofbox + if(pos[2] < p->GetAttachedScene()->GetVolumeZ0()) + pos[2] = p->GetAttachedScene()->GetVolumeZ0(); + + if(pos[2] > p->GetAttachedScene()->GetVolumeZ1()) + pos[2] = p->GetAttachedScene()->GetVolumeZ1(); + + + p->SetClipPos(pos); + this->m_Sample->SetCliper(p); + this->updateGL(); + return; +} + +void VisAtomWidget::OnClipZForward() +{ + VisAtomCliper*p = this->GetCurrentClipper(); + double pos[3], step[3]; + p->GetClipPos(pos); + p->GetClipThickness(step); + if(p->IsInverseClipZ()) pos[2] = pos[2]-step[2]; + else pos[2] = pos[2]+step[2]; + + + //to prevent the sample moving out ofbox + if(pos[2] < p->GetAttachedScene()->GetVolumeZ0()) + pos[2] = p->GetAttachedScene()->GetVolumeZ0(); + + if(pos[2] > p->GetAttachedScene()->GetVolumeZ1()) + pos[2] = p->GetAttachedScene()->GetVolumeZ1(); + + + p->SetClipPos(pos); + this->m_Sample->SetCliper(p); + this->updateGL(); + return; +} + +void VisAtomWidget::OnShowClipANYDIRFrontface(bool show) +{ + VisAtomCliper*p = this->GetCurrentClipper(); + p->ShowFronFace(show); + this->updateGL(); +} + +void VisAtomWidget::OnShowClipANYDIRBackface(bool show) +{ + VisAtomCliper*p = this->GetCurrentClipper(); + p->ShowBackFace(show); + this->updateGL(); +} + + +void VisAtomWidget::OnCoordinatBody() +{ + this->m_Scene->SetAsRelativeSystem(); +} + +void VisAtomWidget::OnCoordinatLab() +{ + this->m_Scene->SetAsLaboratorySystem(); +} + + +void VisAtomWidget::OnTimerout() +{ + if(this->m_pickedAtomInfo->isVisible()) return; + + if(this->m_MouseState == LBUTTON_PRESSED || this->m_MouseState == RBUTTON_PRESSED) + { + this->makeCurrent(); + this->ProcessCurrentAction(); + this->updateGL(); + } +} + + +void VisAtomWidget::OnSelectShapeDot(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_DOT, false); +} + +void VisAtomWidget::OnSelectShapeSolidSphere(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_SOLID, false); +} + +void VisAtomWidget::OnSelectShapeWireSphere(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_WIRE, false); +} + +void VisAtomWidget::OnSelectShapeCircle(bool checked) +{ + if(checked) + this->SetAtomShape(VisAtomVisualizingPolicy::SHAPE_STYLE_LINE, false); +} + + +void VisAtomWidget::OnChangeAtomColor() +{ + int i; + + int R = 1.0*RGBSIZE; + int G = 1.0*RGBSIZE; + int B = 1.0*RGBSIZE; + int A = 1.0*RGBSIZE; + + QColorDialog colorsel(QColor(R, G, B, A), this); + + if(colorsel.exec()) + { + + QColor color = colorsel.currentColor(); + color.getRgb(&R, &G, &B, &A); + + this->m_Sample->SetColorForCurrentSubsample(R/float(RGBSIZE), G/float(RGBSIZE), B/float(RGBSIZE)); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL(); + } +} + +void VisAtomWidget::SetAtomRadiu(int range, int value, bool all) +{ + float ratio = (float)value/(float)range; + + float ds = this->m_Scene->GetVolumeX1() - this->m_Scene->GetVolumeX0(); + if(ds > this->m_Scene->GetVolumeY1() - this->m_Scene->GetVolumeY0()) + ds = this->m_Scene->GetVolumeY1() - this->m_Scene->GetVolumeY0(); + if(ds > this->m_Scene->GetVolumeZ1() - this->m_Scene->GetVolumeZ0()) + ds = this->m_Scene->GetVolumeZ1() - this->m_Scene->GetVolumeZ0(); + ds = (ds/4.0)*ratio; + + float rad; + VisAtomSubSample*sub = this->m_Sample->GetCurrentSubsample(); + sub->GetCurAtomSize(rad); + + if(abs(ds-rad) >0.00001) + { + if(!all) + { + /*sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp();*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomSize(ds,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomSize(ds, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomSize(ds, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + } +} + +void VisAtomWidget::SetVariableAtomRadiu(bool variable,bool all) +{ + VisAtomSubSample*sub = this->m_Sample->GetCurrentSubsample(); + + if(!all) + { + /*sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp();*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomHaveUnifiedSize(!variable,VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + sub = this->m_Sample->GetSubsample(i); + sub->SetAtomHaveUnifiedSize(!variable, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomHaveUnifiedSize(!variable, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + return; +} + + +//************************************************************************************************** +void VisAtomWidget::SetAtomShape(int shape, bool all) +{ + VisAtomVisualizingPolicy*policy; + + if(!all) + { + /*VisAtomSubSample*sub = this->m_Sample->GetCurrentSubsample(); + policy = sub->GetCurVisualPolicy(); + int ageom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK; + if(ageom != shape) + { + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL(); + }*/ + bool changed = false; + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*sub = this->m_Sample->GetSubsample(i); + policy = sub->GetCurVisualPolicy(); + int ageom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK; + if(ageom != shape) + { + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = true; + } + } + } + if(changed) this->updateGL(); + } + else + { + bool changed = false; + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + VisAtomSubSample*sub = this->m_Sample->GetSubsample(i); + policy = sub->GetCurVisualPolicy(); + int ageom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::SHAPE_STYLE_MASK; + if(ageom != shape) + { + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + sub->SetAtomShapeStyle(shape, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = true; + } + } + if(changed) this->updateGL(); + } + return; +} + +//************************************************************************************************** +void VisAtomWidget::OnRotationXStep(int step) +{ + this->m_Scene->ChangeRotationStepx((float)step); +} + +//************************************************************************************************** +void VisAtomWidget::OnRotationYStep(int step) +{ + this->m_Scene->ChangeRotationStepy((float)step); + +} + +//************************************************************************************************** +void VisAtomWidget::OnRotationZStep(int step) +{ + this->m_Scene->ChangeRotationStepz((float)step); + +} + +//************************************************************************************************** +void VisAtomWidget:: OnZoomStep(int step) +{ + this->m_Scene->ChangeZoomPercent(1.-(float)step/100.f); +} + +//************************************************************************************************** +void VisAtomWidget::OnChangeGraphQuality(int nfai) +{ + Sphere::Set(nfai, nfai); + Circle::Set(nfai); + SolidCircle::Set(nfai); + this->updateGL(); + return; +} + +//************************************************************************************************** +void VisAtomWidget::ChangeGraphQuality(int nfai) +{ + Sphere::Set(nfai, nfai); + Circle::Set(nfai); + SolidCircle::Set(nfai); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::SetGeomStyleVectorVisible(bool show, int style, bool all) +{ + VisAtomSubSample*subp = this->m_Sample->GetCurrentSubsample(); + + if(show) + { + //dtermine if need creating initial lenscal + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + if(vlenscal < 0) + { + this->m_Sample->GetDefaultVectorSize(vlenscal,vrad, arrowl, arrowr); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad); + } + } + + if(!all) + { + /*subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleVectorVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleVectorVisible(show); + for(int i=0; im_Sample->NumberofSubsample(); i++) + this->m_Sample->LoadSubsampleProp(i);*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleVectorVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleVectorVisible(show); + this->m_Sample->LoadSubsampleProp(i); + } + } + this->updateGL(); + } + return; +} + +//********************************************************************************************************** +#define VECTOR_INCREMENT 0.1 +void VisAtomWidget::OnVectorLenMinus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vlenscal = vlenscal*(1.-VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} +void VisAtomWidget:: OnVectorLenPlus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vlenscal = vlenscal*(1.+VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnVectorSizeMinus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vrad = vrad*(1.-VECTOR_INCREMENT); + arrowr = arrowr*(1.-VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + //for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnVectorSizePlus() +{ + float vlenscal, vrad, arrowl, arrowr; + VisAtomVisualizingPolicy::GetVectorSize(vlenscal, vrad, arrowl, arrowr); + vrad = vrad*(1.+VECTOR_INCREMENT); + arrowr = arrowr*(1.+VECTOR_INCREMENT); + VisAtomVisualizingPolicy::SetVectorSize(vlenscal, vrad, arrowl, arrowr); + //for(int i=0; im_Sample->NumberofSubsample(); i++) this->m_Sample->LoadSubsampleProp(i); + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnSelectVectorStyleLine(bool checked) +{ + bool changed = 0; + if(checked) + { + /*VisAtomSubSample*subp = this->m_Sample->GetCurrentSubsample(); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + //reserve the shape of atoms + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_LINE) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL(); + }*/ + + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*subp = this->m_Sample->GetSubsample(i); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_LINE) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_LINE, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = 1; + } + } + } + } + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnSelectVectorStyleSolid(bool checked) +{ + bool changed = 0; + if(checked) + { + /*VisAtomSubSample*subp = this->m_Sample->GetCurrentSubsample(); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + //reserve the shape of atoms + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadCurSubsampleProp(); + this->updateGL();*/ + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + if(this->m_Sample->IsSelectedSubsample(i)) + { + VisAtomSubSample*subp = this->m_Sample->GetSubsample(i); + VisAtomVisualizingPolicy*policy = subp->GetCurVisualPolicy(); + int vgeom = policy->GetGeomStyle()&VisAtomVisualizingPolicy::VECTOR_STYLE_MASK; + if(vgeom != VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID) + { + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE); + subp->SetVectorStyle(VisAtomVisualizingPolicy::VECTOR_STYLE_SOLID, VisAtomVisualizingPolicy::COLOR_STYLE_MAP); + this->m_Sample->LoadSubsampleProp(i); + changed = 1; + } + } + } + } + if(changed) this->updateGL(); + + return; +} + +//********************************************************************************************************** +void VisAtomWidget::GetSceneVolume(float&xmin, float&xmax, float&ymin, float&ymax, float&zmin, float&zmax) +{ + if(!this->m_Scene) return; + xmin = this->m_Scene->GetVolumeX0(); + xmax = this->m_Scene->GetVolumeX1(); + ymin = this->m_Scene->GetVolumeY0(); + ymax = this->m_Scene->GetVolumeY1(); + zmin = this->m_Scene->GetVolumeZ0(); + zmax = this->m_Scene->GetVolumeZ1(); + return; +} +//********************************************************************************************************** +void VisAtomWidget::SetSceneVolume(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax) +{ + if(!this->m_Scene) return; + this->m_Scene->SetVolumeX0(xmin); + this->m_Scene->SetVolumeX1(xmax); + this->m_Scene->SetVolumeY0(ymin); + this->m_Scene->SetVolumeY1(ymax); + this->m_Scene->SetVolumeZ0(zmin); + this->m_Scene->SetVolumeZ1(zmax); + this->m_Scene->CreateScene(); + + + VisAtomVisualizingPolicy::SetProjectionBox(xmin, xmax, ymin, ymax, zmin, zmax); + return; +} +//********************************************************************************************************** +void VisAtomWidget::SetGeomStyleTrajectyoryVisible(bool show,int style,bool all) +{ + + VisAtomSubSample*subp; + + if(!all) + { + subp = this->m_Sample->GetCurrentSubsample(); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleTrajectoryVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleTrajectoryVisible(show); + this->m_Sample->LoadCurSubsampleProp(); + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleTrajectoryVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleTrajectoryVisible(show); + this->m_Sample->LoadSubsampleProp(i); + } + } + return; + +} + +//********************************************************************************************************** +void VisAtomWidget::SetGeomStyleAtomVisible(bool show,int style,bool all) +{ + + VisAtomSubSample*subp; + + if(!all) + { + subp = this->m_Sample->GetCurrentSubsample(); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleAtomVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleAtomVisible(show); + this->m_Sample->LoadCurSubsampleProp(); + + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetGeomStyleAtomVisible(show); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetGeomStyleAtomVisible(show); + this->m_Sample->LoadSubsampleProp(i); + } + + } + this->updateGL(); + return; +} + + +//********************************************************************************************************** +void VisAtomWidget::SetTrajectoryThickChanged(double thick, bool all) +{ + VisAtomSubSample*subp; + if(!all) + { + subp = this->m_Sample->GetCurrentSubsample(); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetTrajectoryLinethick(thick); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetTrajectoryLinethick(thick); + } + else + { + for(int i=0; im_Sample->NumberofSubsample(); i++) + { + subp = this->m_Sample->GetSubsample(i); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_SINGLE)->SetTrajectoryLinethick(thick); + subp->GetVisualPolicy(VisAtomVisualizingPolicy::COLOR_STYLE_MAP)->SetTrajectoryLinethick(thick); + } + + } + this->updateGL(); + return; +} + +//********************************************************************************************************** +void VisAtomWidget::OnOpenExtendedObject(VisAtomExtendObject*ptrObj, QString fname) +{ + int i; + for(i=0; im_ExtObjs.size(); i++) + { + if(this->m_ExtObjs[i]->RUNTIME_CLASSNAME() == ptrObj->RUNTIME_CLASSNAME()) + { + delete this->m_ExtObjs[i]; + if(ptrObj->HasData()) + this->m_ExtObjs[i] = ptrObj; + else + this->m_ExtObjs.removeAt(i); + + break; + } + } + + if(ptrObj->HasData() && i == this->m_ExtObjs.size()) + { + this->m_ExtObjs.append(ptrObj); + } + this->updateGL(); + return; +} \ No newline at end of file diff --git a/VisAtom2017/sor/VisAtomwidget.h b/VisAtom2017/sor/VisAtomwidget.h new file mode 100644 index 0000000..cc7a4d0 --- /dev/null +++ b/VisAtom2017/sor/VisAtomwidget.h @@ -0,0 +1,175 @@ + +#ifndef VISATOMWIDGET_H +#define VISATOMWIDGET_H + +#include +#include "VisAtomSample.h" + +class Scene; +class Bitmap; +class VisAtomDataSheet; +class VisAtomCliper; +class VisAtom_AtomInfo; +class VisAtomTrajectory; +class VisAtomExtendObject; +class VisAtomWidget : public QGLWidget +{ + Q_OBJECT + +public: + VisAtomWidget(QWidget *parent = 0); + ~VisAtomWidget(); + + enum ACTION_OTPION + { + ACTION_ROTATION_X = 0, + ACTION_ROTATION_Y = 1, + ACTION_ROTATION_Z = 2, + ACTION_ZOOM_SCENE = 3, + ACTION_VIEWPORT_CENTER = 4 + }; + + enum ACTION_MOUSE_STATE + { + BUTTON_RELEASED = 0, + LBUTTON_PRESSED = 1, + RBUTTON_PRESSED = 2 + }; + + +public slots: + + +signals: + +protected: + void initializeGL(); + void paintGL(); + void paintEvent(QPaintEvent *event); + void resizeGL(int width, int height); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent( QMouseEvent * event); + void mouseMoveEvent(QMouseEvent *event); + + + //VisAtomData type + Scene*m_Scene; + Scene*m_ColorbarView; + VisAtomSample*m_Sample; + VisAtomCliper**m_Cliper; + int m_currentCliper; + + //extension objects + VisAtomTrajectory*m_Trajectory; + QListm_ExtObjs; + + //Properties for concerning scene + BOOL m_AutoNormalizingView; + int m_MouseAction; + int m_MouseState; + float m_Backgroud[4]; + + QTimer *m_Timer; + int m_Timestep; + + //Methods for VisAtom + void NormalizingView(); + void ProcessCurrentAction(); + + VisAtom_AtomInfo*m_pickedAtomInfo; + + + +private slots: + void SelectMouseAction(int action); + void OnChangeSceneBackground(); + void OnProjecttypeOrtho(); + void OnProjecttypePerspect(); + void SetSceneDistance(int range, int value); + void OnCoordinatBody(); + void OnCoordinatLab(); + void OnBoxDisplayOption(QTreeWidgetItem*); + void OnShowSceneBox(int show); + void OnShowSceneBackfaceX(int show); + void OnShowSceneBackfaceY(int show); + void OnShowSceneBackfaceZ(int show); + void OnShowSceneFrontfaceX(int show); + void OnShowSceneFrontfaceY(int show); + void OnShowSceneFrontfaceZ(int show); + void OnClipXBack(); + void OnClipXForward(); + void OnClipYBack(); + void OnClipYForward(); + void OnClipZBack(); + void OnClipZForward(); + void OnRotationXStep(int step); + void OnRotationYStep(int step); + void OnRotationZStep(int step); + void OnZoomStep(int step); + void OnShowClipANYDIRFrontface(bool show); + void OnShowClipANYDIRBackface(bool show); + + + void OnTimerout(); + + void OnSelectShapeDot(bool checked); + void OnSelectShapeSolidSphere(bool checked); + void OnSelectShapeWireSphere(bool checked); + void OnSelectShapeCircle(bool checked); + void OnChangeAtomColor(); + void OnChangeGraphQuality(int nfai); + + void SetAtomRadiu(int range, int value, bool all=false); + void SetAtomShape(int shape, bool all); + void SetGeomStyleVectorVisible(bool show, int style, bool all); + void SetVariableAtomRadiu(bool variable,bool all); + void ChangeGraphQuality(int nfai); + + void OnVectorLenMinus(); + void OnVectorLenPlus(); + void OnVectorSizeMinus(); + void OnVectorSizePlus(); + void OnSelectVectorStyleLine(bool checked); + void OnSelectVectorStyleSolid(bool checked); + + void SetGeomStyleAtomVisible(bool show,int style,bool all); + void SetGeomStyleTrajectyoryVisible(bool show,int style,bool all); + void SetTrajectoryThickChanged(double thick,bool all); + + void OnOpenExtendedObject(VisAtomExtendObject*ptrObj, QString fname); + +private: + + QPoint lastPos; + +public: + VisAtomSample*GetSample() + {return m_Sample;} + VisAtomTrajectory*GetTrajectory() + {return m_Trajectory;} + void SetSampleDataSheet(VisAtomDataSheet*pData, BOOL redraw=true); + + BOOL IfAutoNormalizingView() + {return m_AutoNormalizingView;} + void SetAutoNormalizingView() + {m_AutoNormalizingView = true;} + void SetNoAutoNormalizingView() + {m_AutoNormalizingView = false;} + + void FitGraphView(); + void GetSceneVolume(float&xmin, float&xmax, float&ymin, float&ymax, float&zmin, float&zmax); + void SetSceneVolume(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax); + + + //Clipping routines + VisAtomCliper*GetCurrentClipper() + {return m_Cliper[m_currentCliper];} + void SetCurrentCliper(int current, bool redraw=true); + void SetCliperParameters(VisAtomCliper*sor); + + //IO + void RenderToPixmap(QPixmap&pixmap); + void RenderToBitmap(Bitmap&bitmap); +}; + +#endif diff --git a/VisAtom2017/sor/visatom_atominfo.cpp b/VisAtom2017/sor/visatom_atominfo.cpp new file mode 100644 index 0000000..4ee273b --- /dev/null +++ b/VisAtom2017/sor/visatom_atominfo.cpp @@ -0,0 +1,176 @@ +#include "visatom_atominfo.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomTrajectory.h" + +VisAtom_AtomInfo::VisAtom_AtomInfo(QWidget *parent) + : QWidget(parent, Qt::FramelessWindowHint) +{ + ui.setupUi(this); + +} + +VisAtom_AtomInfo::~VisAtom_AtomInfo() +{ + +} + +void VisAtom_AtomInfo::ShowAtomInfo(int posx, int posy, VisAtomSample*pSample, int atomid) +{ + this->ui.treeWidget->clear(); + + int col; + if(atomid >0) + { + + QString snum, snum0; + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, tr("ATOM ID:")); + snum.setNum(atomid); + item->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item); + + //following the index should minus 1 + VisAtomDataSheet*pDataSheet = pSample->GetDataSheet(); + atomid = atomid-1; + //type + QTreeWidgetItem*item1 = new QTreeWidgetItem(); + item1->setText(0, tr("TYPE ID:")); + col = pDataSheet->GetTypeCol(); + if(col >= 0) + snum.setNum((int)(pDataSheet->GetData(col)[atomid]+0.00001)); + else + snum.setNum(1); + item1->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item1); + + //postion + QTreeWidgetItem*item2 = new QTreeWidgetItem(); + item2->setText(0, tr("POS:")); + snum = tr("("); + col = pDataSheet->GetPosXCol(); + snum0.setNum(pDataSheet->GetData(col)[atomid]); + snum.append(snum0); + snum.append(tr(", ")); + col = pDataSheet->GetPosYCol(); + snum0.setNum(pDataSheet->GetData(col)[atomid]); + snum.append(snum0); + snum.append(tr(", ")); + col = pDataSheet->GetPosZCol(); + snum0.setNum(pDataSheet->GetData(col)[atomid]); + snum.append(snum0); + snum.append(tr(")")); + item2->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item2); + + //scalar + QTreeWidgetItem*item3 = new QTreeWidgetItem(); + item3->setText(0, tr("SCARLAR:")); + col = VisAtomVisualizingPolicy::GetScalarCol(); + if(col >=0) + snum.setNum(pDataSheet->GetData(col)[atomid], 'e', 6); + else + snum = tr("undefined"); + item3->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item3); + + //vector + QTreeWidgetItem*item4 = new QTreeWidgetItem(); + item4->setText(0, tr("VECTOR:")); + int vcol[3]; + VisAtomVisualizingPolicy::GetVectorCol(vcol); + if(vcol[0]>=0 && vcol[1]>=0 && vcol[2]>=0) + { + snum = tr("("); + snum0.setNum(pDataSheet->GetData(vcol[0])[atomid], 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(pDataSheet->GetData(vcol[1])[atomid], 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(pDataSheet->GetData(vcol[2])[atomid], 'e',4); + snum.append(snum0); + snum.append(tr(")")); + } + else + snum = tr("undefined"); + item4->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item4); + + //trajectory displacement + VisAtomTrajectory*trajectoryDate = pSample->GetTrajectoryData(); + QTreeWidgetItem*item5 = new QTreeWidgetItem(); + item5->setText(0, tr("DISPLACEMENT:")); + float dx, dy, dz, len; + if(trajectoryDate) + { + if(trajectoryDate->GetDisplacement(atomid,dx,dy,dz)) + { + snum = tr("("); + snum0.setNum(dx, 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(dy, 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(dz, 'e',4); + snum.append(snum0); + snum.append(tr("), len=")); + snum0.setNum(pow(dx*dx+dy*dy+dz*dz,0.5f), 'e',4); + snum.append(snum0); + } + else + snum = tr("undefined"); + } + else + snum = tr("undefined"); + item5->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item5); + + //trajectory length + QTreeWidgetItem*item6 = new QTreeWidgetItem(); + item6->setText(0, tr("PATH LEN:")); + if(trajectoryDate) + { + if(trajectoryDate->GetPathlength(atomid,len)) + snum.setNum(len, 'e',4); + else + snum = tr("undefined"); + } + else + snum = tr("undefined"); + item6->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item6); + + } + else + { + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, tr("ID")); + item->setText(1, tr("No atom picked")); + this->ui.treeWidget->addTopLevelItem(item); + } + + QRect rect = this->rect(); + QRect rect0 = QApplication::desktop()->screenGeometry(); + if(posx + rect.width() > rect0.width()) posx = posx - rect.width(); + if(posy + rect.height() > rect0.height()) posy = posy - rect.height(); + rect.moveTo(posx, posy); + this->setGeometry(rect); + this->show(); + +} + +void VisAtom_AtomInfo::StarPickAtomInfo(int posx, int posy) +{ + this->ui.treeWidget->clear(); + + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, tr("Pick atom,....")); + this->ui.treeWidget->addTopLevelItem(item); + + QRect rect = this->rect(); + rect.moveTo(posx, posy); + this->setGeometry(rect); + this->show(); +} diff --git a/VisAtom2017/sor/visatom_atominfo.h b/VisAtom2017/sor/visatom_atominfo.h new file mode 100644 index 0000000..cbd0e4d --- /dev/null +++ b/VisAtom2017/sor/visatom_atominfo.h @@ -0,0 +1,23 @@ +#ifndef VISATOM_ATOM_INFO_H +#define VISATOMABOUTDLG_H + +#include +#include "ui_visatom_atominfo.h" + +class VisAtomSample; +class VisAtom_AtomInfo : public QWidget +{ + Q_OBJECT + +public: + VisAtom_AtomInfo(QWidget *parent = Q_NULLPTR); + ~VisAtom_AtomInfo(); + + void StarPickAtomInfo(int posx, int posy); + void ShowAtomInfo(int posx, int posy,VisAtomSample*pSample, int atomid); + +private: + Ui::visatom_atominfo ui; +}; + +#endif // VISATOMABOUTDLG_H diff --git a/VisAtom2017/sor/visatom_loadtrajecoryThread.cpp b/VisAtom2017/sor/visatom_loadtrajecoryThread.cpp new file mode 100644 index 0000000..f9524ea --- /dev/null +++ b/VisAtom2017/sor/visatom_loadtrajecoryThread.cpp @@ -0,0 +1,516 @@ +#include +#include +#include "VisAtomTrajectory.h" +#include "VisAtomWidget.h" + + +VisAtom_LoadTrajecoryThread::VisAtom_LoadTrajecoryThread( QObject *parent) + : QThread(parent) +{ + m_pRender = NULL; + m_loaded = 0; + m_colx = m_coly = m_colz = -1; + +} + +VisAtom_LoadTrajecoryThread::~VisAtom_LoadTrajecoryThread() +{ + this->Clear(); + +} + +void VisAtom_LoadTrajecoryThread::Clear() +{ + m_pRender = NULL; + m_SampleFileList.clear(); + return; +} + +//*************************************************************** +void VisAtom_LoadTrajecoryThread::SetFileSerial(QString fname, int from, int to, int step, int colx, int coly, int colz) +{ + + m_SampleFileList.clear(); + + int i; + QString fileName, ext, snum; + for(i=from; i<=to;i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = fname; + fileName.append(ext); + m_SampleFileList.append(fileName); + } + m_loaded = 0; + m_colx = colx; + m_coly = coly; + m_colz = colz; + return; +} + +void VisAtom_LoadTrajecoryThread::AttachRender(VisAtomWidget*pRenader) +{ + this->m_pRender = pRenader; +} + + +QString VisAtom_LoadTrajecoryThread::GetFilename(int i) +{ + if(m_SampleFileList.isEmpty()) return tr(""); + if(i >= m_SampleFileList.size()) return tr(""); + return m_SampleFileList[i]; +} + +QString VisAtom_LoadTrajecoryThread::FirstFilename() +{ + if(m_SampleFileList.isEmpty()) return tr(""); + return m_SampleFileList[0]; +} +QString VisAtom_LoadTrajecoryThread::LasttFilename() +{ + if(m_SampleFileList.isEmpty()) return tr(""); + return m_SampleFileList[m_SampleFileList.size()-1]; +} + +int static extract_numb( char*str, int mxCount, char**strnumb) +{ +/* +! Purpose: to extract number from a string +! Input: STRING a string +! Ouput: COUNT the number of numbers found in the string +! REAL_NUMB the number text founded +! Note: the REAL_NUMBi are character varible. These character number +! could be transformed to real number by DRSTR or RSTRi +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + int i, flag, index1, count; + + count=0; + index1=0; + i = 0; + flag = 0; + do + { + if(str[i] == ' ' || str[i] == ',') + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + index1 = 0; + } + flag = 0; + } + else + { + if((str[i] >= '0' && str[i] <= '9') || str[i] == '-' || str[i] == '+' || str[i] == '.' ) + { + if(flag == 0 ) + { + flag = 1; + count ++; + if(count > mxCount) break; + } + } + else + { + if(flag != 1) flag = 2; + } + } + + if(flag == 1) index1 ++; + + i++; + if(i >= strlen(str) ) + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + } + break; + } + } while(1); + return count; +} + +#define MAXCOL 64 +#define MAXSTRL 32 +void VisAtom_LoadTrajecoryThread::StartLoadData() +{ + if(this->m_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, hlines; + char buf[MAXCOL*MAXSTRL]; + //determin the format of file + QFile file; + //open the first file to determine the format + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + hlines = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + if(len <= 0) {hlines++; continue;} + if(buf[0] == '&' && buf[1] == 'B' && buf[2] == 'O' && buf[3] == 'X'&& buf[4] == 'C'&& buf[5] == 'F'&& buf[6] == 'G'&& + buf[7] == '1' && buf[8] == '4') + { + LoadFrom_BOXCFG14(); + break; + } + + else + if(buf[0] == '&' && buf[1] == 'B' && buf[2] == 'O' && buf[3] == 'X'&& buf[4] == 'C'&& buf[5] == 'F'&& buf[6] == 'G'&& + buf[7] == '1' && buf[8] == '5') + { + LoadFrom_BOXCFG14(); + break; + } + else + if(buf[0] == '&' && buf[1] == 'B' && buf[2] == 'O' && buf[3] == 'X'&& buf[4] == 'C'&& buf[5] == 'F'&& buf[6] == 'G'&& + buf[7] == '1' && buf[8] == '6') + { + LoadFrom_BOXCFG16(); + break; + } + + else + { + LoadFrom_FMTUNKNOWN(); + break; + } + } + file.close(); +} + + +void VisAtom_LoadTrajecoryThread::LoadFrom_FMTUNKNOWN() +{ + if(this->m_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, flag, sline; + char buf[MAXCOL*MAXSTRL]; + char*strnumb[MAXCOL]; + for(i=0; im_SampleFileList[0], 0, this->m_SampleFileList.size()); + QFile file; + //open the first file to determine the number of cols and rows + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + sline = 0; + while (!file.atEnd()) + { + int len, lentrim; + len = file.readLine(buf, sizeof(buf))-1; + if(len <= 0) {sline++; continue;} + flag = 0; + lentrim = 0; + for(i=0; im_SampleFileList.size(); j++) + { + VisAtomDataSheet*pData = new VisAtomDataSheet(ncol, nrow); + int ncol1; + + file.setFileName(this->m_SampleFileList[j]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + //the lenth of the hearder for files could be different + //thus we should redetermine sline for each file + sline = 0; + while (!file.atEnd()) + { + int len, lentrim; + len = file.readLine(buf, sizeof(buf))-1; + if(len <= 0) {sline++; continue;} + flag = 0; + lentrim = 0; + for(i=0; iSetDataForRow(i, strnumb); + } + file.close(); + //add the data to the trajectory object + pData->SetPosxCol(this->m_colx); + pData->SetPosyCol(this->m_coly); + pData->SetPoszCol(this->m_colz); + pTrajectory->AddData(pData); + //The system down if we use GL here,why? + //this->m_pRender->updateGL(); + emit OnEndLoadFile(this->m_SampleFileList[j], j, this->m_SampleFileList.size()); + } + this->m_loaded = 1; + + //clear the temp data + for(i=0; im_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, flag, sline; + char buf[MAXCOL*MAXSTRL]; + char*strnumb[MAXCOL]; + for(i=0; im_SampleFileList[0], 0, this->m_SampleFileList.size()); + QFile file; + //open the first file to determine the number of cols and rows + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + flag = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + nrow = nrow+atoi(strnumb[1]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + if(ncol <= 0) + { + len = file.readLine(buf, sizeof(buf))-1; + ncol = extract_numb( buf, MAXCOL, strnumb); + } + flag = 0; + break; + } + } + file.close(); + + //load the position and displacement data of the first point + for(j=0; jm_SampleFileList.size(); j++) + { + VisAtomDataSheet*pData = new VisAtomDataSheet(ncol, nrow); + + file.setFileName(this->m_SampleFileList[j]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + int ii; + ii = 0; flag = 0; + while (!file.atEnd()) + { + int len,na; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + na = atoi(strnumb[1]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + for(i=0; iSetDataForRow(ii, strnumb); + ii++; + } + flag = 0; + break; + } + } + file.close(); + //add the data to the trajectory object + pData->SetPosxCol(this->m_colx); + pData->SetPosyCol(this->m_coly); + pData->SetPoszCol(this->m_colz); + pTrajectory->AddData(pData); + //The system down if we use GL here,why? + //this->m_pRender->updateGL(); + emit OnEndLoadFile(this->m_SampleFileList[j], j, this->m_SampleFileList.size()); + } + this->m_loaded = 1; + + //clear the temp data + for(i=0; im_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, flag, sline; + char buf[MAXCOL*MAXSTRL]; + char*strnumb[MAXCOL]; + for(i=0; im_SampleFileList[0], 0, this->m_SampleFileList.size()); + QFile file; + //open the first file to determine the number of cols and rows + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + flag = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + nrow = nrow+atoi(strnumb[0]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + if(ncol <= 0) + { + len = file.readLine(buf, sizeof(buf))-1; + ncol = extract_numb( buf, MAXCOL, strnumb); + } + flag = 0; + break; + } + } + file.close(); + + //load the position and displacement data of the first point + for(j=0; jm_SampleFileList.size(); j++) + { + VisAtomDataSheet*pData = new VisAtomDataSheet(ncol, nrow); + + file.setFileName(this->m_SampleFileList[j]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + int ii; + ii = 0; flag = 0; + while (!file.atEnd()) + { + int len,na; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + na = atoi(strnumb[0]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + for(i=0; iSetDataForRow(ii, strnumb); + ii++; + } + flag = 0; + break; + } + } + file.close(); + //add the data to the trajectory object + pData->SetPosxCol(this->m_colx); + pData->SetPosyCol(this->m_coly); + pData->SetPoszCol(this->m_colz); + pTrajectory->AddData(pData); + //The system down if we use GL here,why? + //this->m_pRender->updateGL(); + emit OnEndLoadFile(this->m_SampleFileList[j], j, this->m_SampleFileList.size()); + } + this->m_loaded = 1; + + //clear the temp data + for(i=0; im_loaded) + { + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->SetDataCol(this->m_colx, this->m_coly, this->m_colz); + } + return; + } + + + + +void VisAtom_LoadTrajecoryThread::run() +{ +} + diff --git a/VisAtom2017/sor/visatom_loadtrajecoryThread.h b/VisAtom2017/sor/visatom_loadtrajecoryThread.h new file mode 100644 index 0000000..1c6fdbf --- /dev/null +++ b/VisAtom2017/sor/visatom_loadtrajecoryThread.h @@ -0,0 +1,43 @@ + +#ifndef VISATOMWLOADDATATHREAD_H +#define VISATOMWLOADDATATHREAD_H + +#include +#include + +class VisAtomWidget; +class VisAtom_LoadTrajecoryThread : public QThread +{ + Q_OBJECT + +public: + VisAtom_LoadTrajecoryThread(QObject * parent = 0); + ~VisAtom_LoadTrajecoryThread(); + void SetFileSerial(QString fname, int from, int to, int step, int vx, int vy, int vz); + void SetDataCol(int vx, int vy, int vz); + void AttachRender(VisAtomWidget*pRenader); + + QString GetFilename(int i); + QString FirstFilename(); + QString LasttFilename(); + void Clear(); + void StartLoadData(); + void LoadFrom_FMTUNKNOWN(); + void LoadFrom_BOXCFG14(); + void LoadFrom_BOXCFG16(); + + int IsDataLoaded(){return m_loaded;} +public slots: + + +signals: + void OnStartLoadFile(QString& filename, int index, int total); + void OnEndLoadFile(QString& filename, int index, int total); +protected: + VisAtomWidget*m_pRender; + QList m_SampleFileList; + int m_loaded, m_colx, m_coly, m_colz; + void run(); +}; + +#endif diff --git a/VisAtom2017/sor/visatom_newcolorpolicydlg.cpp b/VisAtom2017/sor/visatom_newcolorpolicydlg.cpp new file mode 100644 index 0000000..94f0542 --- /dev/null +++ b/VisAtom2017/sor/visatom_newcolorpolicydlg.cpp @@ -0,0 +1,271 @@ +#include "visatom_newcolorpolicydlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomSubsample.h" +#include + + +double VisAtom_NewColorPolicyDlg::m_winmin = 0; +double VisAtom_NewColorPolicyDlg::m_winmax = 100; +double VisAtom_NewColorPolicyDlg::m_datamin = 1e8; +double VisAtom_NewColorPolicyDlg::m_datamax =-1.e8; +int VisAtom_NewColorPolicyDlg::m_datacol = -1; + +VisAtom_NewColorPolicyDlg::VisAtom_NewColorPolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + + this->m_Sample = NULL; + this->m_atype = NULL; + this->m_px = NULL; + this->m_py = NULL; + this->m_pz = NULL; + + ui.scalarwindowMinSpinBox->setValue(VisAtom_NewColorPolicyDlg::m_winmin); + ui.scalarwindowMaxSpinBox->setValue(VisAtom_NewColorPolicyDlg::m_winmax); + if(VisAtom_NewColorPolicyDlg::m_datamax > VisAtom_NewColorPolicyDlg::m_datamin) + { + QString snum; + snum.setNum(VisAtom_NewColorPolicyDlg::m_datamin, 'e', 4); + ui.rangeminLable->setText(snum); + snum.setNum(VisAtom_NewColorPolicyDlg::m_datamax, 'e', 4); + ui.rangemaxLable->setText(snum); + } + QString title(tr("Edit scalar range for colormapping")); + this->setWindowTitle(title); + this->ui.subsampleListTreeWidget->setHeaderLabel("Scalar filter"); + + return; +} + +VisAtom_NewColorPolicyDlg::~VisAtom_NewColorPolicyDlg() +{ + +} + +void VisAtom_NewColorPolicyDlg::SetSample(VisAtomSample*sample) +{ + this->m_Sample = sample; + + QString sname; + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0,tr("ALL subsamples")); + item->setCheckState(0,Qt::Checked); + this->ui.subsampleListTreeWidget->addTopLevelItem(item); + + int i; + for(i=0; im_Sample->NumberofSubsample(); i++) + { + VisAtomSubSample*subp = this->m_Sample->GetSubsample(i); + sname = subp->GetName(); + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, sname); + item->setCheckState(0,Qt::Checked); + this->ui.subsampleListTreeWidget->addTopLevelItem(item); + } + return; +} + +void VisAtom_NewColorPolicyDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + #define MAXROW 100 + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + int*colprop = this->m_SampleDataSheet->GetColProp(); + + int i, j; + QString title, snum; + + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row)); + for(i=0; im_atype = this->m_SampleDataSheet->GetData(i); + break; + case VisAtomDataSheet::COLPROP_POSX: + title.append(tr(" (x)")); + this->m_px = this->m_SampleDataSheet->GetData(i); + break; + case VisAtomDataSheet::COLPROP_POSY: + title.append(tr(" (y)")); + this->m_py = this->m_SampleDataSheet->GetData(i); + break; + case VisAtomDataSheet::COLPROP_POSZ: + title.append(tr(" (z)")); + this->m_pz = this->m_SampleDataSheet->GetData(i); + break; + } + + QTableWidgetItem*hitem = new QTableWidgetItem(title); + ui.datasheetTableWidget->setHorizontalHeaderItem(i, hitem); + } + + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[j]+0.000001)); + else + snum.setNum(cdata[j], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[row-1]+0.000001)); + else + snum.setNum(cdata[row-1], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + + } + ui.datasheetTableWidget->selectColumn(this->m_datacol); + ui.numrowSpinBox->setValue(row); + return; +} + +void VisAtom_NewColorPolicyDlg::OnTableSelected() +{ + int col = ui.datasheetTableWidget->currentColumn(); + if(col < 0) return; + if(!this->m_Sample) return; + int i; + double fmin, fmax; + + this->m_datacol = col; + this->GetFilteredScalarRange(col, fmin, fmax); + + QString snum; + snum.setNum(fmin, 'e', 4); + ui.dataminLabel->setText(snum); + snum.setNum(fmax, 'e', 4); + ui.datamaxLabel->setText(snum); + + double range = ui.scalarwindowMinSpinBox->maximum() - ui.scalarwindowMinSpinBox->minimum(); + this->m_datamin = ui.scalarwindowMinSpinBox->value()*(fmax-fmin)/range + fmin; + this->m_datamax = ui.scalarwindowMaxSpinBox->value()*(fmax-fmin)/range + fmin; + + //to make data in 10 based data + fmin = this->m_datamin; + fmax = this->m_datamax; + int scal, num; + scal = log10(abs(fmin)); + num = floor(fmin*pow(10.f, -scal)); + this->m_datamin = (float)num*pow(10.f,scal); + + scal = log10(abs(fmax)); + num = ceil(fmax*pow(10.f, -scal)); + this->m_datamax = (float)num*pow(10.f,scal); + + snum.setNum(this->m_datamin, 'e', 4); + ui.rangeminLable->setText(snum); + snum.setNum(this->m_datamax, 'e', 4); + ui.rangemaxLable->setText(snum); + return; +} + +void VisAtom_NewColorPolicyDlg::OnSubsampleListItemChanged(QTreeWidgetItem*item) +{ + if(item->text(0) == tr("ALL subsamples") && item->checkState(0) == Qt::Checked ) + { + int i; + for(i=0; im_Sample->NumberofSubsample(); i++) + { + QTreeWidgetItem*p = this->ui.subsampleListTreeWidget->topLevelItem(i+1); + p->setCheckState(0,Qt::Checked); + } + } + else if(item->checkState(0) == Qt::Unchecked) + { + this->ui.subsampleListTreeWidget->topLevelItem(0)->setCheckState(0,Qt::Unchecked); + } + this->OnTableSelected(); +} + +void VisAtom_NewColorPolicyDlg::GetFilteredScalarRange(int col, double&fmin, double&fmax) +{ + float*pdat = this->m_SampleDataSheet->GetData(col); + + fmin = 1.e10; + fmax =-1.e10; + int i,j, nsub, ingroup; + + QTreeWidgetItem*item; + QList subp; + for(i=0; im_Sample->NumberofSubsample(); i++) + { + item = this->ui.subsampleListTreeWidget->topLevelItem(i+1); + if(item->checkState(0) == Qt::Checked) + { + subp.append(this->m_Sample->GetSubsample(i)); + } + } + + nsub = subp.count(); + for(i=0; im_SampleDataSheet->GetNumRow(); i++) + { + ingroup = false; + for(j=0; jCheckMembership((int)(m_atype[i]+0.00001), m_px[i], m_py[i], m_pz[i])) + { + ingroup = true; break; + } + } + else + { + if(subp[j]->CheckMembership(1,m_px[i], m_py[i], m_pz[i])) + { + ingroup = true; break; + } + } + } + + if(ingroup) + { + if(pdat[i] > fmax) fmax = pdat[i]; + if(pdat[i] < fmin) fmin = pdat[i]; + } + } +} + + diff --git a/VisAtom2017/sor/visatom_newcolorpolicydlg.h b/VisAtom2017/sor/visatom_newcolorpolicydlg.h new file mode 100644 index 0000000..b1b1032 --- /dev/null +++ b/VisAtom2017/sor/visatom_newcolorpolicydlg.h @@ -0,0 +1,52 @@ +#ifndef VISATOMNEWCOLORPOLICY_H +#define VISATOMNEWCOLORPOLICY_H + +#include +#include "ui_visatom_newcolorpolicyDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewColorPolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + VisAtomSample*m_Sample; + + static double m_winmin, m_winmax; + static double m_datamin, m_datamax; + static int m_datacol; + +public: + VisAtom_NewColorPolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewColorPolicyDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + void SetSample(VisAtomSample*sample); + + void GetData(int&col, float&min, float&max) + { + col = m_datacol; min = m_datamin; max = m_datamax; + } + +private slots: + + void OnTableSelected(); + void OnSubsampleListItemChanged(QTreeWidgetItem*item); + +private: + Ui::visatom_newcolorpolicyForm ui; + void GetFilteredScalarRange(int col, double&fmin, double&fmax); + float*m_atype; + float*m_px; + float*m_py; + float*m_pz; + + + // + +}; + +#endif // VISATOMNEWCOLORPOLICY_H diff --git a/VisAtom2017/sor/visatom_newdisplacementdlg.cpp b/VisAtom2017/sor/visatom_newdisplacementdlg.cpp new file mode 100644 index 0000000..35864f9 --- /dev/null +++ b/VisAtom2017/sor/visatom_newdisplacementdlg.cpp @@ -0,0 +1,524 @@ +#include "visatom_newdisplacementdlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomSubsample.h" +#include + +int VisAtom_NewDisplacementPolicyDlg::m_discol[3]={-1,-1,-1}; +int VisAtom_NewDisplacementPolicyDlg::m_startInd=-1; +int VisAtom_NewDisplacementPolicyDlg::m_endInd=-1; +int VisAtom_NewDisplacementPolicyDlg::m_indStep=1; +int VisAtom_NewDisplacementPolicyDlg::m_IndRng[3]={-1, -1, 1}; +QString VisAtom_NewDisplacementPolicyDlg::m_filename = ""; // tr(""); +#define MAXROW 53 +#define HEADROWS 3 +#define BKR 220 +#define BKG 220 +#define BKB 220 + +#define MAXCOL 64 +#define MAXSTRL 32 + +//**************************************************************************** +int static extract_numb( char*str, int mxCount, char**strnumb) +{ +/* +! Purpose: to extract number from a string +! Input: STRING a string +! Ouput: COUNT the number of numbers found in the string +! REAL_NUMB the number text founded +! Note: the REAL_NUMBi are character varible. These character number +! could be transformed to real number by DRSTR or RSTRi +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + int i, flag, index1, count; + + count=0; + index1=0; + i = 0; + flag = 0; + do + { + if(str[i] == ' ' || str[i] == ',') + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + index1 = 0; + } + flag = 0; + } + else + { + if((str[i] >= '0' && str[i] <= '9') || str[i] == '-' || str[i] == '+' || str[i] == '.' ) + { + if(flag == 0 ) + { + flag = 1; + count ++; + if(count > mxCount) break; + } + } + else + { + if(flag != 1) flag = 2; + } + } + + if(flag == 1) index1 ++; + + i++; + if(i >= strlen(str) ) + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + } + break; + } + } while(1); + return count; +} +//**************************************************************************** + +VisAtom_NewDisplacementPolicyDlg::VisAtom_NewDisplacementPolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + + QString title(tr("Choose the data for displacement of atoms")); + this->setWindowTitle(title); + + m_selcol[0] = m_selcol[1] = m_selcol[2] = -1; + m_fromF = m_toF = 0; + return; +} + +VisAtom_NewDisplacementPolicyDlg::~VisAtom_NewDisplacementPolicyDlg() +{ + +} + +int VisAtom_NewDisplacementPolicyDlg::SetFilename(QString fname,VisAtomDataSheet*pDataSheet) +{ + if(fname.isEmpty() || !pDataSheet) + { + VisAtom_NewDisplacementPolicyDlg::m_filename.clear(); + VisAtom_NewDisplacementPolicyDlg::m_startInd = -1; + VisAtom_NewDisplacementPolicyDlg::m_endInd = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[1] = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[2] = 1; + return ERR_NOTINDEXEDFILE; + } + + if(fname != this->ui.trajectfilenameEdit->text()) + { //file name has been changed + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[1] = -1; + this->ui.trajectfilenameEdit->setText(fname); + } + int from, to, step; + + if(VisAtom_NewDisplacementPolicyDlg::m_IndRng[0]<0) + { // no range have been extracted + from = 0; + to = 9999; + step = 1; + + //*** to find the start file + QString fileName, ext, snum; + int i; + for(i=from; i<=to; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = fname; + fileName.append(ext); + QFile file(fileName); + if (file.exists()) break; + } + + if(i>to) + { //no any file found + this->m_fromF = this->m_toF = 0; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = -1; + } + else + { + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = i; + from = i; + //to find the end file + for(i=from+step; i<=to+step; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = fname; + fileName.append(ext); + QFile file(fileName); + if (!file.exists()) break; + } + to = i-step; + this->m_fromF = this->m_toF = 1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[1] = to; + } + } + int err = this->FillPrevewTable(pDataSheet); + + + if(VisAtom_NewDisplacementPolicyDlg::m_startInd<0) from = 0; + else from = VisAtom_NewDisplacementPolicyDlg::m_startInd; + + if(VisAtom_NewDisplacementPolicyDlg::m_endInd<0) to = 9999; + else to = VisAtom_NewDisplacementPolicyDlg::m_endInd; + + step = VisAtom_NewDisplacementPolicyDlg::m_indStep; + + this->ui.trajectfromSpinBox->setValue(from); + this->ui.trajecttoSpinBox->setMinimum(VisAtom_NewDisplacementPolicyDlg::m_IndRng[0]); + this->ui.trajecttoSpinBox->setMaximum(VisAtom_NewDisplacementPolicyDlg::m_IndRng[1]); + this->ui.trajecttoSpinBox->setSingleStep(step); + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajectstepSpinBox->setValue(step); + + this->m_selcol[0] = VisAtom_NewDisplacementPolicyDlg::m_discol[0]; + this->m_selcol[1] = VisAtom_NewDisplacementPolicyDlg::m_discol[1]; + this->m_selcol[2] = VisAtom_NewDisplacementPolicyDlg::m_discol[2]; + this->UpdateUI(); + if(err != ERR_NOERROR) return err; + return ERR_NOERROR; + +} + +//***************************************************************************** +void VisAtom_NewDisplacementPolicyDlg::UpdateUI() +{ + int from = this->ui.trajectfromSpinBox->value(); + int to = this->ui.trajecttoSpinBox->value(); + QString fileName, snum, ext; + + if(!this->m_fromF) + { + this->ui.trajectfilefromLineEdit->setText(tr("not exist")); + + } + else + { + fileName = this->ui.trajectfilenameEdit->text(); + if(from<10) ext = ".000"; + else if(from<100) ext = ".00"; + else if(from<1000) ext = ".0"; + snum.setNum(from); + ext.append(snum); + fileName.append(ext); + this->ui.trajectfromSpinBox->setValue(from); + this->ui.trajectfilefromLineEdit->setText(fileName); + + } + + if(!this->m_toF) + { + this->ui.trajectfiletoLineEdit->setText(tr("not exist")); + } + else + { + fileName = this->ui.trajectfilenameEdit->text(); + if(to<10) ext = ".000"; + else if(to<100) ext = ".00"; + else if(to<1000) ext = ".0"; + snum.setNum(to); + ext.append(snum); + fileName.append(ext); + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajectfiletoLineEdit->setText(fileName); + } + //write the stat of the table + for(int i=0; im_selcol[i] >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(i, this->m_selcol[i]); + item->setCheckState(Qt::Checked); + } + //WriteColLabels + QString title; + if(this->m_selcol[0] >= 0) {title = tr("Col.#"); snum.setNum(this->m_selcol[0]+1); title.append(snum);} + else title = tr("N/A"); + ui.vxcolLabel->setText(title); + + if(this->m_selcol[1] >= 0) {title = tr("Col.#"); snum.setNum(this->m_selcol[1]+1); title.append(snum);} + else title = tr("N/A"); + ui.vycolLabel->setText(title); + + if(this->m_selcol[2] >= 0) {title = tr("Col.#"); snum.setNum(this->m_selcol[2]+1); title.append(snum);} + else title = tr("N/A"); + ui.vzcolLabel->setText(title); + + //enable or disable the okButton + if(this->m_fromF && this->m_toF && this->m_selcol[0] >=0 && this->m_selcol[1] >= 0 &&this->m_selcol[2]>= 0) + this->ui.okButton->setEnabled(true); + else + this->ui.okButton->setEnabled(false); + + +} +//******************************************************************************* +int VisAtom_NewDisplacementPolicyDlg::FillPrevewTable(VisAtomDataSheet*pDataSheet) +{ + + //to determine how many col for each line + int ncol=0, i,j; + + ncol = pDataSheet->GetNumCol(); + this->ui.datasheetTableWidget->clear(); + //set the header + QString title, snum; + QTableWidgetItem*hitem, *item; + this->ui.datasheetTableWidget->setColumnCount(ncol); + this->ui.datasheetTableWidget->setRowCount(MAXROW); + + for(i=0; iGetTypeCol()) + title.append(tr("(atom type)")); + else if(i == pDataSheet->GetPosXCol()) + title.append(tr("(pos x)")); + else if(i == pDataSheet->GetPosYCol()) + title.append(tr("(pos y)")); + else if(i == pDataSheet->GetPosZCol()) + title.append(tr("(pos z)")); + + hitem = new QTableWidgetItem(title); + ui.datasheetTableWidget->setHorizontalHeaderItem(i, hitem); + } + + + title.clear(); + item = new QTableWidgetItem(title); + this->ui.datasheetTableWidget->setVerticalHeaderItem(0, item); + title.append(tr("Dx")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + this->ui.datasheetTableWidget->setItem(0, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(1, item); + title.append(tr("Dy")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + this->ui.datasheetTableWidget->setItem(1, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(2, item); + title.append(tr("Dz")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + this->ui.datasheetTableWidget->setItem(2, i, item); + } + + + for(j=HEADROWS; jGetNumRow())-2; j++) + { + snum.setNum(j-HEADROWS+1); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(j, item); + + for(i=0; iGetData(i)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item = new QTableWidgetItem(snum); + this->ui.datasheetTableWidget->setItem(j, i, item); + } + } + + if(pDataSheet->GetNumRow() >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(pDataSheet->GetNumRow()); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; iGetData(i); + snum.setNum(cdata[pDataSheet->GetNumRow()-1], 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + } + return 0; +} + + +void VisAtom_NewDisplacementPolicyDlg::OnDatasheetChanged(QTableWidgetItem*item) +{ + int col = item->column(); + int row = item->row(); + int checked = item->checkState(); + if(row >= HEADROWS) return; + + if(checked) + { + int i; + for(i=0; icolumnCount(); i++) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(row, i); + if(i != col) item->setCheckState(Qt::Unchecked); + } + //in this case, we permit the same colume for are chosen + /*for(i=0; iitem(i, col); + if(i != row) item->setCheckState(Qt::Unchecked); + }*/ + + ////////////////////////////////////// + m_selcol[row] = col; + } + else //unchecked + { + m_selcol[row] = -1; + } + this->UpdateUI(); + + return; +} + +bool VisAtom_NewDisplacementPolicyDlg::HasTrajectData() +{ + if(VisAtom_NewDisplacementPolicyDlg::m_filename.isEmpty() || + VisAtom_NewDisplacementPolicyDlg::m_startInd < 0 || + VisAtom_NewDisplacementPolicyDlg::m_endInd < 0 ) + return false; + else return true; +} + +void VisAtom_NewDisplacementPolicyDlg::OnFromChanged(int from) +{ + + QString snum, ext, fileName; + int i, to, step; + if(from<10) ext = ".000"; + else if(from<100) ext = ".00"; + else if(from<1000) ext = ".0"; + + snum.setNum(from); + ext.append(snum); + fileName = this->ui.trajectfilenameEdit->text(); + fileName.append(ext); + QFile file(fileName); + if(!file.exists()) + { + this->m_fromF = 0; + } + else + { + this->ui.trajectfilefromLineEdit->setText(fileName); + step = this->ui.trajectstepSpinBox->value(); + //to find the end file + to = 9999; + for(i=from+step; i<=to+step; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = this->ui.trajectfilenameEdit->text(); + fileName.append(ext); + file.setFileName(fileName); + if (!file.exists()) break; + } + to = i-step; + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajecttoSpinBox->setMinimum(from); + this->ui.trajecttoSpinBox->setMaximum(to); + + this->m_fromF = this->m_toF = 1; + } + this->UpdateUI(); + return; +} + +void VisAtom_NewDisplacementPolicyDlg::OnStepChanged(int step) +{ + QString fileName, ext, snum; + QFile file; + //to find the end file + int i, from, to = 9999; + from = this->ui.trajectfromSpinBox->value(); + for(i=from+step; i<=to+step; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = this->ui.trajectfilenameEdit->text(); + fileName.append(ext); + file.setFileName(fileName); + if (!file.exists()) break; + } + to = i-step; + this->ui.trajecttoSpinBox->setMaximum(to); + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajecttoSpinBox->setSingleStep(step); + this->UpdateUI(); + return; +} + + +void VisAtom_NewDisplacementPolicyDlg::accept() +{ + VisAtom_NewDisplacementPolicyDlg::m_filename = this->ui.trajectfilenameEdit->text(); + VisAtom_NewDisplacementPolicyDlg::m_startInd = this->ui.trajectfromSpinBox->value(); + VisAtom_NewDisplacementPolicyDlg::m_endInd = this->ui.trajecttoSpinBox->value(); + VisAtom_NewDisplacementPolicyDlg::m_discol[0] = this->m_selcol[0]; + VisAtom_NewDisplacementPolicyDlg::m_discol[1] = this->m_selcol[1]; + VisAtom_NewDisplacementPolicyDlg::m_discol[2] = this->m_selcol[2]; + VisAtom_NewDisplacementPolicyDlg::m_indStep = this->ui.trajectstepSpinBox->value(); + QDialog::accept(); +} + + diff --git a/VisAtom2017/sor/visatom_newdisplacementdlg.h b/VisAtom2017/sor/visatom_newdisplacementdlg.h new file mode 100644 index 0000000..b24871a --- /dev/null +++ b/VisAtom2017/sor/visatom_newdisplacementdlg.h @@ -0,0 +1,73 @@ +#ifndef VISATOMNEWDISPLACEMENTPOLICY_H +#define VISATOMNEWDISPLACEMENTPOLICY_H + +#include +#include + +#include "Ui_visatom_newdisplacementDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewDisplacementPolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + + static int m_discol[3]; + static QString m_filename; + static int m_startInd; + static int m_endInd; + static int m_indStep; + static int m_IndRng[3]; //available file index + +public: + VisAtom_NewDisplacementPolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewDisplacementPolicyDlg(); + + static void GetDisplacementColume(int dcol[3]) + { + dcol[0] = m_discol[0]; + dcol[1] = m_discol[1]; + dcol[2] = m_discol[2]; + } + static void GetDisplacementColume(int& dx, int& dy, int& dz) + { + dx = m_discol[0]; + dy = m_discol[1]; + dz = m_discol[2]; + } + + static int GetStartInd() {return m_startInd;}; + static int GetEndInd() {return m_endInd;}; + static int GetIndexStep() {return m_indStep;}; + static QString GetFname() {return m_filename;}; + + enum ERRORCODE + { + ERR_NOERROR = 0, + ERR_NOTINDEXEDFILE = 1, + ERR_INCONSISTENTFOMAT = 2, + }; + + + int SetFilename(QString fname,VisAtomDataSheet*pDataSheet); + static bool HasTrajectData(); + +private slots: + void UpdateUI(); + int FillPrevewTable(VisAtomDataSheet*pDataSheet); + void OnDatasheetChanged(QTableWidgetItem*); + void OnFromChanged(int from); + void OnStepChanged(int step); + void accept(); + +private: + Ui::visatom_newdisplacementpolicyForm ui; + int m_selcol[3]; + int m_fromF, m_toF; + +}; + +#endif // VISATOMNEWVECTORPOLICY_H diff --git a/VisAtom2017/sor/visatom_newsizepolicydlg.cpp b/VisAtom2017/sor/visatom_newsizepolicydlg.cpp new file mode 100644 index 0000000..5590308 --- /dev/null +++ b/VisAtom2017/sor/visatom_newsizepolicydlg.cpp @@ -0,0 +1,176 @@ +#include "VisAtom_NewSizePolicyDlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomSubsample.h" +#include "math.h" + + +double VisAtom_NewSizePolicyDlg::m_datamin = 1e8; +double VisAtom_NewSizePolicyDlg::m_datamax = 0; +int VisAtom_NewSizePolicyDlg::m_datacol = -1; + +VisAtom_NewSizePolicyDlg::VisAtom_NewSizePolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + if(VisAtom_NewSizePolicyDlg::m_datamax > VisAtom_NewSizePolicyDlg::m_datamin) + { + QString snum; + snum.setNum(VisAtom_NewSizePolicyDlg::m_datamin, 'e', 4); + ui.dataminLabel->setText(snum); + snum.setNum(VisAtom_NewSizePolicyDlg::m_datamax, 'e', 4); + ui.datamaxLabel->setText(snum); + } + QString title(tr("Edit scalar range for atom radia")); + this->setWindowTitle(title); + + return; +} + +VisAtom_NewSizePolicyDlg::~VisAtom_NewSizePolicyDlg() +{ + +} + + +void VisAtom_NewSizePolicyDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + #define MAXROW 100 + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + int*colprop = this->m_SampleDataSheet->GetColProp(); + + int i, j; + QString title, snum; + + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row)); + for(i=0; isetHorizontalHeaderItem(i, hitem); + } + + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[j]+0.000001)); + else + snum.setNum(cdata[j], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[row-1]+0.000001)); + else + snum.setNum(cdata[row-1], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + + } + ui.datasheetTableWidget->selectColumn(this->m_datacol); + + ui.numrowSpinBox->setValue(row); + + if(this->m_datacol<0 ||this->m_datamin <0) ui.okButton->setEnabled(false); + + return; +} + +void VisAtom_NewSizePolicyDlg::OnTableSelected() +{ + int col = ui.datasheetTableWidget->currentColumn(); + if(col < 0) return; + + int i,j; + double fmin, fmax; + float*pdat = this->m_SampleDataSheet->GetData(col); + + fmin = 1.e10; + fmax =-1.e10; + + for(i=0; im_SampleDataSheet->GetNumRow(); i++) + { + if(pdat[i] > fmax) fmax = pdat[i]; + if(pdat[i] < fmin) fmin = pdat[i]; + } + + QString snum; + snum.setNum(fmin, 'e', 4); + ui.dataminLabel->setText(snum); + snum.setNum(fmax, 'e', 4); + ui.datamaxLabel->setText(snum); + + this->m_datacol = col; + this->m_datamin = fmin; + this->m_datamax = fmin; + if(fmin < 0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + + QString msg("Warnning"); + msgBox.setText("Radius cannot be negative"); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + ui.okButton->setEnabled(false); + } + else + { + ui.okButton->setEnabled(true); + } + + return; +} + + diff --git a/VisAtom2017/sor/visatom_newsizepolicydlg.h b/VisAtom2017/sor/visatom_newsizepolicydlg.h new file mode 100644 index 0000000..b20beef --- /dev/null +++ b/VisAtom2017/sor/visatom_newsizepolicydlg.h @@ -0,0 +1,39 @@ +#ifndef VISATOMNEWSIZEPOLICY_H +#define VISATOMNEWSIZEPOLICY_H + +#include +#include "ui_visatom_newsizepolicyDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewSizePolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + static double m_datamin, m_datamax; + static int m_datacol; + +public: + VisAtom_NewSizePolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewSizePolicyDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + + void GetData(int&col, float&min, float&max) + { + col = m_datacol; min = m_datamin; max = m_datamax; + } + +private slots: + + void OnTableSelected(); + +private: + Ui::visatom_newsizepolicyForm ui; + +}; + +#endif // VISATOMNEWSIZEPOLICY_H diff --git a/VisAtom2017/sor/visatom_newvectorpolicydlg.cpp b/VisAtom2017/sor/visatom_newvectorpolicydlg.cpp new file mode 100644 index 0000000..6b3b918 --- /dev/null +++ b/VisAtom2017/sor/visatom_newvectorpolicydlg.cpp @@ -0,0 +1,217 @@ +#include "visatom_newvectorpolicydlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSubsample.h" +#include + +int VisAtom_NewVectorPolicyDlg::m_vcol[3]={-1,-1,-1}; +#define MAXROW 53 +#define HEADROWS 3 +#define BKR 220 +#define BKG 220 +#define BKB 220 + +VisAtom_NewVectorPolicyDlg::VisAtom_NewVectorPolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + + QString title(tr("Choose the data for vector for visualizing")); + this->setWindowTitle(title); + + return; +} + +VisAtom_NewVectorPolicyDlg::~VisAtom_NewVectorPolicyDlg() +{ + +} + +void VisAtom_NewVectorPolicyDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + + int i, j; + QString title, snum; + QTableWidgetItem*hitem, *item; + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row)); + + //reserve the previous selection + int oldcol[HEADROWS]; + for(i=0; iGetTypeCol()) + title.append(tr("(atom type)")); + else if(i == pData->GetPosXCol()) + title.append(tr("(pos x)")); + else if(i == pData->GetPosYCol()) + title.append(tr("(pos y)")); + else if(i == pData->GetPosZCol()) + title.append(tr("(pos z)")); + + hitem = new QTableWidgetItem(title); + ui.datasheetTableWidget->setHorizontalHeaderItem(i, hitem); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(0, item); + title.append(tr("Vx")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(0, i, item); + } + + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(1, item); + title.append(tr("Vy")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(1, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(2, item); + title.append(tr("Vz")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(2, i, item); + } + + for(j=HEADROWS; jsetVerticalHeaderItem(j, item); + + for(i=0; im_SampleDataSheet->GetData(i)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + snum.setNum(cdata[row-1], 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + } + + for(i=0; im_vcol[i] = oldcol[i]; + if(this->m_vcol[i] >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(i, this->m_vcol[i]); + item->setCheckState(Qt::Checked); + } + } + return; +} + +void VisAtom_NewVectorPolicyDlg::OnDatasheetChanged(QTableWidgetItem*item) +{ + int col = item->column(); + int row = item->row(); + int checked = item->checkState(); + if(row >= HEADROWS) return; + + if(checked) + { + int i; + for(i=0; icolumnCount(); i++) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(row, i); + if(i != col) item->setCheckState(Qt::Unchecked); + } + //in this case, we permit the same colume for are chosen + /*for(i=0; iitem(i, col); + if(i != row) item->setCheckState(Qt::Unchecked); + }*/ + + ////////////////////////////////////// + m_vcol[row] = col; + } + else //unchecked + { + m_vcol[row] = -1; + } + //write the col labels + WriteColLabels(); + if( this->m_vcol[0]>=0 && this->m_vcol[1]>=0 && this->m_vcol[2]>= 0) + ui.okButton->setEnabled(true); + else + ui.okButton->setEnabled(false); + + return; +} + +void VisAtom_NewVectorPolicyDlg::WriteColLabels() +{ + //write the col labels + QString title, snum; + + if(this->m_vcol[0] >= 0) {title = tr("Col.#"); snum.setNum(this->m_vcol[0]+1); title.append(snum);} + else title = tr("N/A"); + ui.vxcolLabel->setText(title); + + if(this->m_vcol[1] >= 0) {title = tr("Col.#"); snum.setNum(this->m_vcol[1]+1); title.append(snum);} + else title = tr("N/A"); + ui.vycolLabel->setText(title); + + if(this->m_vcol[2] >= 0) {title = tr("Col.#"); snum.setNum(this->m_vcol[2]+1); title.append(snum);} + else title = tr("N/A"); + ui.vzcolLabel->setText(title); + + return; +} + + + + diff --git a/VisAtom2017/sor/visatom_newvectorpolicydlg.h b/VisAtom2017/sor/visatom_newvectorpolicydlg.h new file mode 100644 index 0000000..c084068 --- /dev/null +++ b/VisAtom2017/sor/visatom_newvectorpolicydlg.h @@ -0,0 +1,45 @@ +#ifndef VISATOMNEWVECTORPOLICY_H +#define VISATOMNEWVECTORPOLICY_H + +#include +#include "Ui_visatom_newvectorpolicyDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewVectorPolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + + static int m_vcol[3]; +public: + VisAtom_NewVectorPolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewVectorPolicyDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + static void GetVectorColume(int vcol[3]) + { + vcol[0] = m_vcol[0]; + vcol[1] = m_vcol[1]; + vcol[2] = m_vcol[2]; + } + static void GetVectorColume(int& vx, int& vy, int& vz) + { + vx = m_vcol[0]; + vy = m_vcol[1]; + vz = m_vcol[2]; + } + +private slots: + void OnDatasheetChanged(QTableWidgetItem*); + void WriteColLabels(); + +private: + Ui::visatom_newvectorpolicyForm ui; + +}; + +#endif // VISATOMNEWVECTORPOLICY_H diff --git a/VisAtom2017/sor/visatom_selectsampledataDlg.cpp b/VisAtom2017/sor/visatom_selectsampledataDlg.cpp new file mode 100644 index 0000000..abaa457 --- /dev/null +++ b/VisAtom2017/sor/visatom_selectsampledataDlg.cpp @@ -0,0 +1,326 @@ +#include +#include "VisAtom_SelectSampleDataDlg.h" +#include "VisAtomDataSheet.h" + +int VisAtom_SelectSampleDataDlg::m_showthisdlg = 1; +int VisAtom_SelectSampleDataDlg::m_coltype = -1; +int VisAtom_SelectSampleDataDlg::m_colx = -1; +int VisAtom_SelectSampleDataDlg::m_coly = -1; +int VisAtom_SelectSampleDataDlg::m_colz = -1; + +VisAtom_SelectSampleDataDlg::VisAtom_SelectSampleDataDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + QString title(tr("Choose data from datasheet for sample data")); + this->setWindowTitle(title); + + return; +} + +VisAtom_SelectSampleDataDlg::~VisAtom_SelectSampleDataDlg() +{ + +} + +#define MAXROW 54 +#define HEADROWS 4 +#define BKR 220 +#define BKG 220 +#define BKB 220 +void VisAtom_SelectSampleDataDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + + int i, j; + QString title, snum; + QTableWidgetItem*hitem, *item; + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row+HEADROWS)); + + //reserve the previous selection + int oldtype = this->m_coltype; + int oldx = this->m_colx; + int oldy = this->m_coly; + int oldz = this->m_colz; + + for(i=0; isetHorizontalHeaderItem(i, hitem); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(0, item); + title.append(tr("type")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(0, i, item); + } + + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(1, item); + title.append(tr("X")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(1, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(2, item); + title.append(tr("Y")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(2, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(3, item); + title.append(tr("Z")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(3, i, item); + } + + //for(j=HEADROWS; jrow) break; + + snum.setNum(j-HEADROWS+1); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(j, item); + + for(i=0; im_SampleDataSheet->GetData(i)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + snum.setNum(cdata[row-1], 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + } + + this->m_coltype = oldtype; + this->m_colx = oldx; + this->m_coly = oldy; + this->m_colz = oldz; + + //set the check state + if(this->m_coltype >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(0, this->m_coltype); + item->setCheckState(Qt::Checked); + } + //set the check state + if(this->m_colx >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(1, this->m_colx); + item->setCheckState(Qt::Checked); + } + //set the check state + if(this->m_coly >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(2, this->m_coly); + item->setCheckState(Qt::Checked); + } + //set the check state + if(this->m_colz >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(3, this->m_colz); + item->setCheckState(Qt::Checked); + } + return; +} + +void VisAtom_SelectSampleDataDlg::OnDatasheetChanged(QTableWidgetItem*item) +{ + int col = item->column(); + int row = item->row(); + int checked = item->checkState(); + if(row >= HEADROWS) return; + + if(checked) + { + int i; + for(i=0; icolumnCount(); i++) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(row, i); + if(i != col) item->setCheckState(Qt::Unchecked); + } + for(i=0; iitem(i, col); + if(i != row) item->setCheckState(Qt::Unchecked); + } + + if(row == 0) //type is selected + { + QString snum; + int j; + //restore the float format if type colume select before; + if(this->m_coltype >=0) + { + QString snum; + int j; + //for(j=HEADROWS; jGetNumRow())-2; j++) + for(j=HEADROWS; j m_SampleDataSheet->GetNumRow()) break; + + QTableWidgetItem*item = ui.datasheetTableWidget->item(j, this->m_coltype); + float cdata = this->m_SampleDataSheet->GetData(this->m_coltype)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item->setText(snum); + } + if(m_SampleDataSheet->GetNumRow() >MAXROW-2) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(MAXROW-1, this->m_coltype); + float cdata = this->m_SampleDataSheet->GetData(this->m_coltype)[m_SampleDataSheet->GetNumRow()-1]; + snum.setNum(cdata, 'e', 5); + item->setText(snum); + } + } + + //for(j=HEADROWS; jGetNumRow())-2; j++) + for(j=HEADROWS; j m_SampleDataSheet->GetNumRow()) break; + QTableWidgetItem*item = ui.datasheetTableWidget->item(j, col); + int ityp = this->m_SampleDataSheet->GetData(col)[j-HEADROWS] + 0.000001; + snum.setNum(ityp); + item->setText(snum); + } + if(m_SampleDataSheet->GetNumRow() >MAXROW-2) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(MAXROW-1, col); + int ityp = this->m_SampleDataSheet->GetData(col)[m_SampleDataSheet->GetNumRow()-1] + 0.000001; + snum.setNum(ityp); + item->setText(snum); + } + // + } + ////////////////////////////////////// + switch(row) + { + case VisAtomDataSheet::COLPROP_TYPE: + this->m_coltype = col; + break; + case VisAtomDataSheet::COLPROP_POSX: + this->m_colx = col; + break; + case VisAtomDataSheet::COLPROP_POSY: + this->m_coly = col; + break; + case VisAtomDataSheet::COLPROP_POSZ: + this->m_colz = col; + break; + } + } + else //unchecked + { + switch(row) + { + case VisAtomDataSheet::COLPROP_TYPE: + this->m_coltype = -1; + break; + case VisAtomDataSheet::COLPROP_POSX: + this->m_colx = -1; + break; + case VisAtomDataSheet::COLPROP_POSY: + this->m_coly = -1; + break; + case VisAtomDataSheet::COLPROP_POSZ: + this->m_colz = -1; + break; + } + } + //write the col labels + WriteColLabels(); + //if( this->m_coltype>=0 && this->m_colx>=0 && this->m_coly>= 0 && this->m_colz >= 0) + if( this->m_colx>=0 && this->m_coly>= 0 && this->m_colz >= 0) + ui.okButton->setEnabled(true); + else + ui.okButton->setEnabled(false); + + return; +} + +void VisAtom_SelectSampleDataDlg::WriteColLabels() +{ + //write the col labels + QString title, snum; + + if(this->m_coltype >= 0) {title = tr("Col.#"); snum.setNum(this->m_coltype+1); title.append(snum);} + else title = tr("N/A"); + ui.coltypeLabel->setText(title); + + if(this->m_colx >= 0) {title = tr("Col.#"); snum.setNum(this->m_colx+1); title.append(snum);} + else title = tr("N/A"); + ui.colxLabel->setText(title); + + if(this->m_coly >= 0) {title = tr("Col.#"); snum.setNum(this->m_coly+1); title.append(snum);} + else title = tr("N/A"); + ui.colyLabel->setText(title); + + if(this->m_colz >= 0) {title = tr("Col.#"); snum.setNum(this->m_colz+1); title.append(snum);} + else title = tr("N/A"); + ui.colzLabel->setText(title); + + return; +} + +void VisAtom_SelectSampleDataDlg::OnShowAgainCheckBox(bool no) +{ + m_showthisdlg = !no; +} + diff --git a/VisAtom2017/sor/visatom_selectsampledataDlg.h b/VisAtom2017/sor/visatom_selectsampledataDlg.h new file mode 100644 index 0000000..77b3808 --- /dev/null +++ b/VisAtom2017/sor/visatom_selectsampledataDlg.h @@ -0,0 +1,44 @@ +#ifndef VISATOMSELECTSAMPLEDATA_H +#define VISATOMSELECTSAMPLEDATA_H + +#include +#include "Ui_visatom_selectsampledataDlg.h" + +class VisAtomDataSheet; +class VisAtom_SelectSampleDataDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + + static int m_coltype, m_colx, m_coly, m_colz; + static int m_showthisdlg; +public: + VisAtom_SelectSampleDataDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_SelectSampleDataDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + static void GetDataCol(int col[4]) + { + col[0] = m_coltype; + col[1] = m_colx; + col[2] = m_coly; + col[3] = m_colz; + } + + static bool IsShowAgain(){return m_showthisdlg;} + + +private slots: + void OnDatasheetChanged(QTableWidgetItem*item); + void OnShowAgainCheckBox(bool no); + void WriteColLabels(); + + +private: + Ui::visatom_selectsampledataDlg ui; + +}; + +#endif // VISATOMNEWVECTORPOLICY_H diff --git a/VisAtom2017/sor/visatomaboutdlg.cpp b/VisAtom2017/sor/visatomaboutdlg.cpp new file mode 100644 index 0000000..38eda05 --- /dev/null +++ b/VisAtom2017/sor/visatomaboutdlg.cpp @@ -0,0 +1,12 @@ +#include "visatomaboutdlg.h" + +VisAtomAboutDlg::VisAtomAboutDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); +} + +VisAtomAboutDlg::~VisAtomAboutDlg() +{ + +} diff --git a/VisAtom2017/sor/visatomaboutdlg.h b/VisAtom2017/sor/visatomaboutdlg.h new file mode 100644 index 0000000..fe97928 --- /dev/null +++ b/VisAtom2017/sor/visatomaboutdlg.h @@ -0,0 +1,19 @@ +#ifndef VISATOMABOUTDLG_H +#define VISATOMABOUTDLG_H + +#include +#include "ui_visatomaboutdlg.h" + +class VisAtomAboutDlg : public QDialog +{ + Q_OBJECT + +public: + VisAtomAboutDlg(QWidget *parent = Q_NULLPTR); + ~VisAtomAboutDlg(); + +private: + Ui::visatomaboutForm ui; +}; + +#endif // VISATOMABOUTDLG_H diff --git a/VisAtom2017/visatom2017.qrc b/VisAtom2017/visatom2017.qrc new file mode 100644 index 0000000..5ff4f23 --- /dev/null +++ b/VisAtom2017/visatom2017.qrc @@ -0,0 +1,28 @@ + + + images/solidsphere.png + images/adjustsize.png + images/fit-page-32.png + images/SCUlogo.png + images/cursor-sizeh.png + images/cursor-sizev.png + images/cursor-sizeb.png + images/next.png + images/prev.png + images/colormap.png + images/copy.png + images/scenestyle2.png + images/scenestyle3.png + images/zoomin.png + images/scenestyle1.png + images/SCUlogo1.png + images/About1.png + VisAtoms21.ico + images/rotationx.png + images/adjustsize.png + images/rotationy.png + images/rotationz.png + images/copy.png + images/open.png + + diff --git a/VisAtom2017/visatom_atomfilterDlg.ui b/VisAtom2017/visatom_atomfilterDlg.ui new file mode 100644 index 0000000..f3a233a --- /dev/null +++ b/VisAtom2017/visatom_atomfilterDlg.ui @@ -0,0 +1,143 @@ + + + visatom_atomfilterDlg + + + Qt::WindowModal + + + + 0 + 0 + 539 + 236 + + + + Atom filter + + + true + + + false + + + + + + + + QAbstractItemView::NoSelection + + + + 1 + + + + + + + + + Tab 1 + + + + + 10 + 10 + 71 + 16 + + + + CheckBox + + + + + + Tab 2 + + + + + + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + okButton + clicked() + visatom_atomfilterDlg + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + visatom_atomfilterDlg + reject() + + + 369 + 253 + + + 179 + 282 + + + + + diff --git a/VisAtom2017/visatom_atomfilterdlg.cpp b/VisAtom2017/visatom_atomfilterdlg.cpp new file mode 100644 index 0000000..04d2c8e --- /dev/null +++ b/VisAtom2017/visatom_atomfilterdlg.cpp @@ -0,0 +1,17 @@ +#include "visatom_atomfilterdlg.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomTrajectory.h" + +Visatom_AtomfilterDlg::Visatom_AtomfilterDlg(QWidget *parent) + :QDialog(parent) +{ + ui.setupUi(this); + +} + +Visatom_AtomfilterDlg::~Visatom_AtomfilterDlg() +{ + +} + diff --git a/VisAtom2017/visatom_atomfilterdlg.h b/VisAtom2017/visatom_atomfilterdlg.h new file mode 100644 index 0000000..4dcc712 --- /dev/null +++ b/VisAtom2017/visatom_atomfilterdlg.h @@ -0,0 +1,21 @@ +#ifndef VISATOM_ATOM_FILTER_H +#define VISATOM_ATOM_FILTER_H + +#include +#include "ui_visatom_atomfilterDlg.h" + +//class VisAtomSample; +class Visatom_AtomfilterDlg : public QDialog +{ + Q_OBJECT + +public: + Visatom_AtomfilterDlg(QWidget *parent = Q_NULLPTR); + ~Visatom_AtomfilterDlg(); + + +private: + Ui::visatom_atomfilterDlg ui; +}; + +#endif // VISATOM_ATOM_FILTER_H diff --git a/VisAtom2017/visatom_atominfo.cpp b/VisAtom2017/visatom_atominfo.cpp new file mode 100644 index 0000000..5c49978 --- /dev/null +++ b/VisAtom2017/visatom_atominfo.cpp @@ -0,0 +1,179 @@ +#include "visatom_atominfo.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomTrajectory.h" + +VisAtom_AtomInfo::VisAtom_AtomInfo(QWidget *parent) + : QWidget(parent, Qt::FramelessWindowHint) +{ + ui.setupUi(this); + +} + +VisAtom_AtomInfo::~VisAtom_AtomInfo() +{ + +} + +void VisAtom_AtomInfo::ShowAtomInfo(int posx, int posy, VisAtomSample*pSample, int atomid) +{ + this->ui.treeWidget->clear(); + + int col; + if(atomid >0) + { + + QString snum, snum0; + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, tr("ATOM ID:")); + snum.setNum(atomid); + item->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item); + + //following the index should minus 1 + VisAtomDataSheet*pDataSheet = pSample->GetDataSheet(); + atomid = atomid-1; + //type + QTreeWidgetItem*item1 = new QTreeWidgetItem(); + item1->setText(0, tr("TYPE ID:")); + col = pDataSheet->GetTypeCol(); + if(col >= 0) + snum.setNum((int)(pDataSheet->GetData(col)[atomid]+0.00001)); + else + snum.setNum(1); + item1->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item1); + + //postion + QTreeWidgetItem*itemx = new QTreeWidgetItem(); + itemx->setText(0, tr("POS-x:")); + col = pDataSheet->GetPosXCol(); + snum.setNum(pDataSheet->GetData(col)[atomid],'e',4); + itemx->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(itemx); + QTreeWidgetItem*itemy = new QTreeWidgetItem(); + itemy->setText(0, tr("POS-y:")); + col = pDataSheet->GetPosYCol(); + snum.setNum(pDataSheet->GetData(col)[atomid],'e',4); + itemy->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(itemy); + //snum.append(tr(", ")); + QTreeWidgetItem*itemz = new QTreeWidgetItem(); + itemz->setText(0, tr("POS-z:")); + col = pDataSheet->GetPosZCol(); + snum.setNum(pDataSheet->GetData(col)[atomid],'e',4); + itemz->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(itemz); + + //scalar + QTreeWidgetItem*item3 = new QTreeWidgetItem(); + item3->setText(0, tr("SCARLAR:")); + col = VisAtomVisualizingPolicy::GetScalarCol(); + if(col >=0) + snum.setNum(pDataSheet->GetData(col)[atomid], 'e', 6); + else + snum = tr("undefined"); + item3->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item3); + + //vector + QTreeWidgetItem*item4 = new QTreeWidgetItem(); + item4->setText(0, tr("VECTOR:")); + int vcol[3]; + VisAtomVisualizingPolicy::GetVectorCol(vcol); + if(vcol[0]>=0 && vcol[1]>=0 && vcol[2]>=0) + { + snum = tr("("); + snum0.setNum(pDataSheet->GetData(vcol[0])[atomid], 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(pDataSheet->GetData(vcol[1])[atomid], 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(pDataSheet->GetData(vcol[2])[atomid], 'e',4); + snum.append(snum0); + snum.append(tr(")")); + } + else + snum = tr("undefined"); + item4->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item4); + + //trajectory displacement + VisAtomTrajectory*trajectoryDate = pSample->GetTrajectoryData(); + QTreeWidgetItem*item5 = new QTreeWidgetItem(); + item5->setText(0, tr("DISPLACEMENT:")); + float dx, dy, dz, len; + if(trajectoryDate) + { + if(trajectoryDate->GetDisplacement(atomid,dx,dy,dz)) + { + snum = tr("("); + snum0.setNum(dx, 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(dy, 'e',4); + snum.append(snum0); + snum.append(tr(", ")); + snum0.setNum(dz, 'e',4); + snum.append(snum0); + snum.append(tr("), len=")); + snum0.setNum(pow(dx*dx+dy*dy+dz*dz,0.5f), 'e',4); + snum.append(snum0); + } + else + snum = tr("undefined"); + } + else + snum = tr("undefined"); + item5->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item5); + + //trajectory length + QTreeWidgetItem*item6 = new QTreeWidgetItem(); + item6->setText(0, tr("PATH LEN:")); + if(trajectoryDate) + { + if(trajectoryDate->GetPathlength(atomid,len)) + snum.setNum(len, 'e',4); + else + snum = tr("undefined"); + } + else + snum = tr("undefined"); + item6->setText(1, snum); + this->ui.treeWidget->addTopLevelItem(item6); + + } + else + { + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, tr("ID")); + item->setText(1, tr("No atom picked")); + this->ui.treeWidget->addTopLevelItem(item); + } + + QRect rect = this->rect(); + QRect rect0 = QApplication::desktop()->screenGeometry(); + if(posx + rect.width() > rect0.width()) posx = posx - rect.width(); + if(posy + rect.height() > rect0.height()) posy = posy - rect.height(); + rect.moveTo(posx, posy); + //this->setGeometry(rect); + this->move(posx, posy); + this->show(); + +} + +void VisAtom_AtomInfo::StartPickAtomInfo(int posx, int posy) +{ + this->ui.treeWidget->clear(); + + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, tr("Pick atom,....")); + this->ui.treeWidget->addTopLevelItem(item); + + QRect rect = this->rect(); + rect.moveTo(posx, posy); + this->setGeometry(rect); + this->show(); +} diff --git a/VisAtom2017/visatom_atominfo.h b/VisAtom2017/visatom_atominfo.h new file mode 100644 index 0000000..c95b460 --- /dev/null +++ b/VisAtom2017/visatom_atominfo.h @@ -0,0 +1,23 @@ +#ifndef VISATOM_ATOM_INFO_H +#define VISATOMABOUTDLG_H + +#include +#include "ui_visatom_atominfo.h" + +class VisAtomSample; +class VisAtom_AtomInfo : public QWidget +{ + Q_OBJECT + +public: + VisAtom_AtomInfo(QWidget *parent = Q_NULLPTR); + ~VisAtom_AtomInfo(); + + void StartPickAtomInfo(int posx, int posy); + void ShowAtomInfo(int posx, int posy,VisAtomSample*pSample, int atomid); + +private: + Ui::visatom_atominfo ui; +}; + +#endif // VISATOMABOUTDLG_H diff --git a/VisAtom2017/visatom_atominfo.ui b/VisAtom2017/visatom_atominfo.ui new file mode 100644 index 0000000..6e72b42 --- /dev/null +++ b/VisAtom2017/visatom_atominfo.ui @@ -0,0 +1,113 @@ + + + visatom_atominfo + + + Qt::WindowModal + + + + 0 + 0 + 430 + 145 + + + + + 0 + 0 + + + + + 100 + 100 + + + + + 40 + 40 + + + + Atom information + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + true + + + + 0 + + + 0 + + + + + + Microsoft Sans Serif + 8 + + + + QFrame::StyledPanel + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAsNeeded + + + true + + + true + + + QAbstractItemView::ScrollPerPixel + + + true + + + 2 + + + false + + + false + + + false + + + true + + + + 1 + + + + + 2 + + + + + + + + + + + diff --git a/VisAtom2017/visatom_findatomDlg.ui b/VisAtom2017/visatom_findatomDlg.ui new file mode 100644 index 0000000..41c0ca1 --- /dev/null +++ b/VisAtom2017/visatom_findatomDlg.ui @@ -0,0 +1,174 @@ + + + visatom_findatomDlg + + + + 0 + 0 + 242 + 300 + + + + Find... + + + + + + Show found only + + + + + + + + + + + + + 0 + 0 + + + + Startat + + + + + + + 1 + + + 9999999 + + + + + + + Range + + + + + + + 1 + + + 9999999 + + + + + + + + + true + + + true + + + 2 + + + false + + + + 1 + + + + + 2 + + + + + + + + + + groupselcomboBox + currentIndexChanged(int) + visatom_findatomDlg + OnGroupChanged(int) + + + 167 + 19 + + + 167 + 33 + + + + + fromatomspinBox + valueChanged(int) + visatom_findatomDlg + OnStartatomChanged(int) + + + 101 + 46 + + + 167 + 33 + + + + + widthspinBox + valueChanged(int) + visatom_findatomDlg + OnStepChanged(int) + + + 256 + 43 + + + 162 + 42 + + + + + showselectedonlycheckBox + stateChanged(int) + visatom_findatomDlg + OnShowOnlyChanged(int) + + + 162 + 71 + + + 162 + 44 + + + + + + OnFindatomchanged() + OnGroupChanged(int) + OnStartatomChanged(int) + OnStepChanged(int) + OnShowOnlyChanged(int) + OnToatomChanged(int) + + diff --git a/VisAtom2017/visatom_findatomdlg.cpp b/VisAtom2017/visatom_findatomdlg.cpp new file mode 100644 index 0000000..0284888 --- /dev/null +++ b/VisAtom2017/visatom_findatomdlg.cpp @@ -0,0 +1,253 @@ +#include "visatom_findatomdlg.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomWidget.h" + +static int ON_CHANGEGROUP = 0; + +Visatom_FindatomDlg::Visatom_FindatomDlg(QWidget *parent) + :QDialog(parent) +{ + ui.setupUi(this); + this->m_pVisAtomWidget = NULL; +} + +Visatom_FindatomDlg::~Visatom_FindatomDlg() +{ + this->m_pVisAtomWidget = NULL; + this->m_starta.clear(); + this->m_toa.clear(); + this->m_width.clear(); +} + +void Visatom_FindatomDlg::SetAtomSample(VisAtomWidget*theDisplay) +{ + + this->m_pVisAtomWidget = theDisplay; + if (!theDisplay) + { + this->setHidden(true); + return; + } + VisAtomSample*theSample = theDisplay->GetSample(); + + int grn=0, grind=-1, ng,i; + grn = this->ui.groupselcomboBox->count(); + if(grn > 0) grind = this->ui.groupselcomboBox->currentIndex(); + ng = theSample->NumberofSubsample(); + // + QListstarta; + QListwidth; + QListtoa; + for (i=0; i= this->m_starta.size()) break; + starta[i] = this->m_starta[i]; + width[i] = this->m_width[i]; + toa[i] = this->m_toa[i]; + } + this->m_starta.clear(); + this->m_width.clear(); + this->m_toa.clear(); + for(i=0; im_starta.append(starta[i]); + this->m_width.append(width[i]); + this->m_toa.append(toa[i]); + } + starta.clear(); + width.clear(); + toa.clear(); + + //update UI + this->ui.groupselcomboBox->clear(); + + QString str, snum; + str = "in whole box "; + this->ui.groupselcomboBox->addItem(str); + + for(i=0; iui.groupselcomboBox->addItem(str); + } + if (grind >= 0) + { + this->ui.groupselcomboBox->setCurrentIndex(grind); + } +} +void Visatom_FindatomDlg::setVisible(bool visible) +{ + + if (!this->m_pVisAtomWidget) + { + QDialog::setVisible(false); + return; + } + VisAtomSample*theSample = this->m_pVisAtomWidget->GetSample(); + if (!theSample) return; + + if (visible) + { + int gr; + gr = this->ui.groupselcomboBox->currentIndex(); + this->SetGroup(gr); + this->OnShowOnlyChanged(this->ui.showselectedonlycheckBox->isChecked()); + } + else + { + + theSample->RemoveAtomsFoundMark(); + theSample->ResetVisibility(); + } + QDialog::setVisible(visible); +} + +void Visatom_FindatomDlg::OnGroupChanged(int ind) +{ + if (ind < 0) return; + ON_CHANGEGROUP = 1; + this->SetGroup(ind); + this->ui.fromatomspinBox->setValue(this->m_starta[ind]); + this->ui.fromatomspinBox->setSingleStep(this->m_width[ind]); + this->ui.widthspinBox->setValue(this->m_width[ind]); + ON_CHANGEGROUP = 0; + this->m_pVisAtomWidget->update(); +} + +void Visatom_FindatomDlg::SetGroup(int ind) +{ + if (!this->m_pVisAtomWidget) return; + VisAtomSample*theSample = this->m_pVisAtomWidget->GetSample(); + if (!theSample) return; + + theSample->RemoveAtomsFoundMark(); + + int from, to, step; + from = this->m_starta[ind]; + to = from + this->m_width[ind]-1; + step = this->m_width[ind]; + if (ind == 0) + { + theSample->MarkAtomsFound(from, to, 1); + } + else + { + theSample->MarkGroupAtomsFound(ind, from, to); + } + //display the atom info + this->ui.atominfotreeWidget->clear(); + int gid, type; + float posx, posy, posz; + from = 0; + while (true) + { + theSample->GeNextAtomMarkedFound(from, gid, type, posx, posy, posz); + if (gid <= 0) break; + else + { + QString sname, snum, snum0; + QTreeWidgetItem*item = new QTreeWidgetItem(); + sname.clear(); + sname.append(tr("ATOM ID:")); + snum.setNum(gid); + item->setText(0, sname); + item->setText(1, snum); + this->ui.atominfotreeWidget->addTopLevelItem(item); + + //type + QTreeWidgetItem*itemtype = new QTreeWidgetItem(); + sname.clear(); + sname.append(tr("type: ")); + snum.setNum(type); + itemtype->setText(0, sname); + itemtype->setText(1, snum); + item->addChild(itemtype); + + //postion + QTreeWidgetItem*itemx = new QTreeWidgetItem(); + sname.clear(); + sname.append(tr("pos-x: ")); + snum.setNum(posx, 'e', 4); + itemx->setText(0, sname); + itemx->setText(1, snum); + item->addChild(itemx); + QTreeWidgetItem*itemy = new QTreeWidgetItem(); + sname.clear(); + sname.append(tr("pos-y: ")); + snum.setNum(posy, 'e', 4); + itemy->setText(0, sname); + itemy->setText(1, snum); + item->addChild(itemy); + QTreeWidgetItem*itemz = new QTreeWidgetItem(); + sname.clear(); + sname.append(tr("pos-z: ")); + snum.setNum(posz, 'e', 4); + itemz->setText(0, sname); + itemz->setText(1, snum); + item->addChild(itemz); + item->setExpanded(true); + } + + + from++; + } + + if(this->ui.showselectedonlycheckBox->isChecked()) + theSample->SetShowOnlyAtomsFound(true); +} + +void Visatom_FindatomDlg::OnStartatomChanged(int ind) +{ + int gr; + gr = this->ui.groupselcomboBox->currentIndex(); + this->m_starta[gr] = ind; + this->SetGroup(gr); + if(!ON_CHANGEGROUP) this->m_pVisAtomWidget->updateGL(); +} + +void Visatom_FindatomDlg::OnStepChanged(int ind) +{ + int gr; + gr = this->ui.groupselcomboBox->currentIndex(); + this->m_width[gr] = ind; + this->ui.fromatomspinBox->setSingleStep(this->m_width[gr]); + this->SetGroup(gr); + if (!ON_CHANGEGROUP) this->m_pVisAtomWidget->updateGL(); +} + +void Visatom_FindatomDlg::OnToatomChanged(int ind) +{ + int gr; + gr = this->ui.groupselcomboBox->currentIndex(); + this->m_toa[gr] = ind; + this->SetGroup(gr); + if (!ON_CHANGEGROUP) this->m_pVisAtomWidget->updateGL(); +} + +void Visatom_FindatomDlg::OnShowOnlyChanged(int stat) +{ + if (!this->m_pVisAtomWidget) return; + VisAtomSample*theSample = this->m_pVisAtomWidget->GetSample(); + if (!theSample) return; + + theSample->SetShowOnlyAtomsFound(stat); + if (!ON_CHANGEGROUP) this->m_pVisAtomWidget->updateGL(); +} + + + + + + + diff --git a/VisAtom2017/visatom_findatomdlg.h b/VisAtom2017/visatom_findatomdlg.h new file mode 100644 index 0000000..159c929 --- /dev/null +++ b/VisAtom2017/visatom_findatomdlg.h @@ -0,0 +1,42 @@ +#ifndef VISATOM_FINDATOM_H +#define VISATOM_FINDATOM_H + +#include +#include "ui_visatom_findatomDlg.h" + +class VisAtomWidget; +class Visatom_FindatomDlg : public QDialog +{ + Q_OBJECT + +public: + Visatom_FindatomDlg(QWidget *parent = Q_NULLPTR); + ~Visatom_FindatomDlg(); + void setVisible(bool); + + void SetAtomSample(VisAtomWidget*theSample); +protected: + VisAtomWidget * m_pVisAtomWidget; + QList m_starta; + QList m_toa; + QList m_width; + + void SetGroup(int); + +private slots: + + void OnGroupChanged(int); + void OnStartatomChanged(int); + void OnStepChanged(int); + void OnToatomChanged(int); + void OnShowOnlyChanged(int); + + +private: + Ui::visatom_findatomDlg ui; + +signals: + +}; + +#endif // VISATOM_FINDATOM_H diff --git a/VisAtom2017/visatom_loadtrajecoryThread.cpp b/VisAtom2017/visatom_loadtrajecoryThread.cpp new file mode 100644 index 0000000..f9524ea --- /dev/null +++ b/VisAtom2017/visatom_loadtrajecoryThread.cpp @@ -0,0 +1,516 @@ +#include +#include +#include "VisAtomTrajectory.h" +#include "VisAtomWidget.h" + + +VisAtom_LoadTrajecoryThread::VisAtom_LoadTrajecoryThread( QObject *parent) + : QThread(parent) +{ + m_pRender = NULL; + m_loaded = 0; + m_colx = m_coly = m_colz = -1; + +} + +VisAtom_LoadTrajecoryThread::~VisAtom_LoadTrajecoryThread() +{ + this->Clear(); + +} + +void VisAtom_LoadTrajecoryThread::Clear() +{ + m_pRender = NULL; + m_SampleFileList.clear(); + return; +} + +//*************************************************************** +void VisAtom_LoadTrajecoryThread::SetFileSerial(QString fname, int from, int to, int step, int colx, int coly, int colz) +{ + + m_SampleFileList.clear(); + + int i; + QString fileName, ext, snum; + for(i=from; i<=to;i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = fname; + fileName.append(ext); + m_SampleFileList.append(fileName); + } + m_loaded = 0; + m_colx = colx; + m_coly = coly; + m_colz = colz; + return; +} + +void VisAtom_LoadTrajecoryThread::AttachRender(VisAtomWidget*pRenader) +{ + this->m_pRender = pRenader; +} + + +QString VisAtom_LoadTrajecoryThread::GetFilename(int i) +{ + if(m_SampleFileList.isEmpty()) return tr(""); + if(i >= m_SampleFileList.size()) return tr(""); + return m_SampleFileList[i]; +} + +QString VisAtom_LoadTrajecoryThread::FirstFilename() +{ + if(m_SampleFileList.isEmpty()) return tr(""); + return m_SampleFileList[0]; +} +QString VisAtom_LoadTrajecoryThread::LasttFilename() +{ + if(m_SampleFileList.isEmpty()) return tr(""); + return m_SampleFileList[m_SampleFileList.size()-1]; +} + +int static extract_numb( char*str, int mxCount, char**strnumb) +{ +/* +! Purpose: to extract number from a string +! Input: STRING a string +! Ouput: COUNT the number of numbers found in the string +! REAL_NUMB the number text founded +! Note: the REAL_NUMBi are character varible. These character number +! could be transformed to real number by DRSTR or RSTRi +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + int i, flag, index1, count; + + count=0; + index1=0; + i = 0; + flag = 0; + do + { + if(str[i] == ' ' || str[i] == ',') + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + index1 = 0; + } + flag = 0; + } + else + { + if((str[i] >= '0' && str[i] <= '9') || str[i] == '-' || str[i] == '+' || str[i] == '.' ) + { + if(flag == 0 ) + { + flag = 1; + count ++; + if(count > mxCount) break; + } + } + else + { + if(flag != 1) flag = 2; + } + } + + if(flag == 1) index1 ++; + + i++; + if(i >= strlen(str) ) + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + } + break; + } + } while(1); + return count; +} + +#define MAXCOL 64 +#define MAXSTRL 32 +void VisAtom_LoadTrajecoryThread::StartLoadData() +{ + if(this->m_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, hlines; + char buf[MAXCOL*MAXSTRL]; + //determin the format of file + QFile file; + //open the first file to determine the format + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + hlines = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + if(len <= 0) {hlines++; continue;} + if(buf[0] == '&' && buf[1] == 'B' && buf[2] == 'O' && buf[3] == 'X'&& buf[4] == 'C'&& buf[5] == 'F'&& buf[6] == 'G'&& + buf[7] == '1' && buf[8] == '4') + { + LoadFrom_BOXCFG14(); + break; + } + + else + if(buf[0] == '&' && buf[1] == 'B' && buf[2] == 'O' && buf[3] == 'X'&& buf[4] == 'C'&& buf[5] == 'F'&& buf[6] == 'G'&& + buf[7] == '1' && buf[8] == '5') + { + LoadFrom_BOXCFG14(); + break; + } + else + if(buf[0] == '&' && buf[1] == 'B' && buf[2] == 'O' && buf[3] == 'X'&& buf[4] == 'C'&& buf[5] == 'F'&& buf[6] == 'G'&& + buf[7] == '1' && buf[8] == '6') + { + LoadFrom_BOXCFG16(); + break; + } + + else + { + LoadFrom_FMTUNKNOWN(); + break; + } + } + file.close(); +} + + +void VisAtom_LoadTrajecoryThread::LoadFrom_FMTUNKNOWN() +{ + if(this->m_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, flag, sline; + char buf[MAXCOL*MAXSTRL]; + char*strnumb[MAXCOL]; + for(i=0; im_SampleFileList[0], 0, this->m_SampleFileList.size()); + QFile file; + //open the first file to determine the number of cols and rows + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + sline = 0; + while (!file.atEnd()) + { + int len, lentrim; + len = file.readLine(buf, sizeof(buf))-1; + if(len <= 0) {sline++; continue;} + flag = 0; + lentrim = 0; + for(i=0; im_SampleFileList.size(); j++) + { + VisAtomDataSheet*pData = new VisAtomDataSheet(ncol, nrow); + int ncol1; + + file.setFileName(this->m_SampleFileList[j]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + //the lenth of the hearder for files could be different + //thus we should redetermine sline for each file + sline = 0; + while (!file.atEnd()) + { + int len, lentrim; + len = file.readLine(buf, sizeof(buf))-1; + if(len <= 0) {sline++; continue;} + flag = 0; + lentrim = 0; + for(i=0; iSetDataForRow(i, strnumb); + } + file.close(); + //add the data to the trajectory object + pData->SetPosxCol(this->m_colx); + pData->SetPosyCol(this->m_coly); + pData->SetPoszCol(this->m_colz); + pTrajectory->AddData(pData); + //The system down if we use GL here,why? + //this->m_pRender->updateGL(); + emit OnEndLoadFile(this->m_SampleFileList[j], j, this->m_SampleFileList.size()); + } + this->m_loaded = 1; + + //clear the temp data + for(i=0; im_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, flag, sline; + char buf[MAXCOL*MAXSTRL]; + char*strnumb[MAXCOL]; + for(i=0; im_SampleFileList[0], 0, this->m_SampleFileList.size()); + QFile file; + //open the first file to determine the number of cols and rows + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + flag = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + nrow = nrow+atoi(strnumb[1]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + if(ncol <= 0) + { + len = file.readLine(buf, sizeof(buf))-1; + ncol = extract_numb( buf, MAXCOL, strnumb); + } + flag = 0; + break; + } + } + file.close(); + + //load the position and displacement data of the first point + for(j=0; jm_SampleFileList.size(); j++) + { + VisAtomDataSheet*pData = new VisAtomDataSheet(ncol, nrow); + + file.setFileName(this->m_SampleFileList[j]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + int ii; + ii = 0; flag = 0; + while (!file.atEnd()) + { + int len,na; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + na = atoi(strnumb[1]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + for(i=0; iSetDataForRow(ii, strnumb); + ii++; + } + flag = 0; + break; + } + } + file.close(); + //add the data to the trajectory object + pData->SetPosxCol(this->m_colx); + pData->SetPosyCol(this->m_coly); + pData->SetPoszCol(this->m_colz); + pTrajectory->AddData(pData); + //The system down if we use GL here,why? + //this->m_pRender->updateGL(); + emit OnEndLoadFile(this->m_SampleFileList[j], j, this->m_SampleFileList.size()); + } + this->m_loaded = 1; + + //clear the temp data + for(i=0; im_SampleFileList.isEmpty()) return; + if(this->m_loaded) return; + + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->Clear(); + + + int nrow=0, ncol=0, i,j, flag, sline; + char buf[MAXCOL*MAXSTRL]; + char*strnumb[MAXCOL]; + for(i=0; im_SampleFileList[0], 0, this->m_SampleFileList.size()); + QFile file; + //open the first file to determine the number of cols and rows + file.setFileName(this->m_SampleFileList[0]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + flag = 0; + while (!file.atEnd()) + { + int len; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + nrow = nrow+atoi(strnumb[0]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + if(ncol <= 0) + { + len = file.readLine(buf, sizeof(buf))-1; + ncol = extract_numb( buf, MAXCOL, strnumb); + } + flag = 0; + break; + } + } + file.close(); + + //load the position and displacement data of the first point + for(j=0; jm_SampleFileList.size(); j++) + { + VisAtomDataSheet*pData = new VisAtomDataSheet(ncol, nrow); + + file.setFileName(this->m_SampleFileList[j]); + file.open(QIODevice::ReadOnly|QIODevice::Text); + + int ii; + ii = 0; flag = 0; + while (!file.atEnd()) + { + int len,na; + len = file.readLine(buf, sizeof(buf))-1; + if(flag==0 && buf[0] == '&' && buf[1] == 'N' && buf[2] == 'A' && buf[3] == 'T'&& buf[4] == 'O'&& buf[5] == 'M') + { + extract_numb( buf, MAXCOL, strnumb); + na = atoi(strnumb[0]); + flag = 1; + } + if(buf[0] == '&' && buf[1] == 'T' && buf[2] == 'Y' && buf[3] == 'P'&& buf[4] == 'E') + { + for(i=0; iSetDataForRow(ii, strnumb); + ii++; + } + flag = 0; + break; + } + } + file.close(); + //add the data to the trajectory object + pData->SetPosxCol(this->m_colx); + pData->SetPosyCol(this->m_coly); + pData->SetPoszCol(this->m_colz); + pTrajectory->AddData(pData); + //The system down if we use GL here,why? + //this->m_pRender->updateGL(); + emit OnEndLoadFile(this->m_SampleFileList[j], j, this->m_SampleFileList.size()); + } + this->m_loaded = 1; + + //clear the temp data + for(i=0; im_loaded) + { + VisAtomTrajectory*pTrajectory = this->m_pRender->GetTrajectory(); + pTrajectory->SetDataCol(this->m_colx, this->m_coly, this->m_colz); + } + return; + } + + + + +void VisAtom_LoadTrajecoryThread::run() +{ +} + diff --git a/VisAtom2017/visatom_loadtrajecoryThread.h b/VisAtom2017/visatom_loadtrajecoryThread.h new file mode 100644 index 0000000..1c6fdbf --- /dev/null +++ b/VisAtom2017/visatom_loadtrajecoryThread.h @@ -0,0 +1,43 @@ + +#ifndef VISATOMWLOADDATATHREAD_H +#define VISATOMWLOADDATATHREAD_H + +#include +#include + +class VisAtomWidget; +class VisAtom_LoadTrajecoryThread : public QThread +{ + Q_OBJECT + +public: + VisAtom_LoadTrajecoryThread(QObject * parent = 0); + ~VisAtom_LoadTrajecoryThread(); + void SetFileSerial(QString fname, int from, int to, int step, int vx, int vy, int vz); + void SetDataCol(int vx, int vy, int vz); + void AttachRender(VisAtomWidget*pRenader); + + QString GetFilename(int i); + QString FirstFilename(); + QString LasttFilename(); + void Clear(); + void StartLoadData(); + void LoadFrom_FMTUNKNOWN(); + void LoadFrom_BOXCFG14(); + void LoadFrom_BOXCFG16(); + + int IsDataLoaded(){return m_loaded;} +public slots: + + +signals: + void OnStartLoadFile(QString& filename, int index, int total); + void OnEndLoadFile(QString& filename, int index, int total); +protected: + VisAtomWidget*m_pRender; + QList m_SampleFileList; + int m_loaded, m_colx, m_coly, m_colz; + void run(); +}; + +#endif diff --git a/VisAtom2017/visatom_newcolorpolicyDlg.ui b/VisAtom2017/visatom_newcolorpolicyDlg.ui new file mode 100644 index 0000000..efe5100 --- /dev/null +++ b/VisAtom2017/visatom_newcolorpolicyDlg.ui @@ -0,0 +1,520 @@ + + + visatom_newcolorpolicyForm + + + + 0 + 0 + 630 + 405 + + + + Dialog + + + true + + + true + + + + + + QLayout::SetFixedSize + + + 8 + + + + + + + + + + + + + 0 + 0 + + + + + 160 + 16777215 + + + + true + + + + 1 + + + + + + + + QLayout::SetFixedSize + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + true + + + 2 + + + + + + + true + + + 2 + + + 100.000000000000000 + + + 100.000000000000000 + + + + + + + Value range: + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + window (%): + + + + + + + + + + + + + + + Data sheet preview: + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Rows + + + + + + + false + + + + 0 + 0 + + + + false + + + QAbstractSpinBox::NoButtons + + + 9999999 + + + + + + + + 0 + 0 + + + + Min: + + + + + + + true + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + 0 + 0 + + + + Max: + + + + + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + + true + + + + 0 + 260 + + + + true + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectColumns + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + Qt::DotLine + + + 0 + + + 4 + + + true + + + false + + + false + + + true + + + false + + + false + + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + + + okButton + clicked() + visatom_newcolorpolicyForm + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + visatom_newcolorpolicyForm + reject() + + + 369 + 253 + + + 179 + 282 + + + + + datasheetTableWidget + itemSelectionChanged() + visatom_newcolorpolicyForm + OnTableSelected() + + + 406 + 194 + + + 329 + 199 + + + + + scalarwindowMinSpinBox + valueChanged(double) + visatom_newcolorpolicyForm + OnTableSelected() + + + 55 + 199 + + + 300 + 173 + + + + + scalarwindowMaxSpinBox + valueChanged(double) + visatom_newcolorpolicyForm + OnTableSelected() + + + 127 + 199 + + + 300 + 173 + + + + + subsampleListTreeWidget + itemChanged(QTreeWidgetItem*,int) + visatom_newcolorpolicyForm + OnSubsampleListItemChanged(QTreeWidgetItem*) + + + 89 + 123 + + + 314 + 202 + + + + + datasheetTableWidget + itemClicked(QTableWidgetItem*) + visatom_newcolorpolicyForm + OnTableSelected() + + + 398 + 196 + + + 314 + 202 + + + + + + OnTableSelected() + OnSubsampleListItemChanged(QTreeWidgetItem*) + + diff --git a/VisAtom2017/visatom_newcolorpolicydlg.cpp b/VisAtom2017/visatom_newcolorpolicydlg.cpp new file mode 100644 index 0000000..94f0542 --- /dev/null +++ b/VisAtom2017/visatom_newcolorpolicydlg.cpp @@ -0,0 +1,271 @@ +#include "visatom_newcolorpolicydlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomSubsample.h" +#include + + +double VisAtom_NewColorPolicyDlg::m_winmin = 0; +double VisAtom_NewColorPolicyDlg::m_winmax = 100; +double VisAtom_NewColorPolicyDlg::m_datamin = 1e8; +double VisAtom_NewColorPolicyDlg::m_datamax =-1.e8; +int VisAtom_NewColorPolicyDlg::m_datacol = -1; + +VisAtom_NewColorPolicyDlg::VisAtom_NewColorPolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + + this->m_Sample = NULL; + this->m_atype = NULL; + this->m_px = NULL; + this->m_py = NULL; + this->m_pz = NULL; + + ui.scalarwindowMinSpinBox->setValue(VisAtom_NewColorPolicyDlg::m_winmin); + ui.scalarwindowMaxSpinBox->setValue(VisAtom_NewColorPolicyDlg::m_winmax); + if(VisAtom_NewColorPolicyDlg::m_datamax > VisAtom_NewColorPolicyDlg::m_datamin) + { + QString snum; + snum.setNum(VisAtom_NewColorPolicyDlg::m_datamin, 'e', 4); + ui.rangeminLable->setText(snum); + snum.setNum(VisAtom_NewColorPolicyDlg::m_datamax, 'e', 4); + ui.rangemaxLable->setText(snum); + } + QString title(tr("Edit scalar range for colormapping")); + this->setWindowTitle(title); + this->ui.subsampleListTreeWidget->setHeaderLabel("Scalar filter"); + + return; +} + +VisAtom_NewColorPolicyDlg::~VisAtom_NewColorPolicyDlg() +{ + +} + +void VisAtom_NewColorPolicyDlg::SetSample(VisAtomSample*sample) +{ + this->m_Sample = sample; + + QString sname; + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0,tr("ALL subsamples")); + item->setCheckState(0,Qt::Checked); + this->ui.subsampleListTreeWidget->addTopLevelItem(item); + + int i; + for(i=0; im_Sample->NumberofSubsample(); i++) + { + VisAtomSubSample*subp = this->m_Sample->GetSubsample(i); + sname = subp->GetName(); + QTreeWidgetItem*item = new QTreeWidgetItem(); + item->setText(0, sname); + item->setCheckState(0,Qt::Checked); + this->ui.subsampleListTreeWidget->addTopLevelItem(item); + } + return; +} + +void VisAtom_NewColorPolicyDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + #define MAXROW 100 + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + int*colprop = this->m_SampleDataSheet->GetColProp(); + + int i, j; + QString title, snum; + + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row)); + for(i=0; im_atype = this->m_SampleDataSheet->GetData(i); + break; + case VisAtomDataSheet::COLPROP_POSX: + title.append(tr(" (x)")); + this->m_px = this->m_SampleDataSheet->GetData(i); + break; + case VisAtomDataSheet::COLPROP_POSY: + title.append(tr(" (y)")); + this->m_py = this->m_SampleDataSheet->GetData(i); + break; + case VisAtomDataSheet::COLPROP_POSZ: + title.append(tr(" (z)")); + this->m_pz = this->m_SampleDataSheet->GetData(i); + break; + } + + QTableWidgetItem*hitem = new QTableWidgetItem(title); + ui.datasheetTableWidget->setHorizontalHeaderItem(i, hitem); + } + + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[j]+0.000001)); + else + snum.setNum(cdata[j], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[row-1]+0.000001)); + else + snum.setNum(cdata[row-1], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + + } + ui.datasheetTableWidget->selectColumn(this->m_datacol); + ui.numrowSpinBox->setValue(row); + return; +} + +void VisAtom_NewColorPolicyDlg::OnTableSelected() +{ + int col = ui.datasheetTableWidget->currentColumn(); + if(col < 0) return; + if(!this->m_Sample) return; + int i; + double fmin, fmax; + + this->m_datacol = col; + this->GetFilteredScalarRange(col, fmin, fmax); + + QString snum; + snum.setNum(fmin, 'e', 4); + ui.dataminLabel->setText(snum); + snum.setNum(fmax, 'e', 4); + ui.datamaxLabel->setText(snum); + + double range = ui.scalarwindowMinSpinBox->maximum() - ui.scalarwindowMinSpinBox->minimum(); + this->m_datamin = ui.scalarwindowMinSpinBox->value()*(fmax-fmin)/range + fmin; + this->m_datamax = ui.scalarwindowMaxSpinBox->value()*(fmax-fmin)/range + fmin; + + //to make data in 10 based data + fmin = this->m_datamin; + fmax = this->m_datamax; + int scal, num; + scal = log10(abs(fmin)); + num = floor(fmin*pow(10.f, -scal)); + this->m_datamin = (float)num*pow(10.f,scal); + + scal = log10(abs(fmax)); + num = ceil(fmax*pow(10.f, -scal)); + this->m_datamax = (float)num*pow(10.f,scal); + + snum.setNum(this->m_datamin, 'e', 4); + ui.rangeminLable->setText(snum); + snum.setNum(this->m_datamax, 'e', 4); + ui.rangemaxLable->setText(snum); + return; +} + +void VisAtom_NewColorPolicyDlg::OnSubsampleListItemChanged(QTreeWidgetItem*item) +{ + if(item->text(0) == tr("ALL subsamples") && item->checkState(0) == Qt::Checked ) + { + int i; + for(i=0; im_Sample->NumberofSubsample(); i++) + { + QTreeWidgetItem*p = this->ui.subsampleListTreeWidget->topLevelItem(i+1); + p->setCheckState(0,Qt::Checked); + } + } + else if(item->checkState(0) == Qt::Unchecked) + { + this->ui.subsampleListTreeWidget->topLevelItem(0)->setCheckState(0,Qt::Unchecked); + } + this->OnTableSelected(); +} + +void VisAtom_NewColorPolicyDlg::GetFilteredScalarRange(int col, double&fmin, double&fmax) +{ + float*pdat = this->m_SampleDataSheet->GetData(col); + + fmin = 1.e10; + fmax =-1.e10; + int i,j, nsub, ingroup; + + QTreeWidgetItem*item; + QList subp; + for(i=0; im_Sample->NumberofSubsample(); i++) + { + item = this->ui.subsampleListTreeWidget->topLevelItem(i+1); + if(item->checkState(0) == Qt::Checked) + { + subp.append(this->m_Sample->GetSubsample(i)); + } + } + + nsub = subp.count(); + for(i=0; im_SampleDataSheet->GetNumRow(); i++) + { + ingroup = false; + for(j=0; jCheckMembership((int)(m_atype[i]+0.00001), m_px[i], m_py[i], m_pz[i])) + { + ingroup = true; break; + } + } + else + { + if(subp[j]->CheckMembership(1,m_px[i], m_py[i], m_pz[i])) + { + ingroup = true; break; + } + } + } + + if(ingroup) + { + if(pdat[i] > fmax) fmax = pdat[i]; + if(pdat[i] < fmin) fmin = pdat[i]; + } + } +} + + diff --git a/VisAtom2017/visatom_newcolorpolicydlg.h b/VisAtom2017/visatom_newcolorpolicydlg.h new file mode 100644 index 0000000..b1b1032 --- /dev/null +++ b/VisAtom2017/visatom_newcolorpolicydlg.h @@ -0,0 +1,52 @@ +#ifndef VISATOMNEWCOLORPOLICY_H +#define VISATOMNEWCOLORPOLICY_H + +#include +#include "ui_visatom_newcolorpolicyDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewColorPolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + VisAtomSample*m_Sample; + + static double m_winmin, m_winmax; + static double m_datamin, m_datamax; + static int m_datacol; + +public: + VisAtom_NewColorPolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewColorPolicyDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + void SetSample(VisAtomSample*sample); + + void GetData(int&col, float&min, float&max) + { + col = m_datacol; min = m_datamin; max = m_datamax; + } + +private slots: + + void OnTableSelected(); + void OnSubsampleListItemChanged(QTreeWidgetItem*item); + +private: + Ui::visatom_newcolorpolicyForm ui; + void GetFilteredScalarRange(int col, double&fmin, double&fmax); + float*m_atype; + float*m_px; + float*m_py; + float*m_pz; + + + // + +}; + +#endif // VISATOMNEWCOLORPOLICY_H diff --git a/VisAtom2017/visatom_newdisplacementDlg.ui b/VisAtom2017/visatom_newdisplacementDlg.ui new file mode 100644 index 0000000..f8e763e --- /dev/null +++ b/VisAtom2017/visatom_newdisplacementDlg.ui @@ -0,0 +1,481 @@ + + + visatom_newdisplacementpolicyForm + + + + 0 + 0 + 676 + 299 + + + + Dialog + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + + + + + + Filename: + + + + + + + true + + + true + + + + + + + index from: + + + + + + + true + + + + 0 + 0 + + + + + 64 + 0 + + + + -1 + + + 9999 + + + -1 + + + + + + + true + + + not exist + + + true + + + + + + + to: + + + + + + + true + + + + 0 + 0 + + + + + 64 + 0 + + + + -1 + + + 9999 + + + -1 + + + + + + + true + + + not exist + + + true + + + + + + + by step: + + + + + + + + 0 + 0 + + + + + 48 + 0 + + + + 1 + + + 100 + + + 1 + + + + + + + + + + + + + Displacemane along: x + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + y: + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + z: + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::NoFocus + + + Qt::NoContextMenu + + + true + + + true + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + false + + + false + + + QAbstractItemView::NoSelection + + + true + + + Qt::DashDotLine + + + true + + + false + + + 4 + + + 4 + + + true + + + 130 + + + false + + + false + + + + + + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + false + + + OK + + + + + + + Cancel + + + + + + + + + + + + + okButton + clicked() + visatom_newdisplacementpolicyForm + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + visatom_newdisplacementpolicyForm + reject() + + + 369 + 253 + + + 179 + 282 + + + + + datasheetTableWidget + itemChanged(QTableWidgetItem*) + visatom_newdisplacementpolicyForm + OnDatasheetChanged(QTableWidgetItem*) + + + 287 + 190 + + + 287 + 195 + + + + + trajectfromSpinBox + valueChanged(int) + visatom_newdisplacementpolicyForm + OnFromChanged(int) + + + 261 + 19 + + + 337 + 149 + + + + + trajecttoSpinBox + valueChanged(int) + visatom_newdisplacementpolicyForm + OnToChanged(int) + + + 511 + 19 + + + 337 + 149 + + + + + trajectstepSpinBox + valueChanged(int) + visatom_newdisplacementpolicyForm + OnStepChanged(int) + + + 641 + 19 + + + 337 + 149 + + + + + + OnDatasheetChanged(QTableWidgetItem*) + OnFromChanged(int) + OnToChanged(int) + OnStepChanged(int) + + diff --git a/VisAtom2017/visatom_newdisplacementdlg.cpp b/VisAtom2017/visatom_newdisplacementdlg.cpp new file mode 100644 index 0000000..35864f9 --- /dev/null +++ b/VisAtom2017/visatom_newdisplacementdlg.cpp @@ -0,0 +1,524 @@ +#include "visatom_newdisplacementdlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomSubsample.h" +#include + +int VisAtom_NewDisplacementPolicyDlg::m_discol[3]={-1,-1,-1}; +int VisAtom_NewDisplacementPolicyDlg::m_startInd=-1; +int VisAtom_NewDisplacementPolicyDlg::m_endInd=-1; +int VisAtom_NewDisplacementPolicyDlg::m_indStep=1; +int VisAtom_NewDisplacementPolicyDlg::m_IndRng[3]={-1, -1, 1}; +QString VisAtom_NewDisplacementPolicyDlg::m_filename = ""; // tr(""); +#define MAXROW 53 +#define HEADROWS 3 +#define BKR 220 +#define BKG 220 +#define BKB 220 + +#define MAXCOL 64 +#define MAXSTRL 32 + +//**************************************************************************** +int static extract_numb( char*str, int mxCount, char**strnumb) +{ +/* +! Purpose: to extract number from a string +! Input: STRING a string +! Ouput: COUNT the number of numbers found in the string +! REAL_NUMB the number text founded +! Note: the REAL_NUMBi are character varible. These character number +! could be transformed to real number by DRSTR or RSTRi +! Auther: Hou Qing, Inst. of Nucl. Sci.and Tech., Sichuan Union University +! +! +*/ + int i, flag, index1, count; + + count=0; + index1=0; + i = 0; + flag = 0; + do + { + if(str[i] == ' ' || str[i] == ',') + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + index1 = 0; + } + flag = 0; + } + else + { + if((str[i] >= '0' && str[i] <= '9') || str[i] == '-' || str[i] == '+' || str[i] == '.' ) + { + if(flag == 0 ) + { + flag = 1; + count ++; + if(count > mxCount) break; + } + } + else + { + if(flag != 1) flag = 2; + } + } + + if(flag == 1) index1 ++; + + i++; + if(i >= strlen(str) ) + { + if(index1 > 0) + { + strncpy(strnumb[count-1], &str[i-index1], index1); + strnumb[count-1][index1] = NULL; + } + break; + } + } while(1); + return count; +} +//**************************************************************************** + +VisAtom_NewDisplacementPolicyDlg::VisAtom_NewDisplacementPolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + + QString title(tr("Choose the data for displacement of atoms")); + this->setWindowTitle(title); + + m_selcol[0] = m_selcol[1] = m_selcol[2] = -1; + m_fromF = m_toF = 0; + return; +} + +VisAtom_NewDisplacementPolicyDlg::~VisAtom_NewDisplacementPolicyDlg() +{ + +} + +int VisAtom_NewDisplacementPolicyDlg::SetFilename(QString fname,VisAtomDataSheet*pDataSheet) +{ + if(fname.isEmpty() || !pDataSheet) + { + VisAtom_NewDisplacementPolicyDlg::m_filename.clear(); + VisAtom_NewDisplacementPolicyDlg::m_startInd = -1; + VisAtom_NewDisplacementPolicyDlg::m_endInd = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[1] = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[2] = 1; + return ERR_NOTINDEXEDFILE; + } + + if(fname != this->ui.trajectfilenameEdit->text()) + { //file name has been changed + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = -1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[1] = -1; + this->ui.trajectfilenameEdit->setText(fname); + } + int from, to, step; + + if(VisAtom_NewDisplacementPolicyDlg::m_IndRng[0]<0) + { // no range have been extracted + from = 0; + to = 9999; + step = 1; + + //*** to find the start file + QString fileName, ext, snum; + int i; + for(i=from; i<=to; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = fname; + fileName.append(ext); + QFile file(fileName); + if (file.exists()) break; + } + + if(i>to) + { //no any file found + this->m_fromF = this->m_toF = 0; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = -1; + } + else + { + VisAtom_NewDisplacementPolicyDlg::m_IndRng[0] = i; + from = i; + //to find the end file + for(i=from+step; i<=to+step; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = fname; + fileName.append(ext); + QFile file(fileName); + if (!file.exists()) break; + } + to = i-step; + this->m_fromF = this->m_toF = 1; + VisAtom_NewDisplacementPolicyDlg::m_IndRng[1] = to; + } + } + int err = this->FillPrevewTable(pDataSheet); + + + if(VisAtom_NewDisplacementPolicyDlg::m_startInd<0) from = 0; + else from = VisAtom_NewDisplacementPolicyDlg::m_startInd; + + if(VisAtom_NewDisplacementPolicyDlg::m_endInd<0) to = 9999; + else to = VisAtom_NewDisplacementPolicyDlg::m_endInd; + + step = VisAtom_NewDisplacementPolicyDlg::m_indStep; + + this->ui.trajectfromSpinBox->setValue(from); + this->ui.trajecttoSpinBox->setMinimum(VisAtom_NewDisplacementPolicyDlg::m_IndRng[0]); + this->ui.trajecttoSpinBox->setMaximum(VisAtom_NewDisplacementPolicyDlg::m_IndRng[1]); + this->ui.trajecttoSpinBox->setSingleStep(step); + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajectstepSpinBox->setValue(step); + + this->m_selcol[0] = VisAtom_NewDisplacementPolicyDlg::m_discol[0]; + this->m_selcol[1] = VisAtom_NewDisplacementPolicyDlg::m_discol[1]; + this->m_selcol[2] = VisAtom_NewDisplacementPolicyDlg::m_discol[2]; + this->UpdateUI(); + if(err != ERR_NOERROR) return err; + return ERR_NOERROR; + +} + +//***************************************************************************** +void VisAtom_NewDisplacementPolicyDlg::UpdateUI() +{ + int from = this->ui.trajectfromSpinBox->value(); + int to = this->ui.trajecttoSpinBox->value(); + QString fileName, snum, ext; + + if(!this->m_fromF) + { + this->ui.trajectfilefromLineEdit->setText(tr("not exist")); + + } + else + { + fileName = this->ui.trajectfilenameEdit->text(); + if(from<10) ext = ".000"; + else if(from<100) ext = ".00"; + else if(from<1000) ext = ".0"; + snum.setNum(from); + ext.append(snum); + fileName.append(ext); + this->ui.trajectfromSpinBox->setValue(from); + this->ui.trajectfilefromLineEdit->setText(fileName); + + } + + if(!this->m_toF) + { + this->ui.trajectfiletoLineEdit->setText(tr("not exist")); + } + else + { + fileName = this->ui.trajectfilenameEdit->text(); + if(to<10) ext = ".000"; + else if(to<100) ext = ".00"; + else if(to<1000) ext = ".0"; + snum.setNum(to); + ext.append(snum); + fileName.append(ext); + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajectfiletoLineEdit->setText(fileName); + } + //write the stat of the table + for(int i=0; im_selcol[i] >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(i, this->m_selcol[i]); + item->setCheckState(Qt::Checked); + } + //WriteColLabels + QString title; + if(this->m_selcol[0] >= 0) {title = tr("Col.#"); snum.setNum(this->m_selcol[0]+1); title.append(snum);} + else title = tr("N/A"); + ui.vxcolLabel->setText(title); + + if(this->m_selcol[1] >= 0) {title = tr("Col.#"); snum.setNum(this->m_selcol[1]+1); title.append(snum);} + else title = tr("N/A"); + ui.vycolLabel->setText(title); + + if(this->m_selcol[2] >= 0) {title = tr("Col.#"); snum.setNum(this->m_selcol[2]+1); title.append(snum);} + else title = tr("N/A"); + ui.vzcolLabel->setText(title); + + //enable or disable the okButton + if(this->m_fromF && this->m_toF && this->m_selcol[0] >=0 && this->m_selcol[1] >= 0 &&this->m_selcol[2]>= 0) + this->ui.okButton->setEnabled(true); + else + this->ui.okButton->setEnabled(false); + + +} +//******************************************************************************* +int VisAtom_NewDisplacementPolicyDlg::FillPrevewTable(VisAtomDataSheet*pDataSheet) +{ + + //to determine how many col for each line + int ncol=0, i,j; + + ncol = pDataSheet->GetNumCol(); + this->ui.datasheetTableWidget->clear(); + //set the header + QString title, snum; + QTableWidgetItem*hitem, *item; + this->ui.datasheetTableWidget->setColumnCount(ncol); + this->ui.datasheetTableWidget->setRowCount(MAXROW); + + for(i=0; iGetTypeCol()) + title.append(tr("(atom type)")); + else if(i == pDataSheet->GetPosXCol()) + title.append(tr("(pos x)")); + else if(i == pDataSheet->GetPosYCol()) + title.append(tr("(pos y)")); + else if(i == pDataSheet->GetPosZCol()) + title.append(tr("(pos z)")); + + hitem = new QTableWidgetItem(title); + ui.datasheetTableWidget->setHorizontalHeaderItem(i, hitem); + } + + + title.clear(); + item = new QTableWidgetItem(title); + this->ui.datasheetTableWidget->setVerticalHeaderItem(0, item); + title.append(tr("Dx")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + this->ui.datasheetTableWidget->setItem(0, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(1, item); + title.append(tr("Dy")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + this->ui.datasheetTableWidget->setItem(1, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(2, item); + title.append(tr("Dz")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + this->ui.datasheetTableWidget->setItem(2, i, item); + } + + + for(j=HEADROWS; jGetNumRow())-2; j++) + { + snum.setNum(j-HEADROWS+1); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(j, item); + + for(i=0; iGetData(i)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item = new QTableWidgetItem(snum); + this->ui.datasheetTableWidget->setItem(j, i, item); + } + } + + if(pDataSheet->GetNumRow() >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(pDataSheet->GetNumRow()); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; iGetData(i); + snum.setNum(cdata[pDataSheet->GetNumRow()-1], 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + } + return 0; +} + + +void VisAtom_NewDisplacementPolicyDlg::OnDatasheetChanged(QTableWidgetItem*item) +{ + int col = item->column(); + int row = item->row(); + int checked = item->checkState(); + if(row >= HEADROWS) return; + + if(checked) + { + int i; + for(i=0; icolumnCount(); i++) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(row, i); + if(i != col) item->setCheckState(Qt::Unchecked); + } + //in this case, we permit the same colume for are chosen + /*for(i=0; iitem(i, col); + if(i != row) item->setCheckState(Qt::Unchecked); + }*/ + + ////////////////////////////////////// + m_selcol[row] = col; + } + else //unchecked + { + m_selcol[row] = -1; + } + this->UpdateUI(); + + return; +} + +bool VisAtom_NewDisplacementPolicyDlg::HasTrajectData() +{ + if(VisAtom_NewDisplacementPolicyDlg::m_filename.isEmpty() || + VisAtom_NewDisplacementPolicyDlg::m_startInd < 0 || + VisAtom_NewDisplacementPolicyDlg::m_endInd < 0 ) + return false; + else return true; +} + +void VisAtom_NewDisplacementPolicyDlg::OnFromChanged(int from) +{ + + QString snum, ext, fileName; + int i, to, step; + if(from<10) ext = ".000"; + else if(from<100) ext = ".00"; + else if(from<1000) ext = ".0"; + + snum.setNum(from); + ext.append(snum); + fileName = this->ui.trajectfilenameEdit->text(); + fileName.append(ext); + QFile file(fileName); + if(!file.exists()) + { + this->m_fromF = 0; + } + else + { + this->ui.trajectfilefromLineEdit->setText(fileName); + step = this->ui.trajectstepSpinBox->value(); + //to find the end file + to = 9999; + for(i=from+step; i<=to+step; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = this->ui.trajectfilenameEdit->text(); + fileName.append(ext); + file.setFileName(fileName); + if (!file.exists()) break; + } + to = i-step; + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajecttoSpinBox->setMinimum(from); + this->ui.trajecttoSpinBox->setMaximum(to); + + this->m_fromF = this->m_toF = 1; + } + this->UpdateUI(); + return; +} + +void VisAtom_NewDisplacementPolicyDlg::OnStepChanged(int step) +{ + QString fileName, ext, snum; + QFile file; + //to find the end file + int i, from, to = 9999; + from = this->ui.trajectfromSpinBox->value(); + for(i=from+step; i<=to+step; i=i+step) + { + if(i<10) ext = ".000"; + else if(i<100) ext = ".00"; + else if(i<1000) ext = ".0"; + + snum.setNum(i); + ext.append(snum); + fileName = this->ui.trajectfilenameEdit->text(); + fileName.append(ext); + file.setFileName(fileName); + if (!file.exists()) break; + } + to = i-step; + this->ui.trajecttoSpinBox->setMaximum(to); + this->ui.trajecttoSpinBox->setValue(to); + this->ui.trajecttoSpinBox->setSingleStep(step); + this->UpdateUI(); + return; +} + + +void VisAtom_NewDisplacementPolicyDlg::accept() +{ + VisAtom_NewDisplacementPolicyDlg::m_filename = this->ui.trajectfilenameEdit->text(); + VisAtom_NewDisplacementPolicyDlg::m_startInd = this->ui.trajectfromSpinBox->value(); + VisAtom_NewDisplacementPolicyDlg::m_endInd = this->ui.trajecttoSpinBox->value(); + VisAtom_NewDisplacementPolicyDlg::m_discol[0] = this->m_selcol[0]; + VisAtom_NewDisplacementPolicyDlg::m_discol[1] = this->m_selcol[1]; + VisAtom_NewDisplacementPolicyDlg::m_discol[2] = this->m_selcol[2]; + VisAtom_NewDisplacementPolicyDlg::m_indStep = this->ui.trajectstepSpinBox->value(); + QDialog::accept(); +} + + diff --git a/VisAtom2017/visatom_newdisplacementdlg.h b/VisAtom2017/visatom_newdisplacementdlg.h new file mode 100644 index 0000000..b24871a --- /dev/null +++ b/VisAtom2017/visatom_newdisplacementdlg.h @@ -0,0 +1,73 @@ +#ifndef VISATOMNEWDISPLACEMENTPOLICY_H +#define VISATOMNEWDISPLACEMENTPOLICY_H + +#include +#include + +#include "Ui_visatom_newdisplacementDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewDisplacementPolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + + static int m_discol[3]; + static QString m_filename; + static int m_startInd; + static int m_endInd; + static int m_indStep; + static int m_IndRng[3]; //available file index + +public: + VisAtom_NewDisplacementPolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewDisplacementPolicyDlg(); + + static void GetDisplacementColume(int dcol[3]) + { + dcol[0] = m_discol[0]; + dcol[1] = m_discol[1]; + dcol[2] = m_discol[2]; + } + static void GetDisplacementColume(int& dx, int& dy, int& dz) + { + dx = m_discol[0]; + dy = m_discol[1]; + dz = m_discol[2]; + } + + static int GetStartInd() {return m_startInd;}; + static int GetEndInd() {return m_endInd;}; + static int GetIndexStep() {return m_indStep;}; + static QString GetFname() {return m_filename;}; + + enum ERRORCODE + { + ERR_NOERROR = 0, + ERR_NOTINDEXEDFILE = 1, + ERR_INCONSISTENTFOMAT = 2, + }; + + + int SetFilename(QString fname,VisAtomDataSheet*pDataSheet); + static bool HasTrajectData(); + +private slots: + void UpdateUI(); + int FillPrevewTable(VisAtomDataSheet*pDataSheet); + void OnDatasheetChanged(QTableWidgetItem*); + void OnFromChanged(int from); + void OnStepChanged(int step); + void accept(); + +private: + Ui::visatom_newdisplacementpolicyForm ui; + int m_selcol[3]; + int m_fromF, m_toF; + +}; + +#endif // VISATOMNEWVECTORPOLICY_H diff --git a/VisAtom2017/visatom_newsizepolicyDlg.ui b/VisAtom2017/visatom_newsizepolicyDlg.ui new file mode 100644 index 0000000..5e48022 --- /dev/null +++ b/VisAtom2017/visatom_newsizepolicyDlg.ui @@ -0,0 +1,326 @@ + + + visatom_newsizepolicyForm + + + + 0 + 0 + 519 + 353 + + + + Dialog + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + + + + + + + + Data sheet preview: + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Rows + + + + + + + false + + + + 0 + 0 + + + + false + + + QAbstractSpinBox::NoButtons + + + 9999999 + + + + + + + + 0 + 0 + + + + Min: + + + + + + + true + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + 0 + 0 + + + + Max: + + + + + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + + + true + + + + 0 + 260 + + + + true + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectColumns + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + Qt::DotLine + + + 0 + + + 4 + + + true + + + false + + + false + + + true + + + false + + + false + + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + + + okButton + clicked() + visatom_newsizepolicyForm + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + visatom_newsizepolicyForm + reject() + + + 369 + 253 + + + 179 + 282 + + + + + datasheetTableWidget + itemSelectionChanged() + visatom_newsizepolicyForm + OnTableSelected() + + + 259 + 170 + + + 259 + 176 + + + + + + OnTableSelected() + + diff --git a/VisAtom2017/visatom_newsizepolicydlg.cpp b/VisAtom2017/visatom_newsizepolicydlg.cpp new file mode 100644 index 0000000..5590308 --- /dev/null +++ b/VisAtom2017/visatom_newsizepolicydlg.cpp @@ -0,0 +1,176 @@ +#include "VisAtom_NewSizePolicyDlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSample.h" +#include "VisAtomSubsample.h" +#include "math.h" + + +double VisAtom_NewSizePolicyDlg::m_datamin = 1e8; +double VisAtom_NewSizePolicyDlg::m_datamax = 0; +int VisAtom_NewSizePolicyDlg::m_datacol = -1; + +VisAtom_NewSizePolicyDlg::VisAtom_NewSizePolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + if(VisAtom_NewSizePolicyDlg::m_datamax > VisAtom_NewSizePolicyDlg::m_datamin) + { + QString snum; + snum.setNum(VisAtom_NewSizePolicyDlg::m_datamin, 'e', 4); + ui.dataminLabel->setText(snum); + snum.setNum(VisAtom_NewSizePolicyDlg::m_datamax, 'e', 4); + ui.datamaxLabel->setText(snum); + } + QString title(tr("Edit scalar range for atom radia")); + this->setWindowTitle(title); + + return; +} + +VisAtom_NewSizePolicyDlg::~VisAtom_NewSizePolicyDlg() +{ + +} + + +void VisAtom_NewSizePolicyDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + #define MAXROW 100 + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + int*colprop = this->m_SampleDataSheet->GetColProp(); + + int i, j; + QString title, snum; + + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row)); + for(i=0; isetHorizontalHeaderItem(i, hitem); + } + + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[j]+0.000001)); + else + snum.setNum(cdata[j], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + if(colprop[i] == VisAtomDataSheet::COLPROP_TYPE) + snum.setNum((int)(cdata[row-1]+0.000001)); + else + snum.setNum(cdata[row-1], 'e', 5); + + QTableWidgetItem*item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + + } + ui.datasheetTableWidget->selectColumn(this->m_datacol); + + ui.numrowSpinBox->setValue(row); + + if(this->m_datacol<0 ||this->m_datamin <0) ui.okButton->setEnabled(false); + + return; +} + +void VisAtom_NewSizePolicyDlg::OnTableSelected() +{ + int col = ui.datasheetTableWidget->currentColumn(); + if(col < 0) return; + + int i,j; + double fmin, fmax; + float*pdat = this->m_SampleDataSheet->GetData(col); + + fmin = 1.e10; + fmax =-1.e10; + + for(i=0; im_SampleDataSheet->GetNumRow(); i++) + { + if(pdat[i] > fmax) fmax = pdat[i]; + if(pdat[i] < fmin) fmin = pdat[i]; + } + + QString snum; + snum.setNum(fmin, 'e', 4); + ui.dataminLabel->setText(snum); + snum.setNum(fmax, 'e', 4); + ui.datamaxLabel->setText(snum); + + this->m_datacol = col; + this->m_datamin = fmin; + this->m_datamax = fmin; + if(fmin < 0) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Warning); + + QString msg("Warnning"); + msgBox.setText("Radius cannot be negative"); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + ui.okButton->setEnabled(false); + } + else + { + ui.okButton->setEnabled(true); + } + + return; +} + + diff --git a/VisAtom2017/visatom_newsizepolicydlg.h b/VisAtom2017/visatom_newsizepolicydlg.h new file mode 100644 index 0000000..b20beef --- /dev/null +++ b/VisAtom2017/visatom_newsizepolicydlg.h @@ -0,0 +1,39 @@ +#ifndef VISATOMNEWSIZEPOLICY_H +#define VISATOMNEWSIZEPOLICY_H + +#include +#include "ui_visatom_newsizepolicyDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewSizePolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + static double m_datamin, m_datamax; + static int m_datacol; + +public: + VisAtom_NewSizePolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewSizePolicyDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + + void GetData(int&col, float&min, float&max) + { + col = m_datacol; min = m_datamin; max = m_datamax; + } + +private slots: + + void OnTableSelected(); + +private: + Ui::visatom_newsizepolicyForm ui; + +}; + +#endif // VISATOMNEWSIZEPOLICY_H diff --git a/VisAtom2017/visatom_newvectorpolicyDlg.ui b/VisAtom2017/visatom_newvectorpolicyDlg.ui new file mode 100644 index 0000000..a08edb2 --- /dev/null +++ b/VisAtom2017/visatom_newvectorpolicyDlg.ui @@ -0,0 +1,277 @@ + + + visatom_newvectorpolicyForm + + + + 0 + 0 + 568 + 397 + + + + Dialog + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + + + + + + Vector x: + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + Vector y: + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + Vector z: + + + + + + + QFrame::Box + + + QFrame::Sunken + + + N/A + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::NoFocus + + + Qt::NoContextMenu + + + true + + + true + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + false + + + false + + + QAbstractItemView::NoSelection + + + true + + + Qt::DashDotLine + + + true + + + false + + + 4 + + + 4 + + + true + + + 130 + + + false + + + false + + + + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + false + + + OK + + + + + + + Cancel + + + + + + + + + + + + + okButton + clicked() + visatom_newvectorpolicyForm + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + visatom_newvectorpolicyForm + reject() + + + 369 + 253 + + + 179 + 282 + + + + + datasheetTableWidget + itemChanged(QTableWidgetItem*) + visatom_newvectorpolicyForm + OnDatasheetChanged(QTableWidgetItem*) + + + 287 + 190 + + + 287 + 195 + + + + + + OnDatasheetChanged(QTableWidgetItem*) + + diff --git a/VisAtom2017/visatom_newvectorpolicydlg.cpp b/VisAtom2017/visatom_newvectorpolicydlg.cpp new file mode 100644 index 0000000..6b3b918 --- /dev/null +++ b/VisAtom2017/visatom_newvectorpolicydlg.cpp @@ -0,0 +1,217 @@ +#include "visatom_newvectorpolicydlg.h" +#include "VisAtomVisualizingPolicy.h" +#include "VisAtomDataSheet.h" +#include "VisAtomSubsample.h" +#include + +int VisAtom_NewVectorPolicyDlg::m_vcol[3]={-1,-1,-1}; +#define MAXROW 53 +#define HEADROWS 3 +#define BKR 220 +#define BKG 220 +#define BKB 220 + +VisAtom_NewVectorPolicyDlg::VisAtom_NewVectorPolicyDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + int i; + + QString title(tr("Choose the data for vector for visualizing")); + this->setWindowTitle(title); + + return; +} + +VisAtom_NewVectorPolicyDlg::~VisAtom_NewVectorPolicyDlg() +{ + +} + +void VisAtom_NewVectorPolicyDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + + int i, j; + QString title, snum; + QTableWidgetItem*hitem, *item; + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row)); + + //reserve the previous selection + int oldcol[HEADROWS]; + for(i=0; iGetTypeCol()) + title.append(tr("(atom type)")); + else if(i == pData->GetPosXCol()) + title.append(tr("(pos x)")); + else if(i == pData->GetPosYCol()) + title.append(tr("(pos y)")); + else if(i == pData->GetPosZCol()) + title.append(tr("(pos z)")); + + hitem = new QTableWidgetItem(title); + ui.datasheetTableWidget->setHorizontalHeaderItem(i, hitem); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(0, item); + title.append(tr("Vx")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(0, i, item); + } + + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(1, item); + title.append(tr("Vy")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(1, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(2, item); + title.append(tr("Vz")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(2, i, item); + } + + for(j=HEADROWS; jsetVerticalHeaderItem(j, item); + + for(i=0; im_SampleDataSheet->GetData(i)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + snum.setNum(cdata[row-1], 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + } + + for(i=0; im_vcol[i] = oldcol[i]; + if(this->m_vcol[i] >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(i, this->m_vcol[i]); + item->setCheckState(Qt::Checked); + } + } + return; +} + +void VisAtom_NewVectorPolicyDlg::OnDatasheetChanged(QTableWidgetItem*item) +{ + int col = item->column(); + int row = item->row(); + int checked = item->checkState(); + if(row >= HEADROWS) return; + + if(checked) + { + int i; + for(i=0; icolumnCount(); i++) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(row, i); + if(i != col) item->setCheckState(Qt::Unchecked); + } + //in this case, we permit the same colume for are chosen + /*for(i=0; iitem(i, col); + if(i != row) item->setCheckState(Qt::Unchecked); + }*/ + + ////////////////////////////////////// + m_vcol[row] = col; + } + else //unchecked + { + m_vcol[row] = -1; + } + //write the col labels + WriteColLabels(); + if( this->m_vcol[0]>=0 && this->m_vcol[1]>=0 && this->m_vcol[2]>= 0) + ui.okButton->setEnabled(true); + else + ui.okButton->setEnabled(false); + + return; +} + +void VisAtom_NewVectorPolicyDlg::WriteColLabels() +{ + //write the col labels + QString title, snum; + + if(this->m_vcol[0] >= 0) {title = tr("Col.#"); snum.setNum(this->m_vcol[0]+1); title.append(snum);} + else title = tr("N/A"); + ui.vxcolLabel->setText(title); + + if(this->m_vcol[1] >= 0) {title = tr("Col.#"); snum.setNum(this->m_vcol[1]+1); title.append(snum);} + else title = tr("N/A"); + ui.vycolLabel->setText(title); + + if(this->m_vcol[2] >= 0) {title = tr("Col.#"); snum.setNum(this->m_vcol[2]+1); title.append(snum);} + else title = tr("N/A"); + ui.vzcolLabel->setText(title); + + return; +} + + + + diff --git a/VisAtom2017/visatom_newvectorpolicydlg.h b/VisAtom2017/visatom_newvectorpolicydlg.h new file mode 100644 index 0000000..c084068 --- /dev/null +++ b/VisAtom2017/visatom_newvectorpolicydlg.h @@ -0,0 +1,45 @@ +#ifndef VISATOMNEWVECTORPOLICY_H +#define VISATOMNEWVECTORPOLICY_H + +#include +#include "Ui_visatom_newvectorpolicyDlg.h" + +class VisAtomDataSheet; +class VisAtomVisualizingPolicy; +class VisAtomSample; +class VisAtom_NewVectorPolicyDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + + static int m_vcol[3]; +public: + VisAtom_NewVectorPolicyDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_NewVectorPolicyDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + static void GetVectorColume(int vcol[3]) + { + vcol[0] = m_vcol[0]; + vcol[1] = m_vcol[1]; + vcol[2] = m_vcol[2]; + } + static void GetVectorColume(int& vx, int& vy, int& vz) + { + vx = m_vcol[0]; + vy = m_vcol[1]; + vz = m_vcol[2]; + } + +private slots: + void OnDatasheetChanged(QTableWidgetItem*); + void WriteColLabels(); + +private: + Ui::visatom_newvectorpolicyForm ui; + +}; + +#endif // VISATOMNEWVECTORPOLICY_H diff --git a/VisAtom2017/visatom_selectsampledataDlg.cpp b/VisAtom2017/visatom_selectsampledataDlg.cpp new file mode 100644 index 0000000..abaa457 --- /dev/null +++ b/VisAtom2017/visatom_selectsampledataDlg.cpp @@ -0,0 +1,326 @@ +#include +#include "VisAtom_SelectSampleDataDlg.h" +#include "VisAtomDataSheet.h" + +int VisAtom_SelectSampleDataDlg::m_showthisdlg = 1; +int VisAtom_SelectSampleDataDlg::m_coltype = -1; +int VisAtom_SelectSampleDataDlg::m_colx = -1; +int VisAtom_SelectSampleDataDlg::m_coly = -1; +int VisAtom_SelectSampleDataDlg::m_colz = -1; + +VisAtom_SelectSampleDataDlg::VisAtom_SelectSampleDataDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + QString title(tr("Choose data from datasheet for sample data")); + this->setWindowTitle(title); + + return; +} + +VisAtom_SelectSampleDataDlg::~VisAtom_SelectSampleDataDlg() +{ + +} + +#define MAXROW 54 +#define HEADROWS 4 +#define BKR 220 +#define BKG 220 +#define BKB 220 +void VisAtom_SelectSampleDataDlg::SetDataSheet(VisAtomDataSheet*pData) +{ + this->m_SampleDataSheet = pData; + int col = this->m_SampleDataSheet->GetNumCol(); + int row = this->m_SampleDataSheet->GetNumRow(); + + int i, j; + QString title, snum; + QTableWidgetItem*hitem, *item; + ui.datasheetTableWidget->setColumnCount(col); + ui.datasheetTableWidget->setRowCount(std::min(MAXROW,row+HEADROWS)); + + //reserve the previous selection + int oldtype = this->m_coltype; + int oldx = this->m_colx; + int oldy = this->m_coly; + int oldz = this->m_colz; + + for(i=0; isetHorizontalHeaderItem(i, hitem); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(0, item); + title.append(tr("type")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(0, i, item); + } + + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(1, item); + title.append(tr("X")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(1, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(2, item); + title.append(tr("Y")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(2, i, item); + } + + title.clear(); + item = new QTableWidgetItem(title); + ui.datasheetTableWidget->setVerticalHeaderItem(3, item); + title.append(tr("Z")); + for(i=0; isetCheckState(Qt::Unchecked); + item->setBackgroundColor(QColor(BKR, BKG, BKB)); + ui.datasheetTableWidget->setItem(3, i, item); + } + + //for(j=HEADROWS; jrow) break; + + snum.setNum(j-HEADROWS+1); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(j, item); + + for(i=0; im_SampleDataSheet->GetData(i)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(j, i, item); + } + + } + + if(row >MAXROW-2) + { + snum.clear(); + snum.append(tr("...")); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-2, item); + for(i=0; isetItem(MAXROW-2, i, item); + } + + snum.setNum(row); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setVerticalHeaderItem(MAXROW-1, item); + for(i=0; im_SampleDataSheet->GetData(i); + snum.setNum(cdata[row-1], 'e', 5); + item = new QTableWidgetItem(snum); + ui.datasheetTableWidget->setItem(MAXROW-1, i, item); + } + } + + this->m_coltype = oldtype; + this->m_colx = oldx; + this->m_coly = oldy; + this->m_colz = oldz; + + //set the check state + if(this->m_coltype >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(0, this->m_coltype); + item->setCheckState(Qt::Checked); + } + //set the check state + if(this->m_colx >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(1, this->m_colx); + item->setCheckState(Qt::Checked); + } + //set the check state + if(this->m_coly >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(2, this->m_coly); + item->setCheckState(Qt::Checked); + } + //set the check state + if(this->m_colz >=0) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(3, this->m_colz); + item->setCheckState(Qt::Checked); + } + return; +} + +void VisAtom_SelectSampleDataDlg::OnDatasheetChanged(QTableWidgetItem*item) +{ + int col = item->column(); + int row = item->row(); + int checked = item->checkState(); + if(row >= HEADROWS) return; + + if(checked) + { + int i; + for(i=0; icolumnCount(); i++) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(row, i); + if(i != col) item->setCheckState(Qt::Unchecked); + } + for(i=0; iitem(i, col); + if(i != row) item->setCheckState(Qt::Unchecked); + } + + if(row == 0) //type is selected + { + QString snum; + int j; + //restore the float format if type colume select before; + if(this->m_coltype >=0) + { + QString snum; + int j; + //for(j=HEADROWS; jGetNumRow())-2; j++) + for(j=HEADROWS; j m_SampleDataSheet->GetNumRow()) break; + + QTableWidgetItem*item = ui.datasheetTableWidget->item(j, this->m_coltype); + float cdata = this->m_SampleDataSheet->GetData(this->m_coltype)[j-HEADROWS]; + snum.setNum(cdata, 'e', 5); + item->setText(snum); + } + if(m_SampleDataSheet->GetNumRow() >MAXROW-2) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(MAXROW-1, this->m_coltype); + float cdata = this->m_SampleDataSheet->GetData(this->m_coltype)[m_SampleDataSheet->GetNumRow()-1]; + snum.setNum(cdata, 'e', 5); + item->setText(snum); + } + } + + //for(j=HEADROWS; jGetNumRow())-2; j++) + for(j=HEADROWS; j m_SampleDataSheet->GetNumRow()) break; + QTableWidgetItem*item = ui.datasheetTableWidget->item(j, col); + int ityp = this->m_SampleDataSheet->GetData(col)[j-HEADROWS] + 0.000001; + snum.setNum(ityp); + item->setText(snum); + } + if(m_SampleDataSheet->GetNumRow() >MAXROW-2) + { + QTableWidgetItem*item = ui.datasheetTableWidget->item(MAXROW-1, col); + int ityp = this->m_SampleDataSheet->GetData(col)[m_SampleDataSheet->GetNumRow()-1] + 0.000001; + snum.setNum(ityp); + item->setText(snum); + } + // + } + ////////////////////////////////////// + switch(row) + { + case VisAtomDataSheet::COLPROP_TYPE: + this->m_coltype = col; + break; + case VisAtomDataSheet::COLPROP_POSX: + this->m_colx = col; + break; + case VisAtomDataSheet::COLPROP_POSY: + this->m_coly = col; + break; + case VisAtomDataSheet::COLPROP_POSZ: + this->m_colz = col; + break; + } + } + else //unchecked + { + switch(row) + { + case VisAtomDataSheet::COLPROP_TYPE: + this->m_coltype = -1; + break; + case VisAtomDataSheet::COLPROP_POSX: + this->m_colx = -1; + break; + case VisAtomDataSheet::COLPROP_POSY: + this->m_coly = -1; + break; + case VisAtomDataSheet::COLPROP_POSZ: + this->m_colz = -1; + break; + } + } + //write the col labels + WriteColLabels(); + //if( this->m_coltype>=0 && this->m_colx>=0 && this->m_coly>= 0 && this->m_colz >= 0) + if( this->m_colx>=0 && this->m_coly>= 0 && this->m_colz >= 0) + ui.okButton->setEnabled(true); + else + ui.okButton->setEnabled(false); + + return; +} + +void VisAtom_SelectSampleDataDlg::WriteColLabels() +{ + //write the col labels + QString title, snum; + + if(this->m_coltype >= 0) {title = tr("Col.#"); snum.setNum(this->m_coltype+1); title.append(snum);} + else title = tr("N/A"); + ui.coltypeLabel->setText(title); + + if(this->m_colx >= 0) {title = tr("Col.#"); snum.setNum(this->m_colx+1); title.append(snum);} + else title = tr("N/A"); + ui.colxLabel->setText(title); + + if(this->m_coly >= 0) {title = tr("Col.#"); snum.setNum(this->m_coly+1); title.append(snum);} + else title = tr("N/A"); + ui.colyLabel->setText(title); + + if(this->m_colz >= 0) {title = tr("Col.#"); snum.setNum(this->m_colz+1); title.append(snum);} + else title = tr("N/A"); + ui.colzLabel->setText(title); + + return; +} + +void VisAtom_SelectSampleDataDlg::OnShowAgainCheckBox(bool no) +{ + m_showthisdlg = !no; +} + diff --git a/VisAtom2017/visatom_selectsampledataDlg.h b/VisAtom2017/visatom_selectsampledataDlg.h new file mode 100644 index 0000000..77b3808 --- /dev/null +++ b/VisAtom2017/visatom_selectsampledataDlg.h @@ -0,0 +1,44 @@ +#ifndef VISATOMSELECTSAMPLEDATA_H +#define VISATOMSELECTSAMPLEDATA_H + +#include +#include "Ui_visatom_selectsampledataDlg.h" + +class VisAtomDataSheet; +class VisAtom_SelectSampleDataDlg : public QDialog +{ + Q_OBJECT + +protected: + VisAtomDataSheet*m_SampleDataSheet; + + static int m_coltype, m_colx, m_coly, m_colz; + static int m_showthisdlg; +public: + VisAtom_SelectSampleDataDlg(QWidget *parent = Q_NULLPTR); + ~VisAtom_SelectSampleDataDlg(); + + void SetDataSheet(VisAtomDataSheet*pData); + static void GetDataCol(int col[4]) + { + col[0] = m_coltype; + col[1] = m_colx; + col[2] = m_coly; + col[3] = m_colz; + } + + static bool IsShowAgain(){return m_showthisdlg;} + + +private slots: + void OnDatasheetChanged(QTableWidgetItem*item); + void OnShowAgainCheckBox(bool no); + void WriteColLabels(); + + +private: + Ui::visatom_selectsampledataDlg ui; + +}; + +#endif // VISATOMNEWVECTORPOLICY_H diff --git a/VisAtom2017/visatom_selectsampledataDlg.ui b/VisAtom2017/visatom_selectsampledataDlg.ui new file mode 100644 index 0000000..f70eb2b --- /dev/null +++ b/VisAtom2017/visatom_selectsampledataDlg.ui @@ -0,0 +1,323 @@ + + + visatom_selectsampledataDlg + + + + 0 + 0 + 541 + 382 + + + + Dialog + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + + + + + + Position Y: + + + + + + + QFrame::Box + + + QFrame::Raised + + + N/A + + + + + + + Position X: + + + + + + + QFrame::Box + + + QFrame::Raised + + + N/A + + + + + + + Position Z: + + + + + + + Atom type: + + + false + + + + + + + QFrame::Box + + + QFrame::Raised + + + N/A + + + Qt::AutoText + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + :/VisAtom2013_1/solidsphere.png + + + false + + + + + + + QFrame::Box + + + QFrame::Raised + + + N/A + + + + + + + + + Qt::NoFocus + + + Qt::NoContextMenu + + + false + + + true + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + false + + + false + + + QAbstractItemView::NoSelection + + + true + + + Qt::DashDotLine + + + true + + + false + + + 4 + + + 4 + + + true + + + false + + + false + + + + + + + + + + + + + + + + + Do not show again + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + OK + + + + + + + Cancel + + + + + + + + + + + + + + okButton + clicked() + visatom_selectsampledataDlg + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + visatom_selectsampledataDlg + reject() + + + 369 + 253 + + + 179 + 282 + + + + + datasheetTableWidget + itemChanged(QTableWidgetItem*) + visatom_selectsampledataDlg + OnDatasheetChanged(QTableWidgetItem*) + + + 252 + 196 + + + 252 + 187 + + + + + showagainCheckBox + clicked(bool) + visatom_selectsampledataDlg + OnShowAgainCheckBox(bool) + + + 72 + 359 + + + 270 + 190 + + + + + + OnDatasheetChanged(QTableWidgetItem*) + OnShowAgainCheckBox(bool) + + diff --git a/VisAtom2017/visatomaboutDlg.ui b/VisAtom2017/visatomaboutDlg.ui new file mode 100644 index 0000000..05aa325 --- /dev/null +++ b/VisAtom2017/visatomaboutDlg.ui @@ -0,0 +1,147 @@ + + + visatomaboutForm + + + + 0 + 0 + 620 + 340 + + + + + 620 + 340 + + + + + 620 + 340 + + + + false + + + About + + + + :/VisAtom2017/VisAtoms21.ico:/VisAtom2017/VisAtoms21.ico + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + 0 + 0 + + + + + 160 + 60 + + + + + 160 + 5000 + + + + true + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/VisAtom2017/images/SCUlogo.png" /></p></body></html> + + + + + + + + + + + + 500 + 16777215 + + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> <span style=" font-size:14pt; font-weight:600;">ABOUT VisAtom2017</span> </p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-weight:600;"><br /></p> +<p align="justify" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">INTRODUCTION:</span> VisAtom2017 is a tool for visualizing results of MD calculations.It provides 3D display of atomistic structures of materials. One can rotate, translate, zoom and clip the scene. One can also coloring the atoms in different styles. The graphics can be copied into clipboard and then pasted in presentation documnets,for example,PowerPoint.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="justify" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">HISTORY: </span>VisAtom2017 is a version adapted from Visatom2013. The first version is VisAtoms21 which was written by the author in the 1990s for in-lab use. There has been requirements of adding more functions in the tool. Thus new features have been added and modification on GUI has been made in the new version. </p> +<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">AUTHOR: </span>Qing HOU</p> +<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">ADDRESS:</span> Institute of Nuclear Science and Technology </p> +<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> Key Lab of Radiation Physics and Tehnology</p> +<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> Sichuan University</p> +<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p></body></html> + + + + + + + + + + diff --git a/VisAtom2017/visatomaboutdlg.cpp b/VisAtom2017/visatomaboutdlg.cpp new file mode 100644 index 0000000..38eda05 --- /dev/null +++ b/VisAtom2017/visatomaboutdlg.cpp @@ -0,0 +1,12 @@ +#include "visatomaboutdlg.h" + +VisAtomAboutDlg::VisAtomAboutDlg(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); +} + +VisAtomAboutDlg::~VisAtomAboutDlg() +{ + +} diff --git a/VisAtom2017/visatomaboutdlg.h b/VisAtom2017/visatomaboutdlg.h new file mode 100644 index 0000000..8b7bbd7 --- /dev/null +++ b/VisAtom2017/visatomaboutdlg.h @@ -0,0 +1,19 @@ +#ifndef VISATOMABOUTDLG_H +#define VISATOMABOUTDLG_H + +#include +#include "ui_visatomaboutdlg.h" + +class VisAtomAboutDlg : public QDialog +{ + Q_OBJECT + +public: + VisAtomAboutDlg(QWidget *parent = 0); + ~VisAtomAboutDlg(); + +private: + Ui::visatomaboutForm ui; +}; + +#endif // VISATOMABOUTDLG_H