// Remove specified point from colourscale void ColourScale::removePoint(ColourScalePoint* point) { points_.remove(point); // Recalculate colour deltas calculateDeltas(); }
// Set colour and value data for point void ColourScale::setPoint(ColourScalePoint* point, double value, double r, double g, double b, double a, bool modifyValue, bool modifyColour) { Messenger::enter("ColourScale::setPoint"); // Set value if (modifyValue) { // Set the new value, then adjust position of point as necessary point->setValue(value); // -- Shuffle up (towards head = lower values) while (point->prev) { if (value < point->prev->value()) points_.shiftUp(point); else break; } // -- Shuffle down (towards tail = higher values) while (point->next) { if (value > point->next->value()) points_.shiftDown(point); else break; } } // Set colour if (modifyColour) point->setColour(r, g, b, a); // Recalculate colour deltas calculateDeltas(); // Refresh linked objects refreshObjects(); Messenger::exit("ColourScale::setPoint"); }
// Add point to scale ColourScalePoint* ColourScale::addPoint(double value, QColor colour) { ColourScalePoint* csp = NULL; // If supplied value is less than that at the start of the list, add it at the beginning. // If larget than the one at the end, then append it to the end of the list. // If neither of these, find the first existing value which is larger, and add it before that one if (points_.nItems() == 0) csp = points_.add(); else if (value > points_.last()->value()) csp = points_.add(); else for (ColourScalePoint* oldPoint = points_.first(); oldPoint != NULL; oldPoint = oldPoint->next) if (oldPoint->value() > value) { csp = points_.insertBefore(oldPoint); break; } if (csp == NULL) return NULL; // Now, set data in new point csp->setColour(colour); csp->setValue(value); // Recalculate colour deltas calculateDeltas(); return csp; }
/** * Move the mouse to a specific point. * @param point The coordinates to move the mouse to (x, y). */ void moveMouse(MMPoint point) { #if defined(IS_MACOSX) CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, CGPointFromMMPoint(point), kCGMouseButtonLeft); calculateDeltas(&move, point); CGEventPost(kCGSessionEventTap, move); CFRelease(move); #elif defined(USE_X11) Display *display = XGetMainDisplay(); XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, point.x, point.y); XSync(display, false); #elif defined(IS_WINDOWS) //Mouse motion is now done using SendInput with MOUSEINPUT. We use Absolute mouse positioning #define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1)) point.x = MOUSE_COORD_TO_ABS(point.x, GetSystemMetrics(SM_CXSCREEN)); point.y = MOUSE_COORD_TO_ABS(point.y, GetSystemMetrics(SM_CYSCREEN)); INPUT mouseInput; mouseInput.type = INPUT_MOUSE; mouseInput.mi.dx = point.x; mouseInput.mi.dy = point.y; mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; mouseInput.mi.time = 0; //System will provide the timestamp mouseInput.mi.dwExtraInfo = 0; mouseInput.mi.mouseData = 0; SendInput(1, &mouseInput, sizeof(mouseInput)); #endif }
// Remove old point from colourscale void ColourScale::removePoint(int position) { // Check position supplied if ((position < 0) || (position >= points_.nItems())) { printf("Scale point position to set (%i) is invalid - nItems = %i.\n", position, points_.nItems()); return; } points_.remove( points_[position] ); // Recalculate colour deltas calculateDeltas(); }
// Set all alpha values to that specified void ColourScale::setAllAlpha(double alpha) { QColor color; for (ColourScalePoint* csp = points_.first(); csp != NULL; csp = csp->next) { color = csp->colour(); int alphai = alpha*255; if (alphai < 0) alphai = 0; else if (alphai > 255) alphai = 255; color.setAlpha(alphai); csp->setColour(color); } calculateDeltas(); }
void dragMouse(MMPoint point, const MMMouseButton button) { #if defined(IS_MACOSX) const CGEventType dragType = MMMouseDragToCGEventType(button); CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType, CGPointFromMMPoint(point), (CGMouseButton)button); calculateDeltas(&drag, point); CGEventPost(kCGSessionEventTap, drag); CFRelease(drag); #else moveMouse(point); #endif }
// Assignment Operator ColourScale& ColourScale::operator=(const ColourScale& source) { name_ = source.name_; interpolated_ = source.interpolated_; visible_ = source.visible_; // Copy points and deltas points_ = source.points_; calculateDeltas(); // Copy reference objects grids_ = source.grids_; return *this; }
// Add point to scale ColourScalePoint* ColourScale::addPoint(double value, double r, double g, double b, double a) { Messenger::enter("ColourScale::addPoint"); // Find position to insert new point at ColourScalePoint* newPoint = NULL; if (points_.nItems() == 0) newPoint = points_.add(); else if (value < points_.first()->value()) newPoint = points_.prepend(); else if (value > points_.last()->value()) newPoint = points_.add(); else { for (ColourScalePoint* point = points_.first()->next; point != NULL; point = point->next) { if (value < point->value()) { newPoint = points_.insertBefore(point); break; } } } // Double-check we have a new point if (!newPoint) { printf("Internal Error: ColourScale::addPoint() failed to add a point.\n"); return NULL; } // Now, set data in new point newPoint->setParent(this); newPoint->setColour(r, g, b, a); newPoint->setValue(value); // Recalculate colour deltas calculateDeltas(); // Refresh linked objects refreshObjects(); Messenger::exit("ColourScale::addPoint"); return newPoint; }
// Set colour and value data for point void ColourScale::setPoint(int position, double value, QColor colour, bool setval, bool setcol) { // Check position supplied if ((position < 0) || (position >= points_.nItems())) { printf("Scale point position to set (%i) is invalid - nItems = %i.\n", position, points_.nItems()); return; } if (setcol) points_[position]->setColour(colour); if (setval) { points_[position]->setValue(value); // Position in list may have changed - check... bool minBad = true, maxBad = true; ColourScalePoint* csp = points_[position]; int dummy = 0; do { // printf("BEFORE SHIFT Prev = %f, current= %f, next = %f\n", csp->prev ? csp->prev->value() : -999, csp->value(), csp->next ? csp->next->value() : -999); // Shift item if necessary if (csp->prev && (csp->prev->value() > csp->value())) { points_.shiftUp(csp); minBad = (csp->prev ? (csp->prev->value() > csp->value()) : false); } else minBad = false; if (csp->next && (csp->next->value() < csp->value())) { points_.shiftDown(csp); maxBad = (csp->next ? (csp->next->value() < csp->value()) : false); } else maxBad = false; // printf("AFTER SHIFT %i Prev = %f, current= %f, next = %f B=%i %i\n", dummy, csp->prev ? csp->prev->value() : -999, csp->value(), csp->next ? csp->next->value() : -999, minBad, maxBad); if (++dummy == 10) break; } while (minBad || maxBad); } // Recalculate colour deltas calculateDeltas(); }
// Remove old point from colourscale void ColourScale::removePoint(int position) { Messenger::enter("ColourScale::removePoint"); // Check position supplied if ((position < 0) || (position >= points_.nItems())) { Messenger::print("Scale point position to set (%i) is invalid - nItems = %i.", position, points_.nItems()); Messenger::exit("ColourScale::removePoint"); return; } points_.remove( points_[position] ); // Recalculate colour deltas calculateDeltas(); // Refresh linked objects refreshObjects(); Messenger::exit("ColourScale::removePoint"); }
/** * Move the mouse to a specific point. * @param point The coordinates to move the mouse to (x, y). */ void moveMouse(MMPoint point) { #if defined(IS_MACOSX) CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, CGPointFromMMPoint(point), kCGMouseButtonLeft); calculateDeltas(&move, point); CGEventPost(kCGSessionEventTap, move); CFRelease(move); #elif defined(USE_X11) Display *display = XGetMainDisplay(); XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, point.x, point.y); XFlush(display); #elif defined(IS_WINDOWS) #define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1)) point.x = MOUSE_COORD_TO_ABS(point.x, GetSystemMetrics(SM_CXSCREEN)); point.y = MOUSE_COORD_TO_ABS(point.y, GetSystemMetrics(SM_CYSCREEN)); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, (DWORD)point.x, (DWORD)point.y, 0, 0); #endif }
int main(int argc, char *argv[]) { if(argc != 4) { printf("Usage: %s <dfe_ip> <cpu_ip> <netmask>\n", argv[0]); return 1; } struct in_addr dfe_ip; inet_aton(argv[1], &dfe_ip); struct in_addr cpu_ip; inet_aton(argv[2], &cpu_ip); struct in_addr netmask; inet_aton(argv[3], &netmask); const int port = 5008; /* Create DFE Socket, then listen */ max_file_t *maxfile = FieldAccumulatorTCP_init(); max_engine_t *engine = max_load(maxfile, "*"); max_ip_config(engine, MAX_NET_CONNECTION_CH2_SFP1, &dfe_ip, &netmask); max_udp_socket_t *dfe_socket = max_udp_create_socket(engine, "udp_ch2_sfp1"); max_udp_bind(dfe_socket, port); max_udp_connect(dfe_socket, &cpu_ip, port); int cpu_socket = create_cpu_udp_socket(&cpu_ip, &dfe_ip, port); FILE *stream = fopen("source_data1.csv", "r"); char line[BUFFERSIZE]; // char *to_be_free = line; /* Ignore Header File */ fgets(line, BUFFERSIZE, stream); printf(line); while (fgets(line, BUFFERSIZE, stream)) { struct input_data data; parse(line,&data); printf("\n Instrument id = %d \n level = %d \n side = %d \n Quantity = %d \n Price = %d",data.instrument_id,data.level,data.side,data.quantity,data.price); calculateDeltas(cpu_socket, &data); } // /* Set Value A */ // data.instrument_id = 0; // data.level = 0; // data.side = 0; // data.quantity = 5; // data.price = 10; // calculateDeltas(cpu_socket, &data); // // /* Set B*/ // data.instrument_id = 1; // data.level = 0; // data.side = 1; // data.quantity = 3; // data.price = 4; // calculateDeltas(cpu_socket, &data); // // /* Hold */ // data.instrument_id = 1; // data.level = 0; // data.side = 1; // data.quantity = 5; // data.price = 6; // calculateDeltas(cpu_socket, &data); // // /* Set AB */ // data.instrument_id = 2; // data.level = 0; // data.side = 1; // data.quantity = 7; // data.price = 8; // calculateDeltas(cpu_socket, &data); max_udp_close(dfe_socket); max_unload(engine); max_file_free(maxfile); return 0; }
// Set whether or not to use HSV interpolation void ColourScale::setUseHSV(bool b) { useHSV_ = b; calculateDeltas(); }