EdgeStrengthHandle.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 
00012 #include "EdgeStrengthHandle.h"
00013 
00014 #include <GL/gl.h>
00015 #include <LinearMath/btTransform.h>
00016 
00017 #include "../document/SetEdgeStrengthDelta.h"
00018 
00019 namespace Track
00020 {
00021 
00022 namespace EditAssist
00023 {
00024 
00025 EdgeStrengthHandle::EdgeStrengthHandle(std::size_t edge_index, EdgeEnd adjust_end)
00026     :   LineConstrainedControlPoint(false, true)
00027     ,   edge_index(edge_index)
00028     ,   adjust_end(adjust_end)
00029 {
00030 }
00031 
00032 EdgeStrengthHandle::~EdgeStrengthHandle()
00033 {
00034 }
00035 
00036 void EdgeStrengthHandle::update(btVector3 source, btQuaternion angle, btScalar length)
00037 {
00038     start = source;
00039     
00040     // ensure the line used for constraint calculation never has 0 length,
00041     // even when the displayed line has 0 length.
00042     stop = source + btTransform(angle)(btVector3(0.0, 1.0, 0.0));
00043     position = source + btTransform(angle)(btVector3(0.0, length, 0.0));
00044 }
00045 
00046 boost::shared_ptr<Document::DocumentDelta> EdgeStrengthHandle::make_delta(btVector3 position) const
00047 {
00048     // Find strength. Position is always along the line.
00049     btVector3 line = position - start;
00050     btScalar strength = line.length();
00051     return boost::shared_ptr<Document::DocumentDelta>
00052     (
00053         new Document::SetEdgeStrengthDelta
00054         (
00055             Document::EdgeStrengthFinder(edge_index, adjust_end),
00056             strength
00057         )
00058     );
00059 }
00060 
00061 void EdgeStrengthHandle::draw() const
00062 {
00063     glColor3ub(127, 127, 255);
00064     LineConstrainedControlPoint::draw();
00065 }
00066 
00067 } // namespace EditAssist
00068 
00069 } // namespace Track

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:11 2010 by Doxygen version 1.4.7 for Racer version svn335.