llpreviewlandmark.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpreviewlandmark.h"
00035 
00036 #include "llassetstorage.h"
00037 #include "llfocusmgr.h"
00038 #include "llfontgl.h"
00039 #include "llgl.h"
00040 #include "llinventory.h"
00041 #include "message.h"
00042 
00043 #include "llagent.h"
00044 #include "llbutton.h"
00045 #include "lleconomy.h"
00046 #include "llfloaterworldmap.h"
00047 #include "llinventoryview.h"
00048 #include "lliconctrl.h"
00049 #include "lllandmarklist.h"
00050 #include "lllineeditor.h"
00051 #include "llpanelplace.h"
00052 #include "llresmgr.h"
00053 #include "llstatusbar.h"
00054 #include "lltextbox.h"
00055 #include "llui.h"
00056 #include "llviewercontrol.h"
00057 #include "llviewerregion.h"
00058 #include "llviewerstats.h"
00059 #include "lluictrlfactory.h"
00060 
00061 
00062 
00063 
00065 // LLPreviewLandmark
00066 
00067 // static
00068 LLPreviewLandmarkList LLPreviewLandmark::sOrderedInstances;
00069 
00070 
00071 LLPreviewLandmark::LLPreviewLandmark(const std::string& name,
00072                                                                          const LLRect& rect,
00073                                                                          const std::string& title,
00074                                                                          const LLUUID& item_uuid,
00075                                                                          BOOL show_keep_discard,
00076                                                                          LLViewerInventoryItem* inv_item)
00077 :       LLPreview(name,
00078                           LLRect(rect.mLeft, 
00079                                         rect.mTop, 
00080                                         (show_keep_discard ? rect.mRight+70 : rect.mRight), 
00081                                         rect.mBottom), 
00082                           title, 
00083                           item_uuid, 
00084                           LLUUID::null, // object id
00085                           FALSE,  // allow resize
00086                           0, 0, // min dimensions
00087                           inv_item),
00088         mLandmark( NULL )
00089 {
00090         
00091         mFactoryMap["place_details_panel"] = LLCallbackMap(LLPreviewLandmark::createPlaceDetail, this);
00092         LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_existing_landmark.xml", &getFactoryMap());
00093 
00094         /*
00095         childSetCommitCallback("desc_editor", LLPreview::onText, this);
00096         childSetText("desc_editor", item->getDescription());
00097         childSetText("name_editor", item->getName());
00098         childSetPrevalidate("desc_editor", &LLLineEditor::prevalidatePrintableNotPipe);
00099 
00100         setTitle(title);
00101         
00102         if (!getHost())
00103         {
00104                 LLRect curRect = getRect();
00105                 translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
00106         }
00107         */
00108         LLPreviewLandmark::sOrderedInstances.push_back( this );
00109 }
00110 
00111 LLPreviewLandmark::~LLPreviewLandmark()
00112 {
00113         LLPreviewLandmarkList::iterator this_itr;
00114         this_itr = std::find(LLPreviewLandmark::sOrderedInstances.begin(), 
00115                         LLPreviewLandmark::sOrderedInstances.end(), this);
00116         if (this_itr != LLPreviewLandmark::sOrderedInstances.end())
00117         {
00118                 LLPreviewLandmark::sOrderedInstances.erase(this_itr);
00119         }
00120 }
00121 
00122 
00123 // Distance and direction from avatar to landmark.
00124 // Distance is in meters; degrees is angle from east (north = 90)
00125 void LLPreviewLandmark::getDegreesAndDist( F32* degrees, F64* horiz_dist, F64* vert_dist) const
00126 {
00127         if( mLandmark )
00128         {
00129                 LLVector3d pos;
00130                 if(mLandmark->getGlobalPos(pos))
00131                 {
00132                         LLVector3d to_vec = pos - gAgent.getPositionGlobal();
00133                         *horiz_dist = sqrt(to_vec.mdV[VX] * to_vec.mdV[VX] + to_vec.mdV[VY] * to_vec.mdV[VY]);
00134                         *vert_dist = to_vec.mdV[VZ];
00135                         *degrees = F32( RAD_TO_DEG * atan2( to_vec.mdV[VY], to_vec.mdV[VX] ) );
00136                 }
00137         }
00138 }
00139 
00140 const LLString& LLPreviewLandmark::getName() const
00141 {
00142         const LLInventoryItem *item = getItem();
00143         if (item)
00144         {
00145                 return item->getName();
00146         }
00147         return LLString::null;
00148 }
00149 
00150 LLVector3d LLPreviewLandmark::getPositionGlobal() const
00151 {
00152         LLVector3d pos;
00153         if( mLandmark )
00154         {
00155                 // we can safely ignore the return value here.
00156                 (void)mLandmark->getGlobalPos(pos);
00157         }
00158         return pos;
00159 }
00160 
00161 
00162 const LLColor4& LLPreviewLandmark::getMarkerColor() const
00163 {
00164         return mMarkerColor;
00165 }
00166 
00167 void LLPreviewLandmark::draw()
00168 {
00169         const LLInventoryItem *item = getItem();
00170 
00171         if( item && !mLandmark )
00172         {
00173                 mLandmark = gLandmarkList.getAsset( item->getAssetUUID() );
00174                 if(mLandmark && mPlacePanel)
00175                 {
00176                         LLVector3 pos_region = mLandmark->getRegionPos();       // always have this
00177                         LLUUID landmark_asset_id = item->getAssetUUID();        // always have this
00178                         LLUUID region_id;
00179                         mLandmark->getRegionID(region_id);              // might find null?
00180                         LLVector3d pos_global = getPositionGlobal();    // might be 0
00181                         mPlacePanel->displayParcelInfo(pos_region, landmark_asset_id, region_id, pos_global);
00182                 }
00183         }
00184 
00185         LLPreview::draw();
00186 }
00187 
00188 void LLPreviewLandmark::loadAsset()
00189 {
00190         const LLInventoryItem *item = getItem();
00191 
00192         if( item && !mLandmark )
00193         {
00194                 mLandmark = gLandmarkList.getAsset( item->getAssetUUID() );
00195         }
00196         mAssetStatus = PREVIEW_ASSET_LOADING;
00197 }
00198 
00199 LLPreview::EAssetStatus LLPreviewLandmark::getAssetStatus()
00200 {
00201         const LLInventoryItem *item = getItem();
00202         if (item && gLandmarkList.assetExists(item->getAssetUUID()))
00203         {
00204                 mAssetStatus = PREVIEW_ASSET_LOADED;
00205         }
00206         return mAssetStatus;
00207 }
00208 // static
00209 void* LLPreviewLandmark::createPlaceDetail(void* userdata)
00210 {
00211         LLPreviewLandmark *self = (LLPreviewLandmark*)userdata;
00212         self->mPlacePanel = new LLPanelPlace();
00213         LLUICtrlFactory::getInstance()->buildPanel(self->mPlacePanel, "panel_place.xml");
00214         const LLInventoryItem* item = self->getItem();
00215         self->mPlacePanel->displayItemInfo(item);
00216 
00217         return self->mPlacePanel;
00218 }

Generated on Fri May 16 08:33:57 2008 for SecondLife by  doxygen 1.5.5