Daily Archives

Articles indexed Saturday March 13 2010

Page 14/89 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Best Practice: Accessing radio button group

    - by seth
    Looking for the best, standards compliant, cross browser compatible, forwards compatible way to access a group of radio buttons in the DOM (this is closely related to my other most recent post...), without the use of any external libraries. <input type="radio" value="1" name="myRadios" />One<br /> <input type="radio" value="2" name="myRadios" />Two<br /> I've read conflicting information on getElementsByName(), which seems like the proper way to do this, but I'm unclear if this is a standards compliant, forwards compatible solution. Perhaps there is a better way?

    Read the article

  • Is Matlab faster than Python?

    - by kame
    I want to compute magnetic fields of some conductors using the biot-savart-law and I want to use a 1000x1000x1000 matrix. Before I use Matlab, but now I want to use Python. Is Python slower than Matlab? How can I make Python faster? EDIT: Maybe the best way is to compute the big array with c/c++ and then transfering them to python. I want to visualise then with VPython. EDIT2: Could somebody give an advice for which is better in my case: C or C++?

    Read the article

  • Button to add value to array and then compare result with another array on IPhone.

    - by slickplaid
    I have ten buttons that each correspond to a different number. I'm looking to record the order that these buttons are pressed and enter them into an array and then compare it to another array that is static in the app. The check should be done on the Nth button press, where N equals the number of items in the other, static array. How do I A) have a button press add a value to an array B) stop after Nth button press equal to amount of numbers in the array I'm checking against and C) compare this array to the other array?

    Read the article

  • How to get a clipboard paste notification and provide my own data?

    - by Uwe Keim
    For a small utility I am writing (.NET, C#), I want to monitor clipboard copy operations and clipboard paste operations. My idea is to provide my own data when pasting into an arbitrary application. The monitoring of a copy operation can be easily done by using a clipboard viewer. Something that seems much more advanced to me is to write a "clipboard paste provider": Answer to "what formats are available" queries of applications. Supply data to application paste operations. I found this posting and this posting, but none of them seems to really help me. What I guess is that I somehow have to mimic/hijack the current clipboard. Question: Is it possible to "wrap" the clipboard in terms of paste operations and provide my own kind of "clipboard proxy"? Thanks Uwe

    Read the article

  • In Objective C, what's the best way to extract multiple substrings of text around multiple patterns?

    - by Matt
    For one NSString, I have N pattern strings. I'd like to extract substrings "around" the pattern matches. So, if i have "the quick brown fox jumped over the lazy dog" and my patterns are "brown" and "lazy" i would like to get "quick brown fox" and "the lazy dog." However, the substrings don't necessarily need to be delimited by whitespace. I have a hunch that there's a very easy solution to this, but I admit a disturbing lack of knowledge of Objective C string functions.

    Read the article

  • Designing interfaces: predict methods needed, discipline yourself and deal with code that comes to m

    - by fireeyedboy
    Was: Design by contract: predict methods needed, discipline yourself and deal with code that comes to mind I like the idea of designing by contract a lot (at least, as far as I understand the principal). I believe it means you define intefaces first before you start implementing actual code, right? However, from my limited experience (3 OOP years now) I usually can't resist the urge to start coding pretty early, for several reasons: because my limited experience has shown me I am unable to predict what methods I will be needing in the interface, so I might as well start coding right away. or because I am simply too impatient to write out the whole interfaces first. or when I do try it, I still wind up implementing bits of code already, because I fear I might forget this or that imporant bit of code, that springs to mind when I am designing the interfaces. As you see, especially with the last two points, this leads to a very disorderly way of doing things. Tasks get mixed up. I should draw a clear line between designing interfaces and actual coding. If you, unlike me, are a good/disciplined planner, as intended above, how do you: ...know the majority of methods you will be needing up front so well? Especially if it's components that implement stuff you are not familiar with yet. ...resist the urge to start coding right away? ...deal with code that comes to mind when you are designing the interfaces? UPDATE: Thank you for the answers so far. Valuable insights! And... I stand corrected; it seems I misinterpreted the idea of Design By Contract. For clarity, what I actually meant was: "coming up with interface methods before implementing the actual components". An additional thing that came up in my mind is related to point 1): b) How do you know the majority of components you will be needing. How do you flesh out these things before you start actually coding? For arguments sake, let's say I'm a novice with the MVC pattern, and I wanted to implement such a component/architecture. A naive approach would be to think of: a front controller some abstract action controller some abstract view ... and be done with it, so to speak. But, being more familiar with the MVC pattern, I know now that it makes sense to also have: a request object a router a dispatcher a response object view helpers etc.. etc.. If you map this idea to some completely new component you want to develop, with which you have no experience yet; how do you come up with these sort of additional components without actually coding the thing, and stuble upon the ideas that way? How would you know up front how fine grained some components should be? Is this a matter of disciplining yourself to think it out thoroughly? Or is it a matter of being good at thinking in abstractions?

    Read the article

  • jQuery Validation - Highlight Radio Labels Only

    - by Michael
    I'm trying to use jQuery validation to highlight the labels for my radio buttons only, and not the labels for my other inputs. I have a label for my radio button set called 'type'. I can't seem to get it to work! $(document).ready(function(){ $("#healthForm").validate({ highlight: function(element, errorClass) { $(element).addClass(errorClass) $(element.form).find("label[for='type']") .addClass("radioerror"); }, unhighlight: function(element, errorClass) { $(element).removeClass(errorClass) $(element.form).find("label[for='type']") .removeClass("radioerror"); }, errorPlacement: function(error, element) { } }); });

    Read the article

  • Silverlight at MIX10: New Framework Tracks Web Analytics

    Silverlight news will play a major part in Microsoft's annual MIX10 conference for Web developers and designers in Las Vegas next week....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • March 22-25th 2010 ESRI Developer Summit

    tweetmeme_source = 'alpascual';In 2 weeks the ESRI Developer Summit will start in Palm Springs, if you havent register, there is still time.   Created for Developers by Developers Prepare for tomorrow's challenges at the ESRI Developer Summit (DevSummit). It's the place to be for developers interested in using spatial technology in their applications. Bring your toughest questions for the ESRI engineers and hear insightful user presentations given by your peers. Register today Hope...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Hex Dump using LINQ (in 7 lines of code)

    Eric White has posted an interesting LINQ query on his blog that shows how to create a Hex Dump in something like 7 lines of code.Of course, this is not production grade code, but it's another good example that demonstrates the expressiveness of LINQ.Here is the code:byte[] ba = File.ReadAllBytes("test.xml");int bytesPerLine = 16;string hexDump = ba.Select((c, i) => new { Char = c, Chunk = i / bytesPerLine })    .GroupBy(c => c.Chunk)    .Select(g => g.Select(c...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • I can learn either C or Java, which one should I choose first? Should I take them concurrently?

    - by GR1000
    I realize this is a subject of hot debate, but I'm interested in opinions that relate to my specific situation. I want to learn the basics and fundamentals of programming, so I'm already taking a college course in general programming concepts. It isn't covering a specific language, but it's giving me a solid foundation that I can build upon when I move on to a class that teaches a specific language. My two options for a specific language are Java and C because those are the two languages taught at the college I want to take classes from. What I want to do is learn a complex language so that I can apply that knowledge to languages that I use, or will eventually use, in my current job building web pages: XHTML, CSS, JavaScript, PHP, XML, ActionScript. I'm not necessariy interested in becoming a Java developer or a C developer in the immediate future, but I do have aspirations of developing web applications and iPod/iPhone applications. So, basically, I'm looking for answers to these questions and the reasoning behind them: Do I take the introductory course in Java first, and then take the intro course in C, or Do I take C first and then take Java? Is there any reason not to take them concurrently? Should I skip C altogether as Java covers everything I need to know? EDIT: Thanks everyone for your thoughtful and insightful responses.

    Read the article

  • Special Character Meanings Defined

    - by Noctis Skytower
    In Python's module named string, there is a line that says whitespace = ' \t\n\r\v\f'. ' ' is a space character. '\t' is a tab character. '\n' is a newline character. '\r' is a carriage-return character. '\v' maps to '\x0b' (11). What does it mean and how might it be typed on a keyboard (any OS)? '\f' maps to '\x0c' (12). What does it mean and how might it be typed on a keyboard (any OS)?

    Read the article

  • Submitting a form on 'Enter' with jQuery?

    - by b. e. hollenbeck
    I have a bog-standard login form - an email text field, a password field and a submit button on an AIR project that's using HTML/jQuery. When I hit Enter on the form, the entire form's contents vanish, but the form isn't submitted. Does anyone know if this is a Webkit issue (Adobe AIR uses Webkit for HTML), or if I've bunged things up? I tried: $('.input').keypress(function(e){ if(e.which == 13){ $('form#login').submit(); } }); But that neither stopped the clearing behavior, or submitted the form. There's no action associated with the form - could that be the issue? Can I put a javascript function in the action?

    Read the article

  • C# Generics Question

    - by TheCloudlessSky
    Would it be possible to do something like the following in c#? Basically TParent and TChildren should be types of the class A but not necessairly have the same types that were passed in. I know this may sound confusing but I want to strongly type the children and parents of a particular object, but at the same time they must be of the same type. Because TParent inherits from A this would imply that it requires type parameters that inherit from A but using potentially different types. public class A<TParent, TChildren> where TParent : A where TControls : A { TParent Parent; List<TChildren> Children; } or more easily seen here: public class A<TParent, TChildren> where TParent : A<?, ?> where TChildren : A<?, ?> { TParent Parent; List<TChildren> Children; } I hope this isn't too confusing. Is this at all possible? Thanks :)

    Read the article

  • jQuery Validation - Highlighting Radio Labels

    - by Michael
    I'm trying to use jQuery validation to highlight the labels for my radio buttons only, and not the labels for my other inputs. I have a label for my radio button set called 'type'. I can't seem to get it to work! $(document).ready(function(){ $("#healthForm").validate({ highlight: function(element, errorClass) { $(element).addClass(errorClass) $(element.form).find("label[for='type']") .addClass("radioerror"); }, unhighlight: function(element, errorClass) { $(element).removeClass(errorClass) $(element.form).find("label[for='type']") .removeClass("radioerror"); }, errorPlacement: function(error, element) { } }); });

    Read the article

  • Google checkout callback API sending ack but nothing else?

    - by Chris Sobolewski
    I am putting together a test google checkout implementation and I cannot seem to get the code in the responsehandler demo to do anything aside from send acknowledgements. Even something as simple as uncommenting the folling lines case 'CHARGEABLE': { $Grequest->SendProcessOrder($data[$root]['google-order-number']['VALUE']); $Grequest->SendChargeOrder($data[$root]['google-order-number']['VALUE'],''); break; Isn't having the expected effect of causing the order to automatically be charged. The error log googlecheckout creates has no errors in it, and the message log shows that xml is being properly recieved and acknlowlegments are sent. Does anyone have a clue on how to start troubleshooting this? I am still rather fresh with PHP.

    Read the article

  • Can someone explain the fascination with twitter.com? [closed]

    - by raven
    I don't get it. WTF do people see in this? I'm trying to figure it out, but I can't. Have you seen what people post? Let's use Jeff Atwood as an example. What does he gain by posting (with disturbing frequency) all those, well... posts (I find the term "tweets" disgusting). What is a "follower" supposed to get from these posts? I know many of you are thinking, "Just don't use it!". Yes, I know I don't have to use it, but it's like asking me not to look at the space shuttle that just crashed in my front yard. The rest of the world thinks it's the greatest thing since sliced bread. I'm just trying to understand what people see in it.

    Read the article

  • Remote desktop type software that the client need not install anything...

    - by allentown
    I am primarily a Macintosh user, and can usually walk a client though any troubles they may have because I have a Macintosh in front of me. If they are on a different OS, things are close enough, or I cam remember, that I can get by. When trying to help clients on Windows, I get stuck. I do not have access to windows, and even if I did, there are far too many versions of Outlook, all with their various esoteric settings and checkboxes, that I could never see exactly what they are seeing. I mostly need to just help them with email setup. Something like copilot.com may do the trick. What is the simplest remote control software out there, ideally, it would accomplish these: No software needed on remote end, or, a single .exe that they can toss when done. I need Mac based software on my end. I do have ARD, which support VNC Free :) If possible, it would be really nice Needs a port forwarding proxy run by the company. There is no way I can get the user to alter their router, or to even plug directly into their WAN for a short time. On the Mac, I just have them open iChat, and this is all built in, proxying through AIM, looking for the same for Windows and Mac.

    Read the article

  • On the lighter side : sudo apt-get moo

    - by Arkapravo
    While dabbling about Ubuntu 9.10 ! I came across this command ! ..... sudo get-apt moo acer@acer:~$ sudo apt-get moo (__) (oo) /------\/ / | || * /\---/\ ~~ ~~ ...."Have you mooed today?"... Which most surprisingly 'made a MOO' ! .....Does anyone know any more such funnier outcomes of command line etc ?

    Read the article

  • Gplv3 and consulting

    - by Mjgp2
    If you are doing a one off piece of work as a consultant, for which the client receives only binaries, can you use gpl3 software ? You are working on behalf of the client and not distributing it. From a standard gpl FAQ: Q: I am an OXID partner/reseller/consultant and I occasionally do one-time OXID eShop Community Edition customization work for clients which are derived from OXID modules. These customizations are used only for the client. Do I need to make these changes publicly available? A: No, unless your client redistributes the code in which case the client must make it available to its licensees. Is this implying it is ok?

    Read the article

  • Global Hotkey in Mono and Gtk#

    - by Zach Johnson
    I'm trying to get a global hotkey working in Linux using Mono. I found the signatures of XGrabKey and XUngrabKey, but I can't seem to get them working. Whenever I try to invoke XGrabKey, the application crashes with a SIGSEGV. This is what I have so far: using System; using Gtk; using System.Runtime.InteropServices; namespace GTKTest { class MainClass { const int GrabModeAsync = 1; public static void Main(string[] args) { Application.Init(); MainWindow win = new MainWindow(); win.Show(); // Crashes here XGrabKey( win.Display.Handle, (int)Gdk.Key.A, (uint)KeyMasks.ShiftMask, win.Handle, true, GrabModeAsync, GrabModeAsync); Application.Run(); XUngrabKey( win.Display.Handle, (int)Gdk.Key.A, (uint)KeyMasks.ShiftMask, win.Handle); } [DllImport("libX11")] internal static extern int XGrabKey( IntPtr display, int keycode, uint modifiers, IntPtr grab_window, bool owner_events, int pointer_mode, int keyboard_mode); [DllImport("libX11")] internal static extern int XUngrabKey( IntPtr display, int keycode, uint modifiers, IntPtr grab_window); } public enum KeyMasks { ShiftMask = (1 << 0), LockMask = (1 << 1), ControlMask = (1 << 2), Mod1Mask = (1 << 3), Mod2Mask = (1 << 4), Mod3Mask = (1 << 5), Mod4Mask = (1 << 6), Mod5Mask = (1 << 7) } } Does anyone have a working example of XGrabKey? Thanks!

    Read the article

  • calculix data visualizor using QT

    - by Ann
    include "final1.h" include "ui_final1.h" include include include ifndef GL_MULTISAMPLE define GL_MULTISAMPLE 0x809D endif define numred 100 define numgrn 10 define numblu 6 final1::final1(QWidget *parent) : QGLWidget(parent) { setFormat(QGLFormat(QGL::SampleBuffers)); rotationX = -38.0; rotationY = -58.0; rotationZ = 0.0; scaling = .05; // glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //createGradient(); createGLObject(); } final1::~final1() { makeCurrent(); glDeleteLists(glObject, 1); } void final1::paintEvent(QPaintEvent * /* event */) { QPainter painter(this); draw(); } void final1::mousePressEvent(QMouseEvent *event) { lastPos = event-pos(); } void final1::mouseMoveEvent(QMouseEvent *event) { GLfloat dx = GLfloat(event-x() - lastPos.x()) / width(); GLfloat dy = GLfloat(event-y() - lastPos.y()) / height(); if (event->buttons() & Qt::LeftButton) { rotationX += 180 * dy; rotationY += 180 * dx; update(); } else if (event->buttons() & Qt::RightButton) { rotationX += 180 * dy; rotationZ += 180 * dx; update(); } lastPos = event->pos(); } void final1::createGLObject() { makeCurrent(); GLfloat f1[150],f2[150],f3[150],length=0; qreal size=2; int k=1,a,b,c,d,e,f,g,h,element_node_no=0; GLfloat x,y,z; QString str1,str2,str3,str4,str5,str6,str7,str8; int red,green,blue,index=1,displacement; int LUT[1000][3]; for(red=100;red glShadeModel(GL_SMOOTH); glObject = glGenLists(1); glNewList(glObject, GL_COMPILE); // qglColor(QColor(255, 239, 191)); glLineWidth(1.0); QLinearGradient linearGradient(0, 0, 100, 100); linearGradient.setColorAt(0.0, Qt::red); linearGradient.setColorAt(0.2, Qt::green); linearGradient.setColorAt(1.0, Qt::black); //renderArea->setBrush(linearGradient); //glColor3f(1,0,0);pow((f1[e]-f1[a]),2) QFile file("/home/41407/input1.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&file); while (!in.atEnd()) { QString line = in.readLine(); if(k<=125) { str1= line.section(',', 1, 1); str2=line.section(',', 2, 2); str3=line.section(',', 3, 3); x=str1.toFloat(); y=str2.toFloat(); z=str3.toFloat(); f1[k]=x; f2[k]=y; f3[k]=z; /* glBegin(GL_TRIANGLES); // glColor3f(LUT[k][0],LUT[k][1],LUT[k][2]); //QColorAt();//setPointSize(size); glVertex3f(x,y,z); glEnd();*/ } else if(k>125) { element_node_no=0; qCount(line.begin(),line.end(),',',element_node_no); // printf("\n%d",element_node_no); str1= line.section(',', 1, 1); str2=line.section(',', 2, 2); str3=line.section(',', 3, 3); str4= line.section(',', 4, 4); str5=line.section(',', 5, 5); str6=line.section(',', 6, 6); str7= line.section(',', 7, 7); str8=line.section(',', 8, 8); a=str1.toInt(); b=str2.toInt(); c=str3.toInt(); d=str4.toInt(); e=str5.toInt(); f=str6.toInt(); g=str7.toInt(); h=str8.toInt(); glBegin(GL_POLYGON); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //brush.setColor(Qt::black);//setColor(QColor::black()); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); // pmp.setBrush(gradient); glVertex3f(f1[a],f2[a] ,f3[a]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[b],f2[b] ,f3[b]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[c],f2[c] ,f3[c]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[d],f2[d] ,f3[d]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[a],f2[a] ,f3[a]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); //glEnd(); //glBegin(GL_LINE_LOOP); glVertex3f(f1[e],f2[e] ,f3[e]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[f],f2[f] ,f3[f]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[g],f2[g], f3[g]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[h],f2[h], f3[h]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[d],f2[d] ,f3[d]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[a],f2[a] ,f3[a]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glEnd(); glBegin(GL_POLYGON); //glVertex3f(f1[a],f2[a] ,f3[a]); glVertex3f(f1[e],f2[e] ,f3[e]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[h],f2[h], f3[h]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); //glVertex3f(f1[d],f2[d] ,f3[d]); glVertex3f(f1[g],f2[g], f3[g]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[c],f2[c] ,f3[c]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[f],f2[f] ,f3[f]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glVertex3f(f1[b],f2[b] ,f3[b]); glColor3f(LUT[k][0],LUT[k][1],LUT[k++][2]); glEnd(); /*length=sqrt(pow((f1[e]-f1[a]),2)+pow((f2[e]-f2[a]),2)+pow((f3[e]-f3[a]),2)); printf("\n%d",length);*/ } k++; } glEndList(); file.close(); k=1; QFile file1("/home/41407/op.txt"); if (!file1.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in1(&file1); k=1; while (!in1.atEnd()) { QString line = in1.readLine(); // if(k<=125) { str1= line.section(' ', 1, 1); x=str1.toFloat(); str2=line.section(' ', 2, 2); y=str2.toFloat(); str3=line.section(' ', 3, 3); z=str3.toFloat(); displacement=sqrt(pow( (x-f1[k]),2)+pow((y-f2[k]),2)+pow((z-f3[k]),2)); //printf("\n %d : %d",k,displacement); glBegin(GL_POLYGON); //glColor3f(LUT[displacement][0],LUT[displacement][1],LUT[displacement][2]); glVertex3f(f1[k],f2[k],f3[k]); glEnd(); a1[k]=x+f1[k]; a2[k]=y+f2[k]; a3[k]=z+f3[k]; //printf("\nc: %f %f %f",x,y,z); //printf("\nf: %f %f %f",f1[k],f2[k],f3[k]); //printf("\na: %f %f %f",a1[k],a2[k],a3[k]); } k++; glEndList(); } } void final1::draw() { glPushAttrib(GL_ALL_ATTRIB_BITS); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); GLfloat x = 3.0 * GLfloat(width()) / height(); glOrtho(-x, +x, -3.0, +3.0, 4.0, 15.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(0.0, 0.0, -10.0); glScalef(scaling, scaling, scaling); glRotatef(rotationX, 1.0, 0.0, 0.0); glRotatef(rotationY, 0.0, 1.0, 0.0); glRotatef(rotationZ, 0.0, 0.0, 1.0); glEnable(GL_MULTISAMPLE); glCallList(glObject); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); } /*uint final1::colorAt(int x) { generateShade(); QPolygonF pts = m_hoverPoints->points(); for (int i=1; i < pts.size(); ++i) { if (pts.at(i-1).x() <= x && pts.at(i).x() >= x) { QLineF l(pts.at(i-1), pts.at(i)); l.setLength(l.length() * ((x - l.x1()) / l.dx())); return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))), qRound(qMin(l.y2(), qreal(m_shade.height() - 1)))); } } return 0;*/ //final1:: //} /*void final1::createGLObject() { makeCurrent(); //QPainter painter; QPixmap pm(20, 20); QPainter pmp(&pm); pmp.fillRect(0, 0, 10, 10, Qt::blue); pmp.fillRect(10, 10, 10, 10, Qt::lightGray); pmp.fillRect(0, 10, 10, 10, Qt::darkGray); pmp.fillRect(10, 0, 10, 10, Qt::darkGray); pmp.end(); QPalette pal = palette(); pal.setBrush(backgroundRole(), QBrush(pm)); //setAutoFillBackground(true); setPalette(pal); //GLfloat f1[150],f2[150],f3[150],a1[150],a2[150],a3[150]; int k=1,a,b,c,d,e,f,g,h; //int p=0; GLfloat x,y,z; int displacement; QString str1,str2,str3,str4,str5,str6,str7,str8; int red,green,blue,index=1; int LUT[8000][3]; for(red=0;red //glShadeModel(GL_LINE); glObject = glGenLists(1); glNewList(glObject, GL_COMPILE); //qglColor(QColor(120,255,210)); glLineWidth(1.0); //glColor3f(1,0,0); QFile file("/home/41407/input.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&file); while (!in.atEnd()) { //glColor3f(LUT[k][0],LUT[k][1],LUT[k][2]); QString line = in.readLine(); if(k<=125) { //printf("\nline :%c",line); str1= line.section(',', 1, 1); str2=line.section(',', 2, 2); str3=line.section(',', 3, 3); x=str1.toFloat(); y=str2.toFloat(); z=str3.toFloat(); f1[k]=x; f2[k]=y; f3[k]=z; //printf("\nf: %f %f %f",f1[k],f2[k],f3[k]); } else if(k125) //for(p=0;p<6;p++) { //glColor3f(LUT[k][0],LUT[k][1],LUT[k][2]); update(); str1= line.section(',', 1, 1); str2=line.section(',', 2, 2); str3=line.section(',', 3, 3); str4= line.section(',', 4, 4); str5=line.section(',', 5, 5); str6=line.section(',', 6, 6); str7= line.section(',', 7, 7); str8=line.section(',', 8, 8); a=str1.toInt(); b=str2.toInt(); c=str3.toInt(); d=str4.toInt(); e=str5.toInt(); f=str6.toInt(); g=str7.toInt(); h=str8.toInt(); //for (p = 0; p < 6; p++) { // glBegin(GL_LINE_WIDTH); //glColor3f(LUT[126][0],LUT[126][1],LUT[126][2]); //update(); //glNormal3fv(&n[p][0]); //glVertex3f(f1[i],f2[i],f3[i]); glVertex3fv(&v[faces[i][1]][0]); glVertex3fv(&v[faces[i][2]][0]); glVertex3fv(&v[faces[i][3]][0]); //glEnd(); //} glBegin(GL_LINE_LOOP); //glColor3f(p*20,p*20,p); glColor3f(1,0,0); glVertex3f(f1[a],f2[a] ,f3[a]); //painter.fillRect(QRectF(f1[a],f2[a] ,f3[a], 2), Qt::magenta); glVertex3f(f1[b],f2[b] ,f3[b]); glVertex3f(f1[c],f2[c] ,f3[c]); glVertex3f(f1[d],f2[d] ,f3[d]); glVertex3f(f1[a],f2[a] ,f3[a]); glVertex3f(f1[e],f2[e] ,f3[e]); glVertex3f(f1[f],f2[f] ,f3[f]); glVertex3f(f1[g],f2[g], f3[g]); glVertex3f(f1[h],f2[h], f3[h]); glVertex3f(f1[d],f2[d] ,f3[d]); glVertex3f(f1[a],f2[a] ,f3[a]); //glColor3f(1,0,0); //QLinearGradient ( f1[a], f2[a], f1[b], f2[b] ); glEnd(); glBegin(GL_LINES); //glNormal3fv(&n[p][0]); //glColor3f(LUT[k][0],LUT[k][1],LUT[k][2]); glVertex3f(f1[e],f2[e] ,f3[e]); glVertex3f(f1[h],f2[h], f3[h]); glVertex3f(f1[g],f2[g], f3[g]); glVertex3f(f1[c],f2[c] ,f3[c]); glVertex3f(f1[f],f2[f] ,f3[f]); glVertex3f(f1[b],f2[b] ,f3[b]); glEnd(); } } k++; } glEndList(); qglColor(QColor(239, 255, 191)); glLineWidth(1.0); glColor3f(0,1,0); k=1; QFile file1("/home/41407/op.txt"); if (!file1.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in1(&file1); k=1; while (!in1.atEnd()) { QString line = in1.readLine(); // if(k<=125) { str1= line.section(' ', 1, 1); x=str1.toFloat(); str2=line.section(' ', 2, 2); y=str2.toFloat(); str3=line.section(' ', 3, 3); z=str3.toFloat(); displacement=sqrt(pow( (x-f1[k]),2)+pow((y-f2[k]),2)+pow((z-f3[k]),2)); printf("\n %d : %d",k,displacement); glBegin(GL_POINT); glColor3f(LUT[displacement][0],LUT[displacement][1],LUT[displacement][2]); glVertex3f(x,y,z); glLoadIdentity(); glEnd(); a1[k]=x+f1[k]; a2[k]=y+f2[k]; a3[k]=z+f3[k]; //printf("\nc: %f %f %f",x,y,z); //printf("\nf: %f %f %f",f1[k],f2[k],f3[k]); //printf("\na: %f %f %f",a1[k],a2[k],a3[k]); } k++; glEndList(); } }*/ /*void final1::draw() { glPushAttrib(GL_ALL_ATTRIB_BITS); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); GLfloat x = 3.0 * GLfloat(width()) / height(); glOrtho(-x, +x, -3.0, +3.0, 4.0, 15.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(0.0, 0.0, -10.0); glScalef(scaling, scaling, scaling); glRotatef(rotationX, 1.0, 0.0, 0.0); glRotatef(rotationY, 0.0, 1.0, 0.0); glRotatef(rotationZ, 0.0, 0.0, 1.0); glEnable(GL_MULTISAMPLE); glCallList(glObject); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); }*/ I need to change the color of a portion of beam where pressure is applied.But I am not able to color the front end back phase.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >